I have a RadTreeView bound in an MVVM style application. If a selection does not contain Details I need to disable the ability to click on that node and keep the currently selected node highlighted. The user should still able to expand and collapse.
I have tried to bind to PreviewSelected but the SelectedItem property still gets hit even if I switch e.handled = true and I lose the node highlighting on the currently selected node.
<
UserControl.Resources
>
<
ResourceDictionary
>
<
Style
x:Key
=
"PHToCItemContainerStyle"
TargetType
=
"{x:Type telerik:RadTreeViewItem}"
BasedOn
=
"{StaticResource RadTreeViewDefaultItemPlusMinusStyle}"
>
<
Setter
Property
=
"IsExpanded"
Value
=
"{Binding IsExpanded, Mode=TwoWay}"
/>
<
Setter
Property
=
"IsSelected"
Value
=
"{Binding IsSelected, Mode=TwoWay}"
/>
</
Style
>
<
DataTemplate
x:Key
=
"Measure"
>
<
TextBlock
Text
=
"{Binding Name }"
Style
=
"{StaticResource RadTreeViewItemSelectedTextBlockDefaultStyle}"
VerticalAlignment
=
"Center"
/>
</
DataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"Condition"
ItemTemplate
=
"{StaticResource Measure}"
ItemsSource
=
"{Binding Measures}"
>
<
TextBlock
Text
=
"{Binding Name}"
Style
=
"{StaticResource RadTreeViewItemSelectedTextBlockDefaultStyle}"
/>
</
HierarchicalDataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"ConditionGroup"
ItemTemplate
=
"{StaticResource Condition}"
ItemsSource
=
"{Binding Conditions}"
>
<
TextBlock
Text
=
"{Binding Name }"
FontWeight
=
"Bold"
Style
=
"{StaticResource RadTreeViewItemSelectedTextBlockDefaultStyle}"
/>
</
HierarchicalDataTemplate
>
</
ResourceDictionary
>
</
UserControl.Resources
>
...
<
telerik:RadTreeView
x:Name
=
"RadTree"
telerik:TextSearch.TextPath
=
"Name"
VirtualizingStackPanel.IsVirtualizing
=
"True"
VirtualizingStackPanel.VirtualizationMode
=
"Recycling"
ItemsSource
=
"{Binding ResultObject}"
Style
=
"{StaticResource RadTreeViewDefaultPlusMinusStyle}"
ExpanderStyle
=
"{StaticResource RadTreeViewDefaultPlusMinusExpanderStyle}"
ItemTemplate
=
"{StaticResource ConditionGroup}"
ItemContainerStyle
=
"{StaticResource PHToCItemContainerStyle}"
SelectedItem
=
"{Binding ResultObject.SelectedIndexItem}"
/>
dll version = 2014.1.331.45