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 Rohit,
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);
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
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. 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,
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 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.