Skip to content

Commit

Permalink
Merge pull request #90 from thomaslevesque/support-for-non-bitmapsource
Browse files Browse the repository at this point in the history
Fix behavior for non-BitmapSource AnimatedSource
  • Loading branch information
thomaslevesque authored Oct 6, 2021
2 parents 510aba1 + a60b37f commit 3deb37c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion WpfAnimatedGif/ImageBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,14 @@ private static void InitAnimationOrImage(Image imageControl)
SetAnimationController(imageControl, null);
SetIsAnimationLoaded(imageControl, false);

BitmapSource source = GetAnimatedSource(imageControl) as BitmapSource;
var rawSource = GetAnimatedSource(imageControl);
BitmapSource source = rawSource as BitmapSource;
if (source == null && rawSource != null)
{
imageControl.Source = rawSource;
return;
}

bool isInDesignMode = DesignerProperties.GetIsInDesignMode(imageControl);
bool animateInDesignMode = GetAnimateInDesignMode(imageControl);
bool shouldAnimate = !isInDesignMode || animateInDesignMode;
Expand Down

0 comments on commit 3deb37c

Please sign in to comment.