3

I'm using a thumb control to act as a sizing control. When I move over the thumb I set the cursor to SizeWE. However, when I press the mouse to initiate the drag operation. The cursor goes back to a pointer.

I've tried setting the cursor explictly during the drag but that does not work. Thoughts?

<Style x:Key="HorizontalSizeThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="Template">
  <Setter.Value>
    <ControlTemplate TargetType="{x:Type Thumb}">
      <Rectangle Name="thumb" Width="1" Stroke="{StaticResource AppBackgroundBrush}" StrokeThickness="0.5" Cursor="SizeWE">
        <Rectangle.Fill>
          <SolidColorBrush Color="{StaticResource AppBackgroundColor}" />
        </Rectangle.Fill>
      </Rectangle>
      <ControlTemplate.Triggers>
        <Trigger Property="IsDragging" Value="True">
          <Setter TargetName="thumb" Property="Stroke" Value="{StaticResource PressedBrush}" />
          <Setter TargetName="thumb" Property="Cursor" Value="SizeWE" />
        </Trigger>
      </ControlTemplate.Triggers>
    </ControlTemplate>
  </Setter.Value>
</Setter>
</Style>
Mike Ward
  • 3,211
  • 1
  • 29
  • 42
  • Potentially useful: http://stackoverflow.com/questions/3129443/wpf-4-drag-and-drop-with-visual-element-as-cursor – Chris Oct 20 '13 at 20:38

1 Answers1

2

Remove the TargetName from the IsDragging handler:

<Setter Property="Cursor" Value="SizeWE" />

instead of:

<Setter TargetName="thumb" Property="Cursor" Value="SizeWE" />
Mike Ward
  • 3,211
  • 1
  • 29
  • 42