We’re using a couple of other Telerik controls that
incorporate selection, but few if any swap to using a hand cursor for selection.
We’d like to enabled selection in the Tree Map but override the default cursor so
that it uses the standard Arrow cursor. Is this possible without modifying the
underlying source for the control?
2 Answers, 1 is accepted
0
Hello Chris,
The cursor of the RadTreeMapItem is set internally in code. Still, you can try to change it by modifying the default template of the RadTreeMapItem. You can check the Editing Control Templates help article which describes how you can get the default template of the control. Basically, in the extracted template you can navigate to a Border element with x:Name="Border" and set its Cursor property. I have tested this and I manage to change the cursor on my side. Here is the template.
Give this approach a try and let me know how it goes on your side.
Regards,
Dinko
Progress Telerik
The cursor of the RadTreeMapItem is set internally in code. Still, you can try to change it by modifying the default template of the RadTreeMapItem. You can check the Editing Control Templates help article which describes how you can get the default template of the control. Basically, in the extracted template you can navigate to a Border element with x:Name="Border" and set its Cursor property. I have tested this and I manage to change the cursor on my side. Here is the template.
<
Style
x:Key
=
"RadTreeMapItemStyle"
TargetType
=
"telerik:RadTreeMapItem"
>
<
Setter
Property
=
"ItemsPanel"
>
<
Setter.Value
>
<
ItemsPanelTemplate
>
<
telerik:TreeMapPanel
/>
</
ItemsPanelTemplate
>
</
Setter.Value
>
</
Setter
>
<
Setter
Property
=
"Value"
Value
=
"{Binding Path=Value}"
/>
<
Setter
Property
=
"Foreground"
Value
=
"Black"
/>
<
Setter
Property
=
"BorderBrush"
Value
=
"Black"
/>
<
Setter
Property
=
"Background"
Value
=
"Transparent"
/>
<
Setter
Property
=
"BorderThickness"
Value
=
"1"
/>
<
Setter
Property
=
"Margin"
Value
=
"1"
/>
<
Setter
Property
=
"HorizontalContentAlignment"
Value
=
"Center"
/>
<
Setter
Property
=
"VerticalContentAlignment"
Value
=
"Center"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:RadTreeMapItem"
>
<
Grid
>
<
VisualStateManager.VisualStateGroups
>
<
VisualStateGroup
x:Name
=
"CommonStates"
>
<
VisualState
x:Name
=
"Normal"
/>
<
VisualState
x:Name
=
"MouseOver"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"MouseOverVisual"
Storyboard.TargetProperty
=
"BorderBrush"
Duration
=
"0.00:00:00.05"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0.00:00:00.0"
>
<
DiscreteObjectKeyFrame.Value
>
<
LinearGradientBrush
StartPoint
=
"0,0"
EndPoint
=
"3,3"
MappingMode
=
"Absolute"
SpreadMethod
=
"Repeat"
>
<
GradientStop
Color
=
"#B2000000"
Offset
=
"0"
/>
<
GradientStop
Color
=
"#B2000000"
Offset
=
"0.5"
/>
<
GradientStop
Color
=
"#D8FFFFFF"
Offset
=
"0.5"
/>
<
GradientStop
Color
=
"#D8FFFFFF"
Offset
=
"1"
/>
</
LinearGradientBrush
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
<
VisualState
x:Name
=
"Pressed"
>
<
Storyboard
>
<
ObjectAnimationUsingKeyFrames
Storyboard.TargetName
=
"SelectedVisual"
Storyboard.TargetProperty
=
"Background"
Duration
=
"0.00:00:00.05"
>
<
DiscreteObjectKeyFrame
KeyTime
=
"0.00:00:00.0"
>
<
DiscreteObjectKeyFrame.Value
>
<
LinearGradientBrush
StartPoint
=
"0,0"
EndPoint
=
"3,3"
MappingMode
=
"Absolute"
SpreadMethod
=
"Repeat"
>
<
GradientStop
Color
=
"#66000000"
Offset
=
"0"
/>
<
GradientStop
Color
=
"#66000000"
Offset
=
"0.15"
/>
<
GradientStop
Color
=
"#26FFFFFF"
Offset
=
"0.15"
/>
<
GradientStop
Color
=
"#26FFFFFF"
Offset
=
"1"
/>
</
LinearGradientBrush
>
</
DiscreteObjectKeyFrame.Value
>
</
DiscreteObjectKeyFrame
>
</
ObjectAnimationUsingKeyFrames
>
</
Storyboard
>
</
VisualState
>
</
VisualStateGroup
>
</
VisualStateManager.VisualStateGroups
>
<
Border
Cursor
=
"Arrow"
Name
=
"border"
Background
=
"{TemplateBinding Background}"
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
SnapsToDevicePixels
=
"True"
>
<
Border
x:Name
=
"SelectedVisual"
>
<
Grid
Margin
=
"{TemplateBinding Padding}"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
ContentPresenter
Grid.Row
=
"0"
Content
=
"{TemplateBinding Header}"
ContentTemplate
=
"{TemplateBinding HeaderTemplate}"
ContentTemplateSelector
=
"{TemplateBinding HeaderTemplateSelector}"
HorizontalAlignment
=
"{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment
=
"{TemplateBinding VerticalContentAlignment}"
/>
<
ItemsPresenter
Grid.Row
=
"1"
/>
</
Grid
>
</
Border
>
</
Border
>
<
Border
x:Name
=
"MouseOverVisual"
BorderThickness
=
"1"
SnapsToDevicePixels
=
"True"
/>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
<
Style
TargetType
=
"telerik:RadTreeMapItem"
BasedOn
=
"{StaticResource RadTreeMapItemStyle}"
/>
Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Chris
Top achievements
Rank 1
answered on 09 May 2018, 05:38 PM
Thanks, Dinko,
Your style changes did exactly what we needed. Much appreciated.