我正在使用Windows Phone 8.1 RT框架开发应用程序。有一些网格控件我想添加倾斜效果。我该怎么做?

最佳答案

在Windows运行时中,可以使用一些漂亮的动画来实现此目的-参考at MSDN。有几种方法可以实现目标:


最简单的方法是将您的Grid置于Button控件内,该控件默认具有Tilt效果。您还可以轻松使用按钮的自定义样式-reference at this answer
您可以设计自己的控件,并使用VisualStateManager.GoToState在状态之间切换。 Here at MSDN是一个很好的简短示例,说明如何执行此操作。
您可以使用主题动画来定义情节提要,并在按下/释放指针时定义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>


在后面的代码中:

private void animatedGrid_PointerPressed(object sender, PointerRoutedEventArgs e)
{
    animatedGrid.Projection = new PlaneProjection();
    animateDown.Begin();
}

private void animatedGrid_PointerReleased(object sender, PointerRoutedEventArgs e)
{
    animateUp.Begin();
}



上面的示例涵盖了指出in this questionfound workaround by Jerry Nixon - MSFT的一些奇怪行为。

关于windows-phone-8.1 - 如何在Windows Phone 8.1 RT应用程序的控件中添加倾斜效果?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24278391/

10-10 13:49
查看更多