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
135
XamDataTree "updateComplete" event
posted

I use mvvm in my application. So I have isChecked binded to the ViewModel property. The checkboxes are enabled.

When I click on a checkbox the tree automatically updates several layers, which is expected.

Each value on the tree works like a filter on the observable collection. So I have to recalculate it on every change.

But I don't want to do it on every call of Set method for isChecked property. 

Is there a way get a callback/event when the tree finishes its own updates? So I rebuild final collection after all the checkboxes were set/reset.

Thanks

Parents
  • 34810
    Offline posted

    Hello Alexis,

    I have been investigating into your requirement to conduct an action on check or uncheck of a checkbox in the XamDataTree, and it certainly makes sense that you do not want to consistently do this action for every checkbox that may be checked for a particular parent checkbox. Unfortunately, there is no event that fires after the checkboxes finish being recursively checked on the XamDataTree.

    Rather than trying to handle this after the checkboxes are checked, though, I would recommend instead handling it before they are. What I mean by this is that the CheckboxSettings of the XamDataTree have a CheckboxStyle property that you can set. Using this property, you can define a Style that hooks into the PreviewMouseDown event of the Checkboxes on your node so that you can catch the click on the node’s checkbox. This style would look something along the lines of the following:

                                <ig:CheckBoxSettings.CheckBoxStyle>
                                    <Style TargetType="{x:Type CheckBox}">
                                        <EventSetter Event="PreviewMouseDown" Handler="CheckBox_PreviewMouseDown" />
                                    </Style>                                    
                                </ig:CheckBoxSettings.CheckBoxStyle>

    Once this event is hooked, you can use the DataContext of the Checkbox, which will be a XamDataTreeNodeDataContext object to get either the Node or the underlying Data item for the node that the checkbox is attached to. You can then recursively loop through the child nodes / data items and construct your filter once on the basis of what the value of the checkbox will be for the parent node. Note, if you use the PreviewMouseDown event for this, this value will be the reverse of the Checkbox.IsChecked property, since the Checkbox will not have actually been checked yet.

    I hope this helps you. Please let me know if you have any other questions or concerns on this matter.

Reply Children