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
55
XamWebTree checkbox data binding
posted

 

How do we bind the xamWebTree checkbox to a bool field in the data source?

 For example, assuming the xamWebTree is bounded to

 

to a Categories collection with nested Products data. How can we get the checkbox values for the corresponding categories and products? Is there a way to bind the checkbox to a bool property in Category and Product?

What we are trying to do is ?

When the checkbox is selected on UI, we want to perform certain action on server and client. So how can we read the checkbox?

Thanks,

Parents
No Data
Reply
  • 40030
    Suggested Answer
    Offline posted

    Hi,

    So, the best way to bind a CheckBox to a bool field in your data source, is to use the ItemTemplate or HierarchicalItemTemplate property of the xamWebTree and place a Checkbox inside of it.

     <igTree:XamWebTree.HierarchicalItemTemplate>
              <ig:HierarchicalDataTemplate ItemsSource="{Binding Path=Products}">
                <ig:HierarchicalDataTemplate.ItemTemplate>
                  <DataTemplate>
                      <CheckBox Content="{Binding ProductName}" IsChecked="{Binding MyProductBoolProperty, Mode=TwoWay}">
                  </DataTemplate>
                </ig:HierarchicalDataTemplate.ItemTemplate>
                <DataTemplate>
                    <CheckBox Content="{Binding CategoryName}" IsChecked="{Binding MyCategoryBoolProperty, Mode=TwoWay}">
                </DataTemplate>
              </ig:HierarchicalDataTemplate>
            </igTree:XamWebTree.HierarchicalItemTemplate>

    Hope this helps,

    -SteveZ

Children