4 using System.Windows.Controls;
 
    5 using System.Windows.Data;
 
    6 using System.Windows.Markup;
 
    7 using System.Windows.Media;
 
    9 namespace SiliconStudio.Presentation.MarkupExtensions
 
   11     [MarkupExtensionReturnType(typeof(Image))]
 
   14         private readonly ImageSource source;
 
   15         private readonly 
int width;
 
   16         private readonly 
int height;
 
   17         private readonly BitmapScalingMode scalingMode;
 
   27             : this(source, width, height, BitmapScalingMode.Unspecified)
 
   31         public ImageExtension(ImageSource source, 
int width, 
int height, BitmapScalingMode scalingMode)
 
   33             if (width < 0) 
throw new ArgumentOutOfRangeException(
"width");
 
   34             if (height < 0) 
throw new ArgumentOutOfRangeException(
"height");
 
   38             this.scalingMode = scalingMode;
 
   41         public override object ProvideValue(IServiceProvider serviceProvider)
 
   43             var image = 
new Image { 
Source = source };
 
   44             RenderOptions.SetBitmapScalingMode(image, scalingMode);
 
   45             if (width >= 0 && height >= 0)
 
   48                 image.Height = height;
 
ImageExtension(ImageSource source)
 
ImageExtension(ImageSource source, int width, int height)
 
ImageExtension(ImageSource source, int width, int height, BitmapScalingMode scalingMode)
 
override object ProvideValue(IServiceProvider serviceProvider)