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?
Awaiting for your response..
Hello Shashinkanth,
You can create the ExpandedIconTemplate for the layout you wish to modify. If you want this to be the root layout you need to set it only for it. For example in my sample applicaiton you can create an ExpandedIconTemplate for CategoryLayout instead of ProductLayout. You can read more about XamDataTree's capabilities and features from 'About xamDataTree' topic and it's sub topics.
Hi Zhivko,
I have used expanded icon template to modify the layout but it is applying only at the expander icon location. I need to change the entire item of the root node not just only the expander icon. I have implemented my approach by modifying the item template for root node layout but i need the root node not to be active node when user clicks on the root node. It just allow me to click on the content in the root node (like click on Button and selecting the value in combo box).
Please find the sample application which i have modified your original application which you have shared with me. Please help me to achieve this functionality.
Shashiakanth N.
Awaiting for your response