I've got the following scenario:
The datacontext of my page contains of a dictionary with two key/value pairs. One holding the label translations and the other holding the object with the data.
I've bound all labels on the page to their corresponding entry in the translation dictionary, which works like a charm.
If I however want to bind the Captions of the ButtonTools in my Ribbon to the same dictionary, it doesn't work.
Works:
<TextBlock Text="{Binding Dict.[name]}" VerticalAlignment="Center" />
Doesn't work:
[...] <ig:XamRibbonGroup Id="TabGroup"> <ig:ButtonTool Caption="{Binding Dict.[name]}" Id="cmdSave" /> [...]
If I set the binding in the code it works:
Dim CaptionBinding As New Windows.Data.Binding("Dict.[name]") CaptionBinding.Source = Me.DataContext Dim ctlSave As Infragistics.Controls.Menus.SegmentedMenuTool = MyRibbon.FindToolById("cmdSave") Windows.Data.BindingOperations.SetBinding(ctlSave, Infragistics.Controls.Menus.RibbonTool.CaptionProperty, CaptionBinding)
But this is just not usable for approx 15 ribbons applicationwide with 10+ buttons / groups / tabs etc.
The exact same goes for the IsEnabled Property of the buttontool, i wanted to bind them to my context's HasChanges Property but couldn't do it in XAML and had to switch to code binding.
Hi,
Ribbon's tools are not FrameworkElements, so they do not participate in DataContext or ElementName bindings.
You should be able to use bindings if you expose your data context as a StaticResource:
<ig:ButtonTool Caption="{Binding Source={StaticResource context}, Path=Dict.[name]}" />
Hope this helps,