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
XamDataTree SelectedNodesCollectionChanged event not fired

I created a user control with in it a XamDockManager with mulitple panes.

One of the panes has a usercontrol with a XamTabControl in it with 2 tabs which contains both a XamDataTree.

When a XamDataTree is in front (active in tab) and the main pane sets the selecteddataitems the event SelectedNodesCollectionChanged

is fired and handled. 

The problem is when the second XamDataTree is active (has no SelectedNodesCollectionChanged event handler) and the selecteddataitems is set then the event does not fire. If you select the tab the event is fired.

Is it possible to handle this event when the tab is not active where the xamdatatree is on ?



  • 28530
    Offline posted

    Hello Eddy,

    I have been investigating the behavior you are seeing, and the behavior you are currently seeing is expected. When elements are on a tab that is not currently in view in the XamDockManager, they are essentially unloaded as they are not in the visual tree of the WPF application.

    Internally, when the SelectedDataItems property of the XamDataTree changes, it triggers a method named ProcessPendingSelectedDataItems, which effectively does the selection and starts the chain of events that triggers the SelectedNodesCollectionChanged event. There is a check in this method, though, that checks to see if the XamDataTree is loaded, and if it is not, this method returns and does not do anything, as this method will be called when the Loaded event of the XamDataTree fires.

    As such, in its current implementation, there is no way to handle this event if the XamDataTree is not in a tab that is in view in the XamDockManager. Out of curiosity, though, if you know when you are changing the SelectedDataItems collection, for what reason do you need the event to fire for it? I would expect that you can just carry out your logic when your selection is made?

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