windows 10 个动画中的通用应用程序 TranslateTransform
universal app in windows 10 animation TranslateTransform
我想为环绕面板设置动画并将其向左移动...
我的平台是 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();
但抛出异常:
{"No installed components were detected.\r\n\r\nCannot resolve TargetProperty (UIElement.RenderTransform).(TranslateTransform.X) on specified object."}
No installed components were detected.
Cannot resolve TargetProperty
(UIElement.RenderTransform).(TranslateTransform.X) on specified
object.
我不会使用 canvas 因为包裹面板磨损后可以正常工作
在你的 Wrappanel 中,你必须先设置一个初始的 Transform,这样你就可以在代码中为它设置动画:
<UniversalWrapPanel:UniversalWrapPanel Name="mainGrid">
<UniversalWrapPanel.RenderTransform>
<TranslateTransform></TranslateTransform>
</UniversalWrapPanel.RenderTransform>
</UniversalWrapPanel:UniversalWrapPanel>
我想为环绕面板设置动画并将其向左移动... 我的平台是 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();
但抛出异常:
{"No installed components were detected.\r\n\r\nCannot resolve TargetProperty (UIElement.RenderTransform).(TranslateTransform.X) on specified object."}
No installed components were detected.
Cannot resolve TargetProperty (UIElement.RenderTransform).(TranslateTransform.X) on specified object.
我不会使用 canvas 因为包裹面板磨损后可以正常工作
在你的 Wrappanel 中,你必须先设置一个初始的 Transform,这样你就可以在代码中为它设置动画:
<UniversalWrapPanel:UniversalWrapPanel Name="mainGrid">
<UniversalWrapPanel.RenderTransform>
<TranslateTransform></TranslateTransform>
</UniversalWrapPanel.RenderTransform>
</UniversalWrapPanel:UniversalWrapPanel>