2011-01-25 2 views
0

내 응용 프로그램에서 모든 WPF 슬라이더 컨트롤의 스타일을 지정하고 사용자가 '엄지 손가락'을 드래그하면 팝업이 엄지 위로 엄지 손가락을 드래그하면 따라갑니다) Popup은 새 슬라이더 값의 라이브 업데이트를 표시합니다.WPF 슬라이더 컨트롤에서 팝업 위치 표시 만들기

C#없이 Xaml에서이 모든 작업을 수행하려면 어떻게해야합니까? 그 horizontalOffset가 바인드되지 않는이 그것을 완료하지의 시작되어 드래그 할 때

감사

+0

당신이이 일을하기 위해 관리나요? – baalazamon

답변

1

당신은 팝업을 표시 엄지 손가락 스타일을 지정할 수 있습니다 (sample how to do that) :

<Style x:Key="HorizontalSliderThumbStyle" TargetType="{x:Type Thumb}"> 
     <Setter Property="Focusable" Value="false"/> 
     <Setter Property="OverridesDefaultStyle" Value="true"/> 
     <Setter Property="Height" Value="22"/> 
     <Setter Property="Width" Value="11"/> 
     <Setter Property="Foreground" Value="Gray"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type Thumb}"> 
        <Canvas SnapsToDevicePixels="true"> 
         <Canvas.RenderTransform> 
          <TranslateTransform X="5.5" Y="11"/> 
         </Canvas.RenderTransform> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal"/> 
           <VisualState x:Name="MouseOver"/> 
           <VisualState x:Name="Pressed" /> 
           <VisualState x:Name="Disabled"/> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Path x:Name="Background" Data="{StaticResource SliderThumbOuterBorderGeometry}" Fill="{StaticResource HorizontalSliderThumbNormalBackground}" />      
         <Path x:Name="InnerBorder" Data="{StaticResource SliderThumbMiddleBorderGeometry}" Stroke="White" />      
         <Path x:Name="OuterBorder" Data="{StaticResource SliderThumbOuterBorderGeometry}" Stroke="#FF929292"/> 
          <Popup x:Name="tooltip" Grid.Row="0" PopupAnimation="Fade" Placement="Right" 
          PlacementRectangle="20,25,40,30" Margin="0" 
          VerticalOffset="-60" 
          HorizontalOffset="-60" > 
           <Border Background="Black" CornerRadius="5"> 
            <TextBlock Text="Sample Text" FontSize="12" Foreground="White" /> 
           </Border> 
          </Popup> 
        </Canvas> 
        <ControlTemplate.Triggers> 
         <Trigger Property="IsMouseOver" Value="true"> 
          <Setter Property="Fill" TargetName="Background" Value="{StaticResource HorizontalSliderThumbHoverBackground}"/> 
          <Setter Property="Stroke" TargetName="OuterBorder" Value="{StaticResource HorizontalSliderThumbHoverBorder}"/> 
         </Trigger> 
         <Trigger Property="Foreground" Value="Blue"> 
          <Setter Property="Fill" TargetName="Background" Value="{StaticResource HorizontalSliderThumbHoverBackground}"/> 
          <Setter Property="Stroke" TargetName="OuterBorder" Value="{StaticResource HorizontalSliderThumbHoverBorder}"/> 
         </Trigger> 
         <Trigger Property="IsDragging" Value="true"> 
          <Setter TargetName="tooltip" Property="IsOpen" Value="true" /> 
          <Setter Property="Fill" TargetName="Background" Value="{StaticResource HorizontalSliderThumbPressedBackground}"/> 
          <Setter Property="Stroke" TargetName="OuterBorder" Value="{StaticResource HorizontalSliderThumbPressedBorder}"/> 
         </Trigger> 
         <Trigger Property="IsEnabled" Value="false"> 
          <Setter Property="Fill" TargetName="Background" Value="#FFF4F4F4"/> 
          <Setter Property="Stroke" TargetName="InnerBorder" Value="{x:Null}"/> 
          <Setter Property="Data" TargetName="OuterBorder" Value="{StaticResource SliderThumbDisabledGeometry}"/> 
          <Setter Property="Stroke" TargetName="OuterBorder" Value="#FFAEB1AF"/> 
         </Trigger> 
        </ControlTemplate.Triggers> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
+0

가장 단순한 경우에는 IsDragging == true 일 때 볼 수있는 정적 테두리를 만들 수 있습니다. 당신이 이것을 원한다면 알려주세요. 나는 코드를 바꿀 것입니다. – baalazamon

+0

Magic은 꽤 멋지게 작동합니다. '트랙'에서 '엄지 손가락'을 '밀기 만하면'재미있어 보입니다. – Adam

+0

그래, 그 이유는 팝업이 특별한 것을 가져 오지 않기 때문에 나는 국경을 가진 버전을 만들 수 있다는 것이다. – baalazamon