Search code examples
wpfribbon

Ribbon Auto-select Contextual Tab


I have a ribbon in my application with a contextual tab. I have managed to get the tab to show and hide itself correctly based on what is selected in my application. My question is, how would I get it to be automatically selected (i.e. brought to front) when it is shown?


Solution

  • I figured it out. Just needed to do a style trigger based on the visibility:

     <r:RibbonTab Header="Options"  
                         ContextualTabGroupHeader="Options" 
                         Visibility="{Binding CurrentFiles.SelectedItem, Converter={StaticResource DSToVisConverter}}" >
                <r:RibbonTab.Style>
                    <Style TargetType="r:RibbonTab">
                        <Style.Triggers>
                            <Trigger Property="Visibility" Value="Visible">
                                <Setter Property="IsSelected" Value="True" />
                            </Trigger>
                        </Style.Triggers>                        
                    </Style>                   
                </r:RibbonTab.Style>