【发布时间】:2012-11-17 13:50:51
【问题描述】:
我可能还有另一个无法解决的问题。在 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)。
【问题讨论】:
-
问题不是Slider上的
Minimun属性,而是Maximum属性,导致样式中设置的值没有被应用。 -
是的,我在帖子末尾写了这个,但它仍然只出现在否定的
Minimum。
标签: silverlight xaml styles slider silverlight-5.0