Har*_*hat 2 windows-rt windows-phone-8.1
我正在使用Windows Phone 8.1 RT框架开发应用程序.有一些网格控件我想添加倾斜效果.我该怎么做?
在Windows运行时中,有一些很好的动画可以用于此目的 - 在MSDN上引用.您可以通过几种方式实现目标:
最简单的方法是将Grid放在Button控件中,默认情况下Tilt效果.您还可以轻松使用按钮的自定义样式 - 参考此答案.
您可以设计自己的Control并使用VisualStateManager.GoToState在状态之间切换.在MSDN这里是一个很好的简短示例,如何做到这一点.
您可以使用主题动画定义Storyboard,并Begin()在指针按下/释放时定义.一个简短的例子:
在XAML中:
<Grid Name="animatedGrid" PointerPressed="animatedGrid_PointerPressed" PointerReleased="animatedGrid_PointerReleased">
<Grid.Resources>
<Storyboard x:Name="animateUp">
<PointerUpThemeAnimation TargetName="animatedGrid" />
</Storyboard>
<Storyboard x:Name="animateDown">
<PointerDownThemeAnimation TargetName="animatedGrid" />
</Storyboard>
</Grid.Resources>
<Rectangle Fill="Tomato" Width="200" Height="200"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
代码背后:
private void animatedGrid_PointerPressed(object sender, PointerRoutedEventArgs e)
{
animatedGrid.Projection = new PlaneProjection();
animateDown.Begin();
}
private void animatedGrid_PointerReleased(object sender, PointerRoutedEventArgs e)
{
animateUp.Begin();
}
Run Code Online (Sandbox Code Playgroud)上面的例子涵盖了这个问题中指出的一个奇怪的行为,并找到了Jerry Nixon - MSFT的解决方法.
| 归档时间: |
|
| 查看次数: |
2549 次 |
| 最近记录: |