Hi,
When I developed my WPF PC application, I used the following code to display my gif image, as I realized that there is no easy way of doing this:-
XAML:
<StackPanel Height="25" Name="stkProgressBar">
<wfi:WindowsFormsHost Background="Transparent" HorizontalAlignment="Center">
<winForms:PictureBox x:Name="pictureBoxLoading" Visible="False">
</winForms:PictureBox>
</wfi:WindowsFormsHost>
</StackPanel>
XAML.cs:
private void Page_Loaded(object sender, RoutedEventArgs e)
{
this.pictureBoxLoading.Image = Properties.Resources.progressbar;
}
Now when I use the same approach to display the image in my WPF Browser (XBAP) application, it is not loading the page because of this xaml code? Any ideas why is that so and if there is any other way to display GIFs on a XBAP page?
Thanks, Abhi.
==================
Updated at 27/07/2010 11:AM
Now I tried the following code:-
XAML:
<Image Name="Image1"></Image>
XAML.cs:
Stream imageStreamSource = new FileStream(@"C:\Inetpub\ExchangeRate\ExchangeRate\Image\progressbar.gif", FileMode.Open, FileAccess.Read, FileShare.Read);
GifBitmapDecoder decoder = new GifBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
Int32Animation anim = new Int32Animation(0, decoder.Frames.Count - 1, new Duration(new TimeSpan(0, 0, 0, decoder.Frames.Count / 10, (int)((decoder.Frames.Count / 10.0 - decoder.Frames.Count / 10) * 1000))));
anim.RepeatBehavior = RepeatBehavior.Forever;
BitmapSource bitmapSource = decoder.Frames[0];
Image1.Source = bitmapSource;
Image1.Stretch = Stretch.None;
It shows the image alright, but is not animated. I would appreciate any help in this regard.
Abhi.