I can create a MenuTool in the 'traditional' manner and it works fine in this toolbar. As example:
<Ribbon:MenuTool Caption="Something" Ribbon:RibbonGroup.MaximumSize="ImageAndTextNormal"> <Ribbon:ToggleButtonTool Caption="First" IsChecked="True" /> <Ribbon:ToggleButtonTool Caption="Second" IsChecked="False" /> <Ribbon:ToggleButtonTool Caption="Third" IsChecked="True" /></Ribbon:MenuTool>
...works fine.
On the other hand, if I am binding a collection of items to a MenuTool in the same Ribbon and using ToggleButtonTool as the ItemTemplate for it, everything functions except the check-mark...
In the Ribbon:<Ribbon:MenuTool Caption="Show/Hide Items" Ribbon:RibbonGroup.MaximumSize="ImageAndTextNormal" ItemsSource="{Binding Items}" ItemTemplate="{StaticResource MenuItem}" />
In the ResourceDictionary:<DataTemplate x:Key="MenuItem"> <Ribbon:ToggleButtonTool IsChecked="{Binding IsVisible}" Caption="{Binding FullName}" /></DataTemplate>
I can use a CheckBox without problem, but it doesn't look as good. Any thoughts on this?
Thank you,rich
Rich,
I am attching a sample here that demonstrates what you are trying to achieve. Using ItemContainerStyle you need to enable IsCheckable property first, and then bind the ToggleButton's IsChecked state to your object's IsVisible property.
Sam
Hi Sam,
I'm not sure if it is something different with my installation, but I see 2 different behaviors with the togglebutton in your example. In the "something" menu tool I can click either on the checkbox area or the caption area and the check is either displayed or not...which is the behavior I would expect.
In the "Show/Hide" menu tool, the check is only displayed/hidden when I click on the checkbox area...if I click on the caption area nothing happens with the check mark. Also, the OnPropertyChanged is only fired when I click on the caption area...however, like I said the checkbox is not check/unchecked so I don't understand why the event is fired.
Thanks.