应用指针向上/向下影响到Windows Phone 8.1的应用程序 [英] Apply Pointer up/down effect to windows phone 8.1 app

查看:136
本文介绍了应用指针向上/向下影响到Windows Phone 8.1的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经迁移我的Windows Phone 8应用到Windows Phone 8.1的运行时间。显然的倾斜效应被包含。我怎么会这样添加到自定义的控制?

I've migrated my windows phone 8 app to windows phone 8.1 runtime. Apparently the tilt effect is included. How would I add this to a custom control?

谢谢,

推荐答案

因此​​,你的目标rintime,你可以看<一个href=\"http://msdn.microsoft.com/en-us/library/windows/apps/jj218361.aspx\">Windows.UI.Xaml.Media.Animation类并espestially:<一href=\"http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.animation.pointerdownthemeanimation.aspx\">PointerDownThemeAnimation和<一个href=\"http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.animation.pointerupthemeanimation.aspx\">PointerUpThemeAnimation - 有简单的例子还有

Hence you are targeting rintime, you may look at Windows.UI.Xaml.Media.Animation classes and espestially: PointerDownThemeAnimation and PointerUpThemeAnimation - there are simple examples there.

晴你必须做的就是把这些动画到VisualStates和VisualTransitions什么,简单的例子可以是这样的:

Mostly what you have to do is put those animations into VisualStates and VisualTransitions, simple example can look like this:

<Style x:Key="myControl" TargetType="Button">
    <Setter Property="Padding" Value="0,0"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Grid Background="Transparent" Name="Grid">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualStateGroup.Transitions>
                                <VisualTransition From="Pressed" To="PointerOver">
                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="Grid"/>
                                    </Storyboard>
                                </VisualTransition>
                                <VisualTransition From="PointerOver" To="Normal">
                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="Grid"/>
                                    </Storyboard>
                                </VisualTransition>
                                <VisualTransition From="Pressed" To="Normal">
                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="Grid"/>
                                    </Storyboard>
                                </VisualTransition>
                            </VisualStateGroup.Transitions>
                            <VisualState x:Name="Normal"/>
                            <VisualState x:Name="PointerOver"/>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <PointerDownThemeAnimation Storyboard.TargetName="Grid"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <ContentPresenter/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

这篇关于应用指针向上/向下影响到Windows Phone 8.1的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆