我正在使用 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>
但它不起作用。
下面是示例截图
我怎样才能做到这一点?
最佳答案
我会尝试使用 WPToolkit,其中有一个选项,您可以在按下 ListBox 或 LongListSelector 中的项目时应用“倾斜”动画。很酷。首先,您需要在 Visual Studio 中通过 NuGet 获取工具包 https://www.nuget.org/packages/WPtoolkit/4.2013.8.16 (指向该站点的链接,但您使用 Visual Studio 本身中的包管理器控制台添加它,它会自动设置所有内容)。检查此链接 http://www.davidsalter.com/2013/09/using-windows-phone-toolkit-in-wp8.html一旦你有了它,在你声明 ListBox 或 LongListSelector 本身的标签中,插入以下内容
`<ListBox ... toolkit:TiltEffect.IsTiltEnabled="True" ../>
这应该有效。
关于c# - 带有项目点击动画的长列表选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22706930/