ImageConverter Class
Represents a value converter that returns a new Image instance created using a specified URI or BitmapSource.
[ValueConversion(typeof(string), typeof(Image))]
[ValueConversion(typeof(Uri), typeof(Image))]
[ValueConversion(typeof(BitmapSource), typeof(Image))]
public class ImageConverter : DependencyObject
- Inheritance:
- object object
Remarks
This converter expects the source value to be a System.Uri, a URI string, or a BitmapSource that can be used to create a new Image instance. A prefix can be defined in UriPrefix which will be prepended to all source values of type string before the Image is created.
Constructors
ImageConverter()
Initializes an instance of the class.
public ImageConverter()
Properties
Height
The target height of the image.
public double Height { get; set; }
Property Value
ImageProvider
The optional ImageProvider to use with image sources created by the converter.
public ImageProvider? ImageProvider { get; set; }
Property Value
- ImageProvider:
The default value is
null, meaning use the static default ImageProvider.
UriPrefix
The URI prefix that should be prepended to all values converted by this object.
Width
The target width of the image.
public double Width { get; set; }
Property Value
Methods
Convert(object?, Type, object?, CultureInfo)
Converts the specified URI, in the form of a string or System.Uri, or the specified BitmapSource to an Image.
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
| Parameter | Type | Description |
|---|---|---|
| value | object | The value produced by the binding source. |
| targetType | Type | The type of the binding target property. |
| parameter | object | The converter parameter to use. |
| culture | CultureInfo | The culture to use in the converter. |
Returns
Remarks
See ImageConverter for more information on the expected source values.
ConvertBack(object?, Type, object?, CultureInfo)
This method always returns null and should not be used.
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
| Parameter | Type | Description |
|---|---|---|
| value | object | Not used. |
| targetType | Type | Not used. |
| parameter | object | Not used. |
| culture | CultureInfo | Not used. |
Returns
- object:
null.
CreateImage(ImageSource)
Creates an Image control to display the specified ImageSource.
protected virtual Image CreateImage(ImageSource imageSource)
| Parameter | Type | Description |
|---|---|---|
| imageSource | ImageSource | The ImageSource to examine. |
Returns
Remarks
The default implementation of this method creates a DynamicImage instance.
Fields
HeightProperty
Defines the Height property.
public static readonly DependencyProperty HeightProperty
ImageProviderProperty
Defines the ImageProvider property.
public static readonly DependencyProperty ImageProviderProperty
UriPrefixProperty
Defines the UriPrefix property.
public static readonly DependencyProperty UriPrefixProperty
WidthProperty
Defines the Width property.
public static readonly DependencyProperty WidthProperty