Ribbon application menu items not collapsing correctly

149 Views Asked by At

I'm trying to use the RibbonControlLibrary in a .NET 4.0 project. I have an application menu with menu items that need to be removed if some condition is not met. I tried using BooleanToVisibilityConverter, which removes the menu item just fine, but the menu itself doesn't change size, so there's a weird gap under the still visible items.

This is what it looks like when the menu item is set as collapsed using a binding: ribbon-wrong

This is what it's supposed to look like: ribbon-correct

If I hardcode the menu item as collapsed, it looks fine, but it's wrong when I use a binding or trigger to change the Visibility value. This makes me think that there is a bug causing the menu not to recalculate size when the items change.

Here is the XAML for the ribbon:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary">
<Window.Resources>
    <BooleanToVisibilityConverter x:Key="converter" />
</Window.Resources>
...

<ribbon:Ribbon>
    <ribbon:Ribbon.ApplicationMenu>
        <ribbon:RibbonApplicationMenu>
            <ribbon:RibbonApplicationMenuItem Header="Item 1"
                                              Visibility="{Binding TestProperty, Converter={StaticResource converter}}" />
            <ribbon:RibbonApplicationMenuItem Header="Item 2" />
        </ribbon:RibbonApplicationMenu>
    </ribbon:Ribbon.ApplicationMenu>
</ribbon:Ribbon>

I also tried setting Height to 0 using a trigger, but the effect was the same. Is there something I'm missing or is this a bug in the ribbon library?

0

There are 0 best solutions below