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
960
Binding Active Dataitem and Selecting items from code behind
posted

I have two questions:

1) Can the ActiveDataItem property of the XamDataTree be bound to a property in the viewmodel

2) At the moment I'm setting the active node setting the ActiveDataItem property from code behind, but I haven't found the something like a Selected Node, or selected data item or something to allow me to activate and select a node on the tree from code behind or using the view model.

changing the active data item puts the active border around a node and makes it visible if it was not before but when the node is clicked it is not only activated but also selected.

is there a way to achieve this using the view model or the code behind.

Also, is it possible somehow access the Tree Node connected to the active data item?

thank you in advance

Parents
  • 34430
    Verified Answer
    Offline posted

    Hello Sabrina,

    Thank you for your post.

    1. Yes, the ActiveDataItem property of the XamDataTree is a dependency property, and so it can be bound to a ViewModel property.

    2. The XamDataTree has a SelectedDataItems property that accepts bindings from an object array. If you initialize this array as a property in your ViewModel and add an item from your data source to it, it will be selected on startup if bound. The same goes for the ActiveDataItem. You will need to bind it to an item in your bound data source.

    Regarding obtaining the tree node connected to the active data item, you cannot obtain it from the data item directly, but the XamDataTree has an ActiveNode property that you can use. It also has ActiveNodeChanging / ActiveNodeChanged events that you can handle to obtain this node from code.

    I have attached a sample application to demonstrate the above.

    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

    XamDataTreeActiveNodeCase.zip
Reply Children