也许我还有一个无法解决的问题。在Silverlight XAML中,我无法为Style属性设置Slider.Minimum负值。我是说,这是可能的,但结果是出乎意料的。在WPF中,这是正常工作的。
<StackPanel Width="200" Orientation="Vertical">
<StackPanel.Resources>
<Style TargetType="Slider" x:Key="style">
<Setter Property="Minimum" Value="-10" />
<Setter Property="Maximum" Value="10" />
<Setter Property="Value" Value="0" />
</Style>
</StackPanel.Resources>
<!-- Here it is not working -->
<Slider Style="{StaticResource style}"/>
<!-- Here it works as expected, as it is not styled -->
<Slider Minimum="-10" Maximum="10" Value="0" />
</StackPanel>其结果如下:

但是很明显,两个拇指应该在相同的位置(在Slider的中间)。
实际上,它看起来像Minimum值(-10),是接受的,但是Maximum值变成0,这就是为什么第一个滑块的拇指对着右边(Value是0,Maximum也是0)。
发布于 2012-11-29 15:13:15
问题是滑翔机的HorizontalTemplate。如果您将Slider的Orientation更改为Vertical,那么在您的样式中定义的值将按预期的方式应用。
更新:解决方案也是在样式中设置方向。那么它就会像预期的那样工作。
<Style TargetType="Slider" x:Key="style">
<Setter Property="Minimum"
Value="-10" />
<Setter Property="Maximum"
Value="10" />
<Setter Property="Value"
Value="0" />
<Setter Property="Orientation"
Value="Horizontal" />
</Style>https://stackoverflow.com/questions/13626636
复制相似问题