Posted 17 February 2021, 1:06 am EST
I'm trying to change the cursor for the Vertical Freezing Separator from the SizeWE to my own cursor.I have defined the style for the presenter and have been trying to test it with the Hand cursor.
Here is the style a created in Blend and add the Cursor Setter.
<Style x:Key="c1VerticalFreezingSeparatorStyle" TargetType="{x:Type c1:DataGridVerticalFreezingSeparatorPresenter}">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type c1:DataGridVerticalFreezingSeparatorPresenter}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="MovementStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="RectMouseOver">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Dragging">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="RectDragging">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<c1:C1BrushBuilder x:Name="BackgroundBrush" DesignBrush="#FFD1DCE8" DesignColor="#FFD1DCE8" ExtrapolationMethod="Absolute" Input="{TemplateBinding Background}"/>
<c1:C1BrushBuilder x:Name="MouseOverBrush" DesignBrush="#FFBFE1EA" DesignColor="#FFBFE1EA" ExtrapolationMethod="Absolute" Input="{TemplateBinding MouseOverBrush}"/>
<Border x:Name="Rect" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,0,1,0" Background="{Binding Output, ElementName=BackgroundBrush}"
Cursor="Hand"/>
<Border x:Name="RectDragging" BorderThickness="0,0,1,0" Background="{TemplateBinding PressedBrush}" Visibility="Collapsed"/>
<Border x:Name="RectMouseOver" BorderThickness="0,0,1,0" Background="{Binding Output, ElementName=MouseOverBrush}" Visibility="Collapsed"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I then applied the style to the VerticalFreezingSeparatorStyle on the data grid.
This does not seem work. I changed some colors and used Snoop to verify that the new style has been applied.
It looks like the cursor is being overridden in code somewhere.
What is the best way to override the cursor?
Thanks,
FR