3

I have a file format gif I put it in mediaelement, animation worked, but how to make that file was played continuously

emirate
  • 149
  • 6
  • 15

1 Answers1

1

You can use a MediaTimeline element to make the animation loop forever:

<MediaElement Name="yourMediaElement">
    <MediaElement.Triggers>
        <EventTrigger RoutedEvent="MediaElement.Loaded">
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard>
                        <MediaTimeline Source="YourAnimation.gif"
                            Storyboard.TargetName="yourMediaElement"  
                            RepeatBehavior="Forever" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger>
    </MediaElement.Triggers>
</MediaElement>

EDIT: The solution above does not seem to be working with GIF files whose size exceeds a few kilobytes. The issue apparently come from Windows Media Player (it can be reproduced with WMP itself). So, YMMV.

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479