I am using XamDataTree and have three level of heirarchy on the tree view
Parent
- Child
- - Symbol
My Xaml looks something like below
<ig:XamDataTree Grid.Row="3" x:Name="FilterTree" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">
<ig:XamDataTree.CheckBoxSettings> <ig:CheckBoxSettings IsCheckBoxThreeState="True" CheckBoxVisibility="Visible" CheckBoxMode="Auto"/> </ig:XamDataTree.CheckBoxSettings> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="Grouped" TargetTypeName="ParentNode" DisplayMemberPath="Title"> </ig:NodeLayout> <ig:NodeLayout Key="L2" TargetTypeName="ChildNode" DisplayMemberPath="Title"> </ig:NodeLayout> <ig:NodeLayout Key="SymbolNodeKey" TargetTypeName="SymbolNode" CheckBoxMemberPath="IsChecked" DisplayMemberPath="Title"> </ig:NodeLayout> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
As you can see i am binding IsChecked member path to the leaf node's CheckBoxMemeberPath, the binding works well and I can see checkbox gets enable/disable from the code behind, the problem is that the parent node of the leaf does not automatically gets checked/unchecked when the leaf gets checked/unchecked from the code behind (the xamdatatree checkbox setting is in auto mode).
Can you suggest if it is a bug or if i am missing something? (please do not tell me that you'd expect users to maintain and enable/disable all parent nodes, if this is the case how can i set a parent node to be in a semi checked state i.e. when not all but only a few child nodes are checked).
Thanks
Hello,
Thank you for your post. I have been looking into it and have created a small sample for you. In the sample application I use a button to check a node. When a node is checked the parent layout gets expanded. In the sample application I bind the ChackBoxMemberPaht to the child layout. The IsCheckBoxThreeState is used when the CheckBoxMode is set to manual. Here is a link to our documentation, where you can find more information about this functionality: http://help.infragistics.com/Help/NetAdvantage/WPF/2013.1/CLR4.0/html/xamDataTree_xamDataTree_Check_Boxes.html.
Please refer to the attached sample application and feel free to let me know if you have any further questions on the matter.
Hi Gergana,
Thanks so much for looking into it, the problem is that I am using MVVM framework and I cannot directly have reference to the xamdatatree. I have modified your application to reflect that. I have added two properties "expanded" and "checked" on the Product/Category class and bounded it via IsExpandedMemberPath and CheckBoxMemberPath. When i click on the button right after the application loads, this is what I see.
If i expand the Beverage node first manually and then click on the button, the parent node gets checked perfectly.
How can i also check/uncheck the parent nodes when i check/uncheck only the leaf node, all by using only the binding on the itemsource and not by holding direct reference to xamdatatree?
Hi,
Could you please give any tentative dates when this issue will be picked up, I am required to hide the tree view inside an expander and until the view is visible, i cannot set the nodes checked.
Hello Rohit,
Thank you for your patience while our development team has been investigating the behavior that you are getting. After researching it, it turns out that this is the designed behavior of the XamDataTree in this scenario. In order to avoid this behavior you can use a recursive method that will iterate through the nodes of the XamDataTree.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
You mentioned you have updated the sample, could you please point me to it (i do not see any sample attached). thanks
Thank you for your reply. It seems that I have forgot to attach the sample application. I am attaching it now. Please let me know if you need any further assistance on the matter.
Hi Krasimir,
I have modified your sample such that we
- add one more node to the collection
- and then programatically check the new node
As you test it does not work.
Thank you for your reply. I have looked into the behavior and the reason for it is that when a new node is added, you should iterate through the nodes one more time to initialize the new node. Here is how you can do that:
public partial class MainWindow : Window
{
public MainWindow()
InitializeComponent();
this.FilterTree.Loaded += FilterTree_Loaded;
}
void FilterTree_Loaded(object sender, RoutedEventArgs e)
Loop();
private void checkNode_btn_Copy_Click_1(object sender, RoutedEventArgs e)
DataUtil.CategoriesAndProducts[0].Expanded = true;
DataUtil.CategoriesAndProducts[0].Products[3].Checked = true;
private void AddNode(object sender, RoutedEventArgs e)
var source = FilterTree.ItemsSource as ObservableCollection<Category>;
source[0].Products.Add(new Product()
ProductID = 1,
ProductName = "Special Chai",
CategoryID = 1,
QuantityPerUnit = "10 boxes x 20 bags",
UnitPrice = 18.0000m,
UnitsInStock = 39,
UnitsOnOrder = 0,
ReorderLevel = 10,
Discontinued = false
});
public void Loop()
Action<XamDataTreeNodesCollection> accessNodes = null;
accessNodes = (nodes) => { foreach (var n in nodes) accessNodes(n.Nodes); };
accessNodes(FilterTree.Nodes);