试图了解一些关于 s 的知识,但我被困在一个特定的主题上。我希望使用我拥有的预制样式编辑按钮的大小和对齐方式。一个例子:
<Button Style="{StaticResource ButtonFormat}">
</Button>
该按钮具有保存在 App.Xaml 中的样式,样式如下所示:
<Application.Resources>
<Style TargetType="Button" x:Key="ButtonFormat">
<Setter Property="Background" Value="#FF6E1400" />
<Setter Property="Margin" Value="5,5,5,5" />
</Style>
<Application.Resources>
现在,这是我的困境:
我想加载另一种覆盖“ButtomFormat”的样式。我一直在尝试在 VisualStatemanager 中进行试验,以尝试提出正确的方法,但实际上找不到任何足以解释我如何做到这一点的东西。
所以在如下的视觉状态下:
<VisualState x:Name="BigView" >
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="550" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!--stuff goes here-->
<!--stuff goes here-->
</VisualState.Setters>
</VisualState>
我想用 ButtonFormatBlue 覆盖 ButtonFormat,如下所示:
<Style TargetType="Button" x:Key="ButtonFormatBlue ">
<Setter Property="Background" Value="Blue" />
<Setter Property="Margin" Value="5,5,5,5" />
</Style>
我看到有人建议使用 C# 而不是 visualstatemanagers,但我没有正确理解该描述,是否可以根据需要从 visualstatetrigger 加载它,还是我看错了方向?
感谢所有帮助,在此先感谢您!