【问题标题】:Long List Selector with item tap animation带有项目点击动画的长列表选择器
【发布时间】: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


【解决方案1】:

我会尝试使用 WPToolkit,其中有一个选项,您可以在按下 ListBox 或 LongListSelector 中的项目时应用“倾斜”动画。很酷。首先,您需要通过 Visual Studio https://www.nuget.org/packages/WPtoolkit/4.2013.8.16 中的 NuGet 获取工具包(该站点的链接,但您使用 Visual Studio 本身中的包管理器控制台添加它,它会自动设置所有内容)。检查此链接http://www.davidsalter.com/2013/09/using-windows-phone-toolkit-in-wp8.html,一旦你拥有它,在你声明 ListBox 或 LongListSelector 本身的标签内,插入以下内容

`<ListBox ... toolkit:TiltEffect.IsTiltEnabled="True" ../>

这应该可行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多