Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1775
The problem with bindings to CheckBoxTool
posted

Good afternoon.
Using ig: XamRibbon.

<ig:XamRibbon Grid.Row="0" x:Name="MyRibbon"...>
   <ig:XamRibbon.Tabs ...>
     <ig:XamRibbonTabItem ...>
       <ig:XamRibbonGroup Id="ColumnSettingsGroup"..>
       
         <ig:CheckBoxTool x:Name="EnableMoving" Id="EnableMoving" Caption="".../>


       </ ig: XamRibbonGroup>
     </ ig: XamRibbonTabItem>
   </ ig: XamRibbon.Tabs>
</ ig: XamRibbon>

There is a control with which to associate

<my2:DataGridControl Grid.Row="3" x:Name="NewGrid" Width="500" AllowColumnMoving="{Binding ElementName=EnableMoving, Path=IsChecked}" />

Here the problem, the link does not work.

When using a standard CheckBox it works.

In what may be the problem?

thank you very much

  • 6475
    posted

    Hi,

    The Ribbon tools are essentially DependencyObjects and they are not FrameworkElements. This is why they cannot participate in DataContext or ElementName bindings.

    If you try to access the CheckBoxTool from code behind using it's x:Name attribute, you'll see that you're not even allowed to do that (it will return null). This is a limitation of the platform.

    What you're allowed to do is to use bindings to a StaticResource.

    So, you have two options in this case:

    1. Add event handler to checkbox' Click event and toggle the AllowColumnMoving option of the grid

    OR

    2. Use a 'proxy' object as a StaticResource and bind Grid's AllowColumnMoving property and CheckBox' IsChecked property to this static resource.

    Attached is a sample that demonstrates both approaches.I used a regular button as a target element, changing it's IsEnabled property, but you can use the same approach for your grid.

     

    Hope this helps,

    RibbonSample.zip