這就是我得到我想要的。我使用Slider下的DockPanel來佈局TextBlocks。 一個用於中心0,一個在右側設置最大值,另一個在左側設置最小值。
我找不到任何其他解決方案做我想做的。如果有,它張貼在這裏:)
XAML:
<StackPanel Orientation="Vertical">
<Slider x:Name="SpeedSlider"
Margin="3"
Foreground="DarkGray"
Value="{Binding SliderValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Maximum="{Binding Steps,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
Minimum="{Binding MinSteps,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
SmallChange="2"
TickFrequency="4"
TickPlacement="BottomRight"
ToolTip="{Binding ElementName=SpeedSlider,Path=Value}">
</Slider>
<DockPanel>
<TextBox DockPanel.Dock="Left"
Text="{Binding MinSteps,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
Width="100"
Background="Transparent"
IsReadOnly="True"
BorderThickness="0" />
<TextBox DockPanel.Dock="Right"
Text="{Binding Steps,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
Width="100"
HorizontalContentAlignment="Right"
Background="Transparent"
IsReadOnly="True"
BorderThickness="0" />
<TextBlock DockPanel.Dock="Right"
Text="0"
HorizontalAlignment="Center" />
</DockPanel>
</StackPanel>
圖片: