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
1770
Event when data binding is finished
posted

Every time the itemsource property for my xamdatatree gets new data I would like to default the first node to IsChecked = true. I can do it like this when then tree first loads:

ItemsSource="{Binding OutageTypes, Mode=TwoWay}"
DisplayMemberPath="OutageTypeDesc"
NodeCheckedChanged="OutageTypeTree_OnNodeCheckedChanged"
Loaded="OutageTypeTree_OnLoaded">








private void OutageTypeTree_OnLoaded(object sender, RoutedEventArgs e)
{
OutageTypeTree.Nodes[0].IsChecked = true;
}

But I can't seem to find an event that fires after I change the dataset in OutageTypes to something else based on a selection the user makes in the UI. In the new dataset in object OutageTypes I have a property called IsChecked but defaulting it to true does not affect the tree.

How can I accomplish this?

Parents
  • 34810
    Verified Answer
    Offline posted

    Hello KrisVice,

    Thank you for your post.

    I have been investigating into this requirement that you are looking to achieve, and toward the end of your description, you mentioned an IsChecked property, which I imagine is either on your ViewModel or is on each of your data items that you are placing in your OutageTypes collection that you are binding to the tree. I would recommend that you continue with the latter of that statement. In other words, I would recommend that you add a property to your data item that you are displaying in the tree named IsChecked.

    The reason I recommend this, is because the XamDataTree has a property named CheckboxMemberPath. If you create an IsChecked property on your data item and then set this CheckboxMemberPath to "IsChecked," it will check the nodes that represent data items that have this property set to true. Then, you only need manipulate your collection to keep the first item in your collection's IsChecked property true when you repopulate that particular collection.

    I have attached a sample project which demonstrates this approach. In the sample, the data source is cleared and updated every 3 seconds and the item at collection[0] has its IsChecked property set to true.

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

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamDataTreeFirstNodeCheckedCase.zip
Reply Children