【发布时间】:2011-01-17 10:07:26
【问题描述】:
我有这个按钮:
<Button x:Name="PrevAdIcon" Tag="-1" Visibility="Collapsed" Width="80" Height="80" Click="PrevAd">
<Button.Background>
<ImageBrush AlignmentY="Top" Stretch="None" ImageSource="/Images/prev.png"></ImageBrush>
</Button.Background>
</Button>
当用户按下按钮时,如何将背景更改为/Images/prev-selected.png?它会给他一个反馈,因为它是一个 WP7 应用程序
到目前为止我所拥有的(不工作):
<vsm:VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<ImageBrush ImageSource="/Images/prev-selected.png" Stretch="Fill"/>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
【问题讨论】:
-
我没有在您的代码中看到任何对您希望切换到的背景的引用 (/Images/prev-selected.png)。
-
@Falanwe 我编辑了。 ImageBrush ImageSource 是 Images/prev-selected.png
标签: silverlight xaml windows-phone-7