0

I have a WPF splash screen and I want to put an animated gif so I have used a winforms picturebox as explained here (WPF MediaElement is not working for me).

Below the code using winforms picturebox:

<Window x:Class="GifExample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
    xmlns:winForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Loaded="Window_Loaded" >
    <Grid>
        <wfi:WindowsFormsHost>
            <winForms:PictureBox x:Name="pictureBoxLoading">
            </winForms:PictureBox>
        </wfi:WindowsFormsHost>
    </Grid>
</Window >

Now from WPF Window loaded event I am trying to set the image for winforms picturebox like in the link provided above:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    pictureBoxLoading.ImageLocation = "../Resources/mygif.gif";
}

My animated gif, "mygif.gif", is in the "Resources" folder of my splash screen project.

When I launch it, no image is shown in the picturebox instead it is show a white square with a red cross inside it.

Willy
  • 9,848
  • 22
  • 141
  • 284
  • 1
    Take a look at this: https://github.com/thomaslevesque/WpfAnimatedGif/ – Clemens Dec 14 '17 at 16:38
  • @Clemens many thanks! it works perfectly! great! – Willy Dec 14 '17 at 21:29
  • @Clemens Hi Clemens again! as i said you, I have done a little WPF test project in .NET 3.5 and it is working ok. So once I know this library works, I have done the same in my real WPF project (net 3.5) and it fails, it raise an exception when importing namespace: xmlns:gif="http://wpfanimatedgif.codeplex.com" see my new post on: https://stackoverflow.com/questions/47830239/wpf-displaying-an-animated-gif-inside-a-wpf-image-using-wpfanimatedgif-codeplex – Willy Dec 15 '17 at 10:26

0 Answers0