http://2.bp.blogspot.com/-bQZRfy4g4t0/TWK05e_Bx9I/AAAAAAAAAEY/nym2bRu-RjI/s1600/5.bmp
如何在按下时将包含图像的按钮更改为白色背景?
默认情况下,当我按下我的按钮时,它不显示按钮中的图像并更改为手机强调色。
这是按钮的XAML代码:
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Source" Storyboard.TargetName="Img">
<DiscreteObjectKeyFrame KeyTime="0" Value="Assets/appbar.control.play.png" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
<DiscreteObjectKeyFrame KeyTime="0" Value="Black"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="White"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
答案 0 :(得分:0)
答案 1 :(得分:0)
您需要将Pressed视觉状态更改为:
(在这种情况下,按下按钮时背景会变为红色)
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Source" Storyboard.TargetName="Img">
//Set you image path like this
<DiscreteObjectKeyFrame KeyTime="0" Value="Assets/..." />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="Red"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="Red"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>