1

How to make an animated .gif to animate every frame in WPF User Control? The .gif here shows only the 1st frame.

<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>
hakunabean
  • 99
  • 1
  • 11
  • native wpf not supported GIF you need custom class.[Get GIF to play in WPF (with GifImage Class)][1] [1]: http://stackoverflow.com/questions/5566330/get-gif-to-play-in-wpf-with-gifimage-class – aifarfa Apr 09 '12 at 03:30
  • Kindly check this link, http://stackoverflow.com/questions/10764585/how-to-add-gif-image-to-wpf –  Jun 01 '12 at 00:58

1 Answers1

0

Why not make the animated gif reside out of the frames? Animated .gif on every frame will work against animation as every frame has to start all over again on each frame.

MACMAN
  • 1,883
  • 1
  • 21
  • 35
  • u got the point here..., l think is better if l can make it only animate with certain time. but what do u mean by 'reside out of the frames'? – hakunabean Apr 09 '12 at 03:31
  • I don't know exactly how to make it happen in WPF. May be you can split the interface into two layers one with frames and one static where you can place your animated gif. – MACMAN Apr 09 '12 at 03:37