Question

I am using a Microsoft's Ribbon control in my application.

I've got an RibbonApplicationMenuItem with SubItems of the same Kind.The default behavior of the Ribbon menu is that whenever a submenu is opened using keyboard, the first item is selected (and highlighted) by default.

I have two menu items with subitems as shown in code below. The first menu opens correctly highlighting the first item. But the second menu doesn't highlight the first item when opened. The only difference is that in the second menu, my first item is disabled (IsEnabled=false). So I would expect the next item (second item) should be highlighted. BUT is doesn't :(. Anyone know how to fix this?

Moreover the worst part is, I can't navigate the second menu's submenu using Up/Down arrow keys like I can do with first menu. This is very strange and seems to me like a bug in the MS implementation. Does anyone has any idea !!?

(ribbon here is Microsoft.Windows.Controls.Ribbon)

      <ribbon:RibbonApplicationMenuItem Header="Options Group 1">
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption1}" Header="Option 1" />
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption2}" Header="Option 2"/>
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption3}" Header="Option 3"/>
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption4}" Header="Option 4"/>
       </ribbon:RibbonApplicationMenuItem>


       <ribbon:RibbonApplicationMenuItem Header="Options Group 2">
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption5}" Header="Option 5" IsEnabled="False"/>
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption6}" Header="Option 6"/>
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption7}" Header="Option 7"/>
                        <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption8}" Header="Option 8"/>
       </ribbon:RibbonApplicationMenuItem>
Was it helpful?

Solution

It seems the best I can do is to move the disabled menu item below the very first enabled menu item. Like this:

   <ribbon:RibbonApplicationMenuItem Header="Options Group 2">
                    <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption6}" Header="Option 6"/>
                    <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption5}" Header="Option 5" IsEnabled="False"/>
                    <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption7}" Header="Option 7"/>
                    <ribbon:RibbonApplicationMenuItem Command="{x:Static viewmodel:commands.ExecuteOption8}" Header="Option 8"/>
   </ribbon:RibbonApplicationMenuItem>

It works this way, though I know this is not the best way to do it. I think there is no other solution to this problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top