private static bool CheckDesignMode(Image image, Uri sourceUri, Stream sourceStream) { if (!AnimationBehavior.IsInDesignMode((DependencyObject)image) || AnimationBehavior.GetAnimateInDesignMode((DependencyObject)image)) { return(true); } BitmapImage bitmapImage = new BitmapImage(); if (sourceStream != null) { ((BitmapSource)bitmapImage).SetSource(sourceStream); } else if (sourceUri != null) { bitmapImage.UriSource = sourceUri; } image.Source = ((ImageSource)bitmapImage); return(false); }