Hello,
I have a treeview control and want to check the nodes from code dynamically according to the values coming from the database. Below is my xaml
I try your solution at this page
http://www.telerik.com/community/forums/wpf/treeview/how-to-check-uncheck-items-from-code-behind.aspx
But could not resolve it. When i try the method mentioned at the solution it gives an error. The error comes from the if statement
"Object reference not set to an instance of an object". Below is the code.
Can you suggest a solution please.
Regards.
I have a treeview control and want to check the nodes from code dynamically according to the values coming from the database. Below is my xaml
<telerik:RadTabItem.Content> |
<telerik:RadTreeView Name="TreeViewCategories" SelectionMode="Extended" |
IsLineEnabled="True" ItemsOptionListType="CheckList" IsOptionElementsEnabled="True" |
IsRootLinesEnabled="True" IsTriStateMode="True" > |
<telerik:RadTreeView.ItemTemplate> |
<HierarchicalDataTemplate ItemsSource="{Binding Path=ChildCategories, Mode=TwoWay}"> |
<StackPanel> |
<TextBlock Text="{Binding Name}" Name="textblockName"></TextBlock> |
</StackPanel> |
</HierarchicalDataTemplate> |
</telerik:RadTreeView.ItemTemplate> |
</telerik:RadTreeView> |
</telerik:RadTabItem.Content> |
I try your solution at this page
http://www.telerik.com/community/forums/wpf/treeview/how-to-check-uncheck-items-from-code-behind.aspx
But could not resolve it. When i try the method mentioned at the solution it gives an error. The error comes from the if statement
"Object reference not set to an instance of an object". Below is the code.
void ItemContainerGenerator_StatusChanged(object sender, EventArgs e) |
{ |
if ((sender as RadTreeView).ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) |
{ |
foreach (RadTreeViewItem item in TreeViewCategories.Items) |
{ |
item.CheckState = System.Windows.Automation.ToggleState.On; |
} |
} |
} |
Can you suggest a solution please.
Regards.