我有ListView
,我在同一个Slider
中插入了TextBlock
和column
:
<DataTemplate x:Key="MyDataTemplate2">
<Grid Margin="-7" >
<Slider Name="sliderColumn"
HorizontalAlignment="Left" VerticalAlignment="Center" Style="{StaticResource SliderStyle}" Width="80"/>
<TextBlock Text="{Binding Path=Value, ElementName=sliderColumn, StringFormat={}{0}}" FontSize="11" Foreground="White"
VerticalAlignment="Center" HorizontalAlignment="Right" />
</Grid>
</DataTemplate>
这就是结果:
当Slider
值发生变化时,它变得不可读:
有任何建议如何修复它并确保只显示整数?
答案 0 :(得分:1)
通过在滑块TickFrequency
和IsSnapToTickEnabled
<Slider Name="sliderColumn"
HorizontalAlignment="Left" VerticalAlignment="Center" Width="80" TickFrequency="1" IsSnapToTickEnabled="True"/>