【问题标题】:universal app in windows 10 animation TranslateTransformWindows 10 动画中的通用应用程序 TranslateTransform
【发布时间】:2016-07-17 17:04:48
【问题描述】:

我想要一个环绕面板的动画并将其移动到左侧... 我的平台是 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();

但抛出异常:

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

未检测到已安装的组件。

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

我不会使用画布,因为磨损的包裹面板可以正常工作

【问题讨论】:

  • 请给您发布 XAML。我很确定,您还没有设置初始转换

标签: c# universal


【解决方案1】:

在你的 Wrappanel 中,你必须先设置一个初始的 Transform,这样你就可以用这样的代码对其进行动画处理:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-09
    • 2015-11-04
    • 1970-01-01
    • 2015-11-30
    • 2016-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多