2013-10-03 76 views
-1

我是wpf的全新品牌。我有一個帶有多個滑塊的窗口,並且我想要顯示滑塊旁邊的滑塊的值,AutoToolTipPlacement的行爲方式除外,我希望它始終可見。slider AutoToolTip always on

我已經嘗試了幾種不同的方法來解決這個問題,但沒有一個工作得很好。

解決方案

<Track.Thumb> 
<Thumb x:Name="Thumb" Focusable="False" Height="18" OverridesDefaultStyle="True" VerticalAlignment="Center" Width="11"> 
    <Thumb.Template> 
     <ControlTemplate TargetType="{x:Type Thumb}"> 
      <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center"> 
       <Path x:Name="grip" Data="M0,0C0,0 11,0 11,0 11,0 11,18 11,18 11,18 0,18 0,18 0,18 0,0 0,0z" Fill="#FFF0F0F0" Stretch="Fill" SnapsToDevicePixels="True" Stroke="#FFACACAC" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/> 
       <TextBox HorizontalAlignment="Left" Height="18" Margin="-12,-23,-13,0" TextWrapping="Wrap" Text="{Binding Value, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Slider}}}" VerticalAlignment="Top" Width="36" TextAlignment="Center" Background="{x:Null}" BorderBrush="{x:Null}" /> 
      </Grid> 
      <ControlTemplate.Triggers> 
       <Trigger Property="IsMouseOver" Value="True"> 
        <Setter Property="Fill" TargetName="grip" Value="#FFDCECFC"/> 
        <Setter Property="Stroke" TargetName="grip" Value="#FF7EB4EA"/> 
       </Trigger> 
       <Trigger Property="IsDragging" Value="True"> 
        <Setter Property="Fill" TargetName="grip" Value="#FFDAECFC"/> 
        <Setter Property="Stroke" TargetName="grip" Value="#FF569DE5"/> 
       </Trigger> 
       <Trigger Property="IsEnabled" Value="False"> 
        <Setter Property="Fill" TargetName="grip" Value="#FFF0F0F0"/> 
        <Setter Property="Stroke" TargetName="grip" Value="#FFD9D9D9"/> 
       </Trigger> 
      </ControlTemplate.Triggers> 
     </ControlTemplate> 
    </Thumb.Template> 
</Thumb> 

回答