Jarred Froman
Top achievements
Rank 1
Jarred Froman
asked on 11 Sep 2008, 04:18 PM
I would like to bind to the checkbox on the Treeview using Templates and databinding. Does anybody know of a way to do this?
Thanks,
-Jarred Froman
Thanks,
-Jarred Froman
7 Answers, 1 is accepted
0
Jonathan Miller
Top achievements
Rank 1
answered on 12 Sep 2008, 02:28 PM
Hi Jarred, how do you want to bind the data? From WCF database?
0
Hello Jarred,
There are several events exposed from the checkbox/radio buttons in the RadTreeView - Checked, PreviewChecked. There is also CheckState property for the RadTreeViewItem that you can use.
What is the scenario? If using the existing mechanism is not extensible enough - what will make your life easier?
All the best,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
There are several events exposed from the checkbox/radio buttons in the RadTreeView - Checked, PreviewChecked. There is also CheckState property for the RadTreeViewItem that you can use.
What is the scenario? If using the existing mechanism is not extensible enough - what will make your life easier?
All the best,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jarred Froman
Top achievements
Rank 1
answered on 15 Sep 2008, 02:29 PM
Given the following code:
<UserControl.Resources>
<DataTemplate x:Key="CountryTemplate">
<TextBlock Text="{Binding Name, Mode=OneWay}" />
</DataTemplate>
<DataTemplate x:Key="RegionTemplate">
<TextBlock Text="{Binding Region, Mode=OneWay}" />
</DataTemplate>
<Telerik:HierarchicalDataTemplate x:Key="Region"
HeaderTemplate="{StaticResource RegionTemplate}"
ItemsSource = "{Binding Countries.Items, Mode=OneWay}"
ItemTemplate="{StaticResource CountryTemplate}" />
We would like to databind on the checkstate of each individual item without having to rely on events. Currently, the way we got around this is by not using the checkbox functionality already in the treeview and just using a CheckBox inside the datatemplate, however, we would prefer to work off the existing treeview functionality if possible.
Thanks,
-Jarred Froman
<UserControl.Resources>
<DataTemplate x:Key="CountryTemplate">
<TextBlock Text="{Binding Name, Mode=OneWay}" />
</DataTemplate>
<DataTemplate x:Key="RegionTemplate">
<TextBlock Text="{Binding Region, Mode=OneWay}" />
</DataTemplate>
<Telerik:HierarchicalDataTemplate x:Key="Region"
HeaderTemplate="{StaticResource RegionTemplate}"
ItemsSource = "{Binding Countries.Items, Mode=OneWay}"
ItemTemplate="{StaticResource CountryTemplate}" />
</UserControl.Resources>
<Client:GodotTreeView x:Name="trvSelectedCountries" IsEditable="False"
ItemsSource="{Binding Regions, Mode=OneWay}"
ItemTemplate="{StaticResource Region}" />
We would like to databind on the checkstate of each individual item without having to rely on events. Currently, the way we got around this is by not using the checkbox functionality already in the treeview and just using a CheckBox inside the datatemplate, however, we would prefer to work off the existing treeview functionality if possible.
Thanks,
-Jarred Froman
0
Jarred Froman
Top achievements
Rank 1
answered on 15 Sep 2008, 02:29 PM
Given the following code:
<UserControl.Resources>
<DataTemplate x:Key="RegionTemplate">
<TextBlock Text="{Binding Region, Mode=OneWay}" />
</DataTemplate>
<Telerik:HierarchicalDataTemplate x:Key="Region"
HeaderTemplate="{StaticResource RegionTemplate}"
ItemsSource = "{Binding Countries.Items, Mode=OneWay}"
ItemTemplate="{StaticResource CountryTemplate}" />
We would like to databind on the checkstate of each individual item without having to rely on events. Currently, the way we got around this is by not using the checkbox functionality already in the treeview and just using a CheckBox inside the datatemplate, however, we would prefer to work off the existing treeview functionality if possible.
Thanks,
-Jarred Froman
<UserControl.Resources>
<DataTemplate x:Key="RegionTemplate">
<TextBlock Text="{Binding Region, Mode=OneWay}" />
</DataTemplate>
<Telerik:HierarchicalDataTemplate x:Key="Region"
HeaderTemplate="{StaticResource RegionTemplate}"
ItemsSource = "{Binding Countries.Items, Mode=OneWay}"
ItemTemplate="{StaticResource CountryTemplate}" />
</UserControl.Resources>
<Client:GodotTreeView x:Name="trvSelectedCountries" IsEditable="False"
ItemsSource="{Binding Regions, Mode=OneWay}"
ItemTemplate="{StaticResource Region}" />
We would like to databind on the checkstate of each individual item without having to rely on events. Currently, the way we got around this is by not using the checkbox functionality already in the treeview and just using a CheckBox inside the datatemplate, however, we would prefer to work off the existing treeview functionality if possible.
Thanks,
-Jarred Froman
0
Hello Jarred Froman,
For this purpose you can use the CheckState property of the RadTreeViewItem?
Best wishes,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
For this purpose you can use the CheckState property of the RadTreeViewItem?
Best wishes,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jarred Froman
Top achievements
Rank 1
answered on 17 Sep 2008, 01:36 PM
Given the code above, how would I databind to that?
Thanks,
-Jarred Froman
Thanks,
-Jarred Froman
0
Hello Jarred,
My bad - this is not curently supported in Silverlight - it is possible in WPF at the moment :(. So the only option for the moment is by using TreeViewItem events or the way you did it.
Sorry once again for misleading you - let us know if we can help you further with your scenario.
Greetings,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
My bad - this is not curently supported in Silverlight - it is possible in WPF at the moment :(. So the only option for the moment is by using TreeViewItem events or the way you did it.
Sorry once again for misleading you - let us know if we can help you further with your scenario.
Greetings,
Valentin.Stoychev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.