【发布时间】:2014-09-24 08:16:03
【问题描述】:
我使用 ControlTemplate 为按钮创建不同的样式。它当然针对类型 Button。我可以为不同的 VisualStates 更改按钮的颜色,但它们都是硬类型的,或者它们是对静态资源的引用。
例子:
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="Blue" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
在页面上我放置了一个按钮:
<Button Template="{StaticResource ResourceKey=ButtonDefaultStyle}"
Background="Yellow"
Content="Hello" />
按钮是黄色的,当你按下它时,它会变成蓝色。
现在的问题是,如何更改 VisualState::Pressed 的颜色?对我来说,为每个不同颜色的按钮创建一个 ControlTemplate 很麻烦。
我正在使用 Visual Studio 2013 Express Update 3。这适用于使用通用 SDK 的 Windows 8.1 和 Windows Phone 8.1。
【问题讨论】:
标签: xaml windows-8 windows-store-apps win-universal-app