Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4100860
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:37:18+00:00 2026-05-20T20:37:18+00:00

I need to display some media in a WPF project. The media could be

  • 0

I need to display some media in a WPF project. The media could be a jpeg, a gif, a png, a bmp or a wmv movie. So I’m hoping to use a MediaElement to do the diplaying. The problem is I can’t get an animated gif to work properly.

I’ve seen a load of questions on here discussing how to display animated gifs within WPF applications, specifically:

1) Embed a windows forms Picture box within the app, which works ok, but the picture box doesn’t scale properly when hosted within a ViewBox, so I can’t use that
2) Create a custom GifImage which inherits from Image and do the animation myself. This works ok, but it means I need to worry about what type of media I am displaying, instead of just asking the element to deal with it (though I guess I could customise the object even further if I wanted to so it knew how to deal with all sorts of media). Also I think that some animated gifs only store the bit that has changed in each frame, so displaying the frame doesn’t work properly – this one for instance: http://www.modernathlete.co.za/layout/banners/PEDI_Relax_469x60.gif)
3) Use a MediaElement and set up a trigger with a storyboard to loop the gif infinitely.

The 3rd method is the one I’m trying to get working as it (ostensibly…) seems like the easiest method. However, whatever I do, I can’t seem to get the animated gif to loop – in fact, it seems to get stuck after 3 frames. The code is below:

<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication4"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <MediaElement Name="yourMediaElement">
            <MediaElement.Triggers>
                <EventTrigger RoutedEvent="MediaElement.Loaded">
                     <EventTrigger.Actions>
                         <BeginStoryboard>
                             <Storyboard>
                                 <MediaTimeline Source="http://www.modernathlete.co.za/layout/banners/PEDI_Relax_469x60.gif"
                             Storyboard.TargetName="yourMediaElement"  
                             RepeatBehavior="Forever" />
                             </Storyboard>
                         </BeginStoryboard>
                     </EventTrigger.Actions>
                 </EventTrigger>
             </MediaElement.Triggers>
         </MediaElement>
     </Grid>
 </Window>

I’ve tried the above with different animated gifs (these two: http://www.modernathlete.co.za/layout/banners/PEDI_Relax_469x60.gif and http://www.gifanimations.com/GA/image/animations/aliens/alien-01.gif), referencing them both directly from the internet, and locally (having downloaded and linked to them in a direct path to the file on the disk), but in all cases, after a few frames, the gif stops animating.

Am I doing something wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:37:19+00:00Added an answer on May 20, 2026 at 8:37 pm

    Have you tried the MediaElement replacement from the WPF MediaKit? That may work better for your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm developing a WPF application. I need to display some HTML content from
I am working on a Rails 3 application and need to display some test
I am running a Tomcat application, and I need to display some time values.
I am displaying a form with Symfony2 and Twig, and need to display some
Need some help assigning a mouseover event to display some icons that start out
At some point I need to display a disabled (greyed out by disabled=disabled attribute)
I need to display to the screen some values which are read in method
I have a RichTextBox and I add some texts programatically. I need to display
I display set of images(small). I need to show the larger image(300*300) at some
i need to display some records in listview but when i am calling services

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.