Hi,
I need to make XamDataTree with no expander and collapse icons and should always be in expandable state. Child nodes should add/remove dynamically at run time. This has to be implemented through MVVM.
Child node should be displayed with "Close" button so when user click on close button we should remove the child node.
When we select the child node, it should display the content at the right pane. No Selection should be made for root node (i.e. selection should be enabled only for child nodes).
Thanks and Regards,
Shashikanth N.
Hello Shashikanth ,
To expand all nodes you can create a recursive method which iterates though the nodes and set XamDataTreeNode's IsExpanded property to true, this way in the same method you can access the expansion button and set it's Visibility property to false, for example:
private void SetNodeExpandedState(IEnumerable<XamDataTreeNode> nodes, bool expandNode) { foreach (XamDataTreeNode item in nodes) { item.IsExpanded = expandNode; Application.Current.Dispatcher.BeginInvoke(new Action(() => { var expBtn = Infragistics.Windows.Utilities.GetDescendantFromType(item.Control, typeof(ExpansionIndicator), true) as ExpansionIndicator; if (null != expBtn) expBtn.Visibility = Visibility.Collapsed; }), System.Windows.Threading.DispatcherPriority.SystemIdle); this.SetNodeExpandedState(item.Nodes, expandNode); } }
Application.Current.Dispatcher.BeginInvoke(new Action(() => { var expBtn = Infragistics.Windows.Utilities.GetDescendantFromType(item.Control, typeof(ExpansionIndicator), true) as ExpansionIndicator; if (null != expBtn) expBtn.Visibility = Visibility.Collapsed; }), System.Windows.Threading.DispatcherPriority.SystemIdle); this.SetNodeExpandedState(item.Nodes, expandNode); } }
You can use XamDataTree's Loaded event to call SetNodeExpandedState method. To handle it in your view model you can use Interaction: <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded" SourceName="xdt"> <ei:CallMethodAction MethodName="XamDataTree_Loaded" TargetObject="{StaticResource vm}" /> </i:EventTrigger> </i:Interaction.Triggers>
By creating an ExpandedIconTemplate for the child layout you can add the 'Close' button you wish. Additional details are available on Configuring Expanded/Collapsed Node State topic.
From the following forum thread you can see how to update XamDataTree's ItemSource at runtime:
https://ko.infragistics.com/community/forums/t/74343.aspx
From Configuring Selected Data Items topic you can see an example of how XamDataTree SelectedDataItems property is used as an ItemsSource of the ListView control.
I have attached a simple sample application. You can use it as a starting point for implementing the functionalities you are trying to achieve. It will be great if you create a separate thread for each of your questions next time, this way the communication would be easier and there would be no confusion about the issues. Also other community members that have similar issues would be able to benefit from the threads too.
Let me know if you have any questions.
Sincerely,ZhivkoAssociate Software Developer
Thanks for your response. how can I change the only root node
template for xamdatatree control.
my requirement is it should display as list of HeaderedContentControls (each item will be list of items within header) So that’s the reason I choose
xamdatatree control. Do you think this is the right control for this?