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.
Hi Rich,
I just tested the attached sample project again, and for me the check/uncheck is applied when I click on the caption area of 'show/Hide menu items. For me OnPropertyChanged event also gets raised for both; clicking on the check box and the caption, which is what I would expect. You may have a different installation that may affect on the behavior. Try running on different computers and see if it makes any differerence.
Thank you,
Sam...
That wasn't me asking that last question. I'm not in front of the code right now, but I believe we had the same problem. Wasn't there a change to a binding that was the final piece? Changing IsChecked to IsCheckable or something?
That change may be in your new upload, though.
rich
My misstake... addressing you on this. You are correct, the IsCheckable property nedds to be set to True. Here is an example:
<Style TargetType="{x:Type igRibbon:ToolMenuItem}"> <Setter Property="IsCheckable" Value="True"/> <Setter Property="IsChecked" Value="{Binding IsVisible}"/>