【发布时间】:2014-03-28 07:43:23
【问题描述】:
我正在处理Windows Phone 8,我有很长的列表选择器,其中包含很少的项目。当我点击项目时,我需要为其添加一些动画,将文本移入并返回。如何实现这一点?我也在尝试将其应用于列表框。
我已经试过了:
<Style x:Key="LongListSelectorStyle1" TargetType="phone:LongListSelector">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<UserControl>
<Border x:Name="MyBorder" Background="Transparent">
<VisualStateManager.VisualStateGroups >
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background)" Storyboard.TargetName="MyBorder">
<DiscreteObjectKeyFrame KeyTime="0" Value="#000000"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>
</UserControl>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
但它不起作用。
下面是示例截图
我怎样才能做到这一点?
【问题讨论】:
-
您将动画定义为电话资源,当点击某个项目时,在代码中运行动画。
标签: c# wpf silverlight windows-phone-8 windows-phone