public static Image GetResourceDrawingImageIcon(string resourceKey, ImageIconOptions options = null) { if (options == null) { options = new ImageIconOptions(); } var image = new Image { Source = Application.Current.FindResource(resourceKey) as DrawingImage, Stretch = options.Stretch, }; if (options.Height.HasValue) { image.Height = options.Height.Value; } if (options.Width.HasValue) { image.Width = options.Width.Value; } RenderOptions.SetBitmapScalingMode(image, options.BitmapScalingMode); return(image); }
public static Image GetBitmapImageIcon(string urlString, ImageIconOptions options = null) { if (options == null) { options = new ImageIconOptions(); } var image = new Image { Source = new BitmapImage(new Uri(urlString, UriKind.Relative)), Stretch = options.Stretch, }; if (options.Height.HasValue) { image.Height = options.Height.Value; } if (options.Width.HasValue) { image.Width = options.Width.Value; } RenderOptions.SetBitmapScalingMode(image, options.BitmapScalingMode); return(image); }