我有简单的动画移动图像内的页面和反映它从边界像DVD标志动画。但是这个动画消耗了我视频卡大约20%的电量(我有1660 TI和i7第10代)。如果我在较弱的硬件上启动它,它有很多滞后。如何优化它?我的XAML:
<Page.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetName="ImagePassCard" >
<DoubleAnimation Storyboard.TargetProperty="(Canvas.Left)"
AutoReverse="True"
From="0" To="{Binding ElementName=CanvasMain, Path=ActualWidth, Converter={StaticResource SubtractValueConverter}, ConverterParameter=400}"
Duration="0:0:10"
RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard TargetName="ImagePassCard">
<DoubleAnimation Storyboard.TargetProperty="(Canvas.Top)"
AutoReverse="True"
From="0" To="{Binding ElementName=CanvasMain, Path=ActualHeight, Converter={StaticResource SubtractValueConverter}, ConverterParameter=250}"
Duration="0:0:15"
RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Page.Triggers>
<Canvas x:Name="CanvasMain">
<Image x:Name="ImagePassCard"
Source="{Binding Source={x:Static res:Resources.PassCard}, Converter={StaticResource BitmapToImageConverter}}"
Height="250"
Width="400"/>
</Canvas>
我试着移动一个矢量XAML图像和这个位图-它是相同的结果。
1条答案
按热度按时间yquaqz181#
我不确定这是否解决了性能问题,但您可以尝试修改
TranslateTransform
X
和Y
值,而不是Canvas.Left
附加值。就像这样: