如何在winrt中设置圆形路径上的文本动画

本文关键字:路径 文本 动画 winrt 设置 | 更新日期: 2023-09-27 18:20:43

我正在为Win8.1的Windows应用商店应用程序(使用C#)中的圆形路径上的文本设置动画。尽管互联网上有一些关于如何使用Silverlight和WPF的例子,但这些在WinRT中似乎根本不起作用(例如,缺少了很多方法)。

在搜索解决方案时,我也发现了下面的堆栈溢出问题,但它只适用于Windows 8.0,而不适用于Windows 8.1,所以我无法使其正常工作。

如何在winrt应用程序中创建文本沿路径的运动动画?

在不从头开始重新实现所有内容的情况下,有什么解决方案吗?

如何在winrt中设置圆形路径上的文本动画

查看WinRT XAML Toolkit中的CascadingTextBlock控件,了解如何将一个TextBlock分解为多个的示例。您只需要更改变换的动画设置方式。如果您的文本是一个常量字符串-最好只在Blend中创建动画-将多个单个字母TextBlocks排列在一个圆上,并使用提供的工具设计动画。

这不起作用吗?它纯粹是一个XAML解决方案。情节提要在加载时启动。

<Window x:Class="WpfApplication3.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
   <Window.Resources>
          <Storyboard x:Key="Rotate">
                 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="Label1">
                       <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                       <EasingDoubleKeyFrame KeyTime="0:0:1" Value="360"/>
                 </DoubleAnimationUsingKeyFrames>
          </Storyboard>
   </Window.Resources>
   <Window.Triggers>
          <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                 <BeginStoryboard Storyboard="{StaticResource Rotate}"/>
          </EventTrigger>
   </Window.Triggers>
<Grid>
   <Label x:Name="Label1" Content="WordsAndStuff" HorizontalAlignment="Left" Margin="218.388,112.806,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.509,1.782">
          <Label.RenderTransform>
                 <TransformGroup>
                       <ScaleTransform/>
                       <SkewTransform/>
                       <RotateTransform/>
                       <TranslateTransform/>
                 </TransformGroup>
          </Label.RenderTransform>
   </Label>
</Grid>