我试图在WPF中制作一个简单的关门动画,但不能让它变得流畅 - 它太生涩了。
这是一个显示问题的视频截屏视频:
https://www.dropbox.com/s/97qdnhk2w6jbi5s/wpf-animation-not-smooth.mp4?dl=0
<Window x:Class="Smth.ShellView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
AllowsTransparency="True"
ResizeMode="NoResize"
Topmost="True"
WindowStyle="None"
MinWidth="{Binding Source={x:Static SystemParameters.FullPrimaryScreenWidth}}"
MinHeight="{Binding Source={x:Static SystemParameters.FullPrimaryScreenHeight}}"
x:ClassModifier="internal" >
<Window.Background>
<SolidColorBrush Opacity="0" Color="White"/>
</Window.Background>
<Window.Triggers>
<EventTrigger
RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard BeginTime="0:0:3">
<DoubleAnimation Storyboard.TargetName="leftDoorMove" Storyboard.TargetProperty="X" To="0" Duration="0:0:6" >
</DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="rightDoorMove" Storyboard.TargetProperty="X" To="0" Duration="0:0:6" >
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Border x:Name="leftDoor" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Border.Background>
<LinearGradientBrush>
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<Border.RenderTransform>
<TranslateTransform x:Name="leftDoorMove" X="-950" />
</Border.RenderTransform>
</Border>
<Border x:Name="rightDoor" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Border.Background>
<LinearGradientBrush>
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" />
</LinearGradientBrush>
</Border.Background>
<Border.RenderTransform>
<TranslateTransform x:Name="rightDoorMove" X="950" />
</Border.RenderTransform>
</Border>
</Grid>
</Window>
答案 0 :(得分:0)
要尝试的另一件事是将缩放设置为低质量。 RenderOptions.SetBitmapScalingMode(imageObject,BitmapScalingMode.LowQuality);