2013-10-20 112 views
2

我正在使用拇指控件來充當大小控件。當我移動拇指時,我將光標設置爲SizeWE。但是,當我按下鼠標啓動拖動操作。光標返回到一個指針。WPF拇指集拖動光標

我試着在拖動過程中明確地設置遊標,但那不起作用。思考?

<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> 
+0

可能有用的:http://stackoverflow.com/questions/3129443/wpf-4-拖動和下降與 - 視覺元素如光標 – Chris

回答

1

從IsDragging處理機取下的TargetName:

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

代替:

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