动画 GIF 在 WPF 中不进行动画处理

本文关键字:动画 处理 GIF WPF | 更新日期: 2023-09-27 18:30:30

如何制作动画.gif以对 WPF 用户控件中的每一帧进行动画处理?此处的.gif仅显示第一帧。

<UserControl.Triggers>
    <EventTrigger RoutedEvent="Button.Click" SourceName="btnPressQ">
        <EventTrigger.Actions>
            <BeginStoryboard Storyboard="{StaticResource sbdShowAlfa}"/>
        </EventTrigger.Actions>
    </EventTrigger>    
</UserControl.Triggers>
<Button Grid.Column="2" Command="{Binding Path=PressAndRelease}" CommandParameter="Q" Style="{StaticResource TransparentButton}">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Image Name="imgNormalQ" Source="/Wosk;component/Images/Alphaberts/Q1.png" Height="127" />
                            <Image Name="imgPressedQ" Source="/Wosk;component/Images/Alphaberts/DancingPeaks.gif" Height="262" Width="119" Margin="-23,-136,-21,0" Visibility="Hidden"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Panel.ZIndex" Value="999"/>
                                <Setter TargetName="imgPressedQ" Property="Visibility" Value="Visible"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>
            </Button>

动画 GIF 在 WPF 中不进行动画处理

为什么不让动画 gif 驻留在帧外?每一帧上的动画.gif将不利于动画,因为每一帧都必须在每一帧上重新开始。