How to expand a XamTree node on mouse click using Model-View-ViewModel pattern?
Hello Yashwant,
Thank you for your reply. I have been looking into your question and there is not XamDataTreeItem element. By reading through your post, it seems that you are using XamDataTree control. If this is correct and you wish to style the nodes of the tree, you can create a style for the XamDataTreeNodeControl, which is the visual representation of the nodes. The DataContext of the XamDataTreeNodeControl is a XamDataTreeNodeDataContext and you can use its Data property to get the data object corresponding to the node. Here is how the style should look like:
<Style x:Key="CustomStyle" TargetType="ig:XamDataTreeNodeControl">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Data.Synchronisation}" Value="2">
<Setter Property="BorderBrush" Value="Aqua"/>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi,
using library XamDataTreeview 12.1
Want to select/highlight a Treeviewnode by passing value from viewmodel, but not able to get TargetType => ig:XamDataTreeItem
gone thro' example ActiveNodeIndicator but it does not fullfill my requirement.
i have the collection of nodes, while binding the collection to xamdatatree im setting the value of "Synchronisation' to 2 for the that perticular node and checking that value in datatrigger if it is 2 then select that node in xamdatatree.
so please let me know how to achive this.
I am using the namespace
<xmlns:ig=http://schemas.infragistics.com/xaml
<Style x:Key="CustomStyle" TargetType="ig:XamDataTreeItem">
<DataTrigger Binding="{Binding Path=Synchronisation}" Value="2">
Thanks
Yashwant
I have created a sample application, which shows how can expand the node that is being clicked using Model-View-ViewModel approach. In order to do that you can add a IsExpanded property to the data objects that are used as source for the XamTree. Afreter doing so you can create a style for the XamTreeNode control and bound its IsExpanded property to the IsExpaned property in your data object. Then you can add an ActiveDataItem property to your ViewModel and bound this property to the ActiveItem property of the XamTree. In the Setter for the ActiveDataItem, set the ActiveDataItem.IsExpanded to true and when you click one of the items of the XamTree the setter for the ActiveDataItem property will fire and the currently activated node will be expanded.