应用指针向上/向下影响到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,你可以看Windows.UI.Xaml.Media.Animation类并espestially:PointerDownThemeAnimation和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>