WPF Animated Animation is not smooth

I'm trying to create a simple closing door animation in WPF but can't get it to be smooth - it's too jerky.

See for yourself

Here's a video showing the problem:

https://www.dropbox.com/s/97qdnhk2w6jbi5s/wpf-animation-not-smooth.mp4?dl=0

dead ends

  • I tried replacing the brushes with simple solid colors, but still choppy
  • Slow down animation duration - still not smooth
  • Setting DesiredFrameRate to a lower value or a higher value does not help
  • Loosening features don't seem to help
  • Can the problem only occur on HD displays (I'm testing at 1920x1200)?

XAML to try

<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>

      

+3


source to share


1 answer


Another thing to try is setting the scaling to low quality. RenderOptions.SetBitmapScalingMode (ImageObject, BitmapScalingMode.LowQuality);



0


source







All Articles