按照我能找到的唯一文档,我尝试了以下 XAML:
<Image Name="testImage" Source="https://upload.wikimedia.org/wikipedia/commons/c/c4/PM5544_with_non-PAL_signals.png" Width="800">
<animations:Implicit.Animations>
<animations:ScalarAnimation Target="Translation.Y" ImplicitTarget="Offset" Duration="0:0:4"/>
<animations:ScalerAnimation Target="Opacity" Duration="0:0:4" />
</animations:Implicit.Animations>
</Image>
以下代码有效,不透明度动画并需要 4 秒才能淡出:
private void myButton_Tapped(object sender, TappedRoutedEventArgs e)
{
testImage.Opacity = 0.2;
}
但我不知道如何触发平移动画(或旋转或缩放)。我试过这个:
private void myButton_Tapped(object sender, TappedRoutedEventArgs e)
{
var translate = new TranslateTransform();
translate.Y = 400;
testImage.RenderTransform = translate;
}
这也希望隐式会覆盖持续时间但没有运气:
private void myButton_Tapped(object sender, TappedRoutedEventArgs e)
{
testImage.Offset(0, 400, 0).Start();
}
更改应用于这些,但没有 4 秒动画。