This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to set checked state of TreeView items based on a bool property in the databound objects as described here (for WPF): http://www.telerik.com/help/wpf/radtreeview-how-to-bind-selected-item.html
This doesn't seem to work in Silverlight. The workaround for this is to use the CheckState property instead and create a converter but I'd rather bind to a bool property, it's just cleaner like that.
I've created a simple project around this issue with just a TreeView but it won't let me attach it so here's the XAML:
I'm trying to set checked state of TreeView items based on a bool property in the databound objects as described here (for WPF): http://www.telerik.com/help/wpf/radtreeview-how-to-bind-selected-item.html
This doesn't seem to work in Silverlight. The workaround for this is to use the CheckState property instead and create a converter but I'd rather bind to a bool property, it's just cleaner like that.
I've created a simple project around this issue with just a TreeView but it won't let me attach it so here's the XAML:
<
UserControl
x:Class
=
"SilverlightApplication1.MainPage"
xmlns:telerik
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:telerikNavigation
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
UserControl.Resources
>
<
telerik:HierarchicalDataTemplate
x:Key
=
"TreeTemplate"
ItemsSource
=
"{Binding Children}"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"{Binding Name}"
Margin
=
"2"
VerticalAlignment
=
"Center"
/>
</
StackPanel
>
</
telerik:HierarchicalDataTemplate
>
<
Style
TargetType
=
"telerikNavigation:RadTreeViewItem"
x:Key
=
"TreeItemStyle"
>
<
Setter
Property
=
"IsExpanded"
Value
=
"True"
/>
<!-- THOSE DON'T WORK -->
<
Setter
Property
=
"IsChecked"
Value
=
"True"
/>
<!--<Setter Property="IsChecked" Value="{Binding Path=IsVisible}" />-->
<!-- THIS WORKS -->
<!--<Setter Property="CheckState" Value="On" />-->
<
Setter
Property
=
"HorizontalAlignment"
Value
=
"Left"
/>
</
Style
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerikNavigation:RadTreeView
x:Name
=
"LayerTree"
HorizontalAlignment
=
"Stretch"
VerticalContentAlignment
=
"Stretch"
ItemTemplate
=
"{StaticResource TreeTemplate}"
ItemContainerStyle
=
"{StaticResource TreeItemStyle}"
ItemsSource
=
"{Binding Path=Layers}"
IsExpandOnSingleClickEnabled
=
"True"
IsLineEnabled
=
"True"
ItemsOptionListType
=
"CheckList"
IsOptionElementsEnabled
=
"True"
IsRootLinesEnabled
=
"True"
IsTriStateMode
=
"True"
SelectionMode
=
"Extended"
IsEditable
=
"False"
>
<
telerikNavigation:RadTreeView.ItemEditTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding Name, Mode=TwoWay}"
/>
</
DataTemplate
>
</
telerikNavigation:RadTreeView.ItemEditTemplate
>
</
telerikNavigation:RadTreeView
>
</
Grid
>
</
UserControl
>