Selecting a menu tab

Bars for Avalonia Forum

Posted 2 days ago by Matt
Version: 25.2.1
Avatar

Hi,

Hopefully a simple question but I haven't quite been able to find what I am looking for:

Is there a way to select/bring to the front a specific Ribbon tab programmatically?  I was hoping there might be a simple SelectedItem in the RibbonViewModel but I can't see anything suitable. It looks like you do have similar in your WPF version of the ribbon menu. Contextual tabs don't quite fit for this use-case as all I want to do is ensure that a particular (always present) tab is at the front when certain assets are selected.

thanks! 

Matt

[Modified 2 days ago]

Comments (2)

Posted 2 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Matt,

Thank you for the suggestion.  What you are asking for isn't currently supported, but we'll be adding it to the next release.  Our MVVM library is open source, though, so you could also make the changes yourself and use a local build of the library until we publish the update.  All you need to do is add a "SelectedItem" property to RibbonViewModel.cs

private RibbonTabViewModel? _selectedItem;

...

/// <summary>
/// A <see cref="RibbonTabViewModel"/> for the currently selected tab.
/// </summary>
public RibbonTabViewModel? SelectedItem {
    get => _selectedItem;
    set => SetProperty(ref _selectedItem, value);
}

Then update the Ribbon control theme in ControlThemes.axaml to bind the view to the view model property:

<Setter Property="SelectedItem" Value="{Binding SelectedItem, Mode=TwoWay}" />


Actipro Software Support

Posted 1 days ago by Matt
Avatar

Thanks for the fast reply! Good news, and to be honest I am happy to wait for the next version if this is coming.

thanks,

Matt

Add Comment

Please log in to a validated account to post comments.