Windows 10动画中的通用应用程序TranslateTransform

时间:2016-07-16 17:30:51

标签: c# universal

我希望动画一个包裹面板并将其移动到左侧... 我的平台是windows 10 visual studio 2015通用应用程序

<Page
x:Class="App5.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App5"
xmlns:UniversalWrapPanel="using:Gregstoll"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="80*"/>
        <RowDefinition Height="10*"/>
    </Grid.RowDefinitions>

        <UniversalWrapPanel:UniversalWrapPanel Name="mainGrid">

        </UniversalWrapPanel:UniversalWrapPanel>

</Grid>

这是我的代码:

double toValue = 800;
        DoubleAnimation animationSub = new DoubleAnimation()
        {
            Duration = TimeSpan.FromSeconds(8),
            To = toValue,
            BeginTime = TimeSpan.FromSeconds(3)
        };

        Storyboard storyBoardErrors = new Storyboard()
        {
            Duration = TimeSpan.FromSeconds(3 + 9),
            RepeatBehavior = RepeatBehavior.Forever,

        };
        Storyboard.SetTarget(animationSub, mainGrid);
        Storyboard.SetTargetProperty(animationSub, "(UIElement.RenderTransform).(TranslateTransform.X)");

        storyBoardErrors.Children.Add(animationSub);
        storyBoardErrors.Begin();

但抛出异常:

  

{&#34;未检测到已安装的组件。\ r \ n \ r \ n无法解析指定对象上的TargetProperty(UIElement.RenderTransform)。(TranslateTransform.X)。&#34;}

     

未检测到已安装的组件。

     

无法解析TargetProperty   (UIElement.RenderTransform)。(TranslateTransform.X)指定   对象

我不会使用帆布,因为导致包裹板正常工作

1 个答案:

答案 0 :(得分:0)

在你的Wrappanel中,你必须先设置一个初始变换,这样你就可以用这样的代码为它设置动画:

<UniversalWrapPanel:UniversalWrapPanel Name="mainGrid">
 <UniversalWrapPanel.RenderTransform>
            <TranslateTransform></TranslateTransform>
        </UniversalWrapPanel.RenderTransform>
</UniversalWrapPanel:UniversalWrapPanel>