ImageControlConverter Class
A value converter that converts an Avalonia.Media.IImage to an Avalonia.Controls.Image control instance, commonly used in Avalonia.Controls.MenuItem.Avalonia.Controls.MenuItem.Icon property bindings.
public class ImageControlConverter : IValueConverter
- Inheritance:
- object object
- Implements:
- IValueConverter
Constructors
ImageControlConverter()
Initializes an instance of the class.
public ImageControlConverter()
Properties
Height
The target height of the image.
public double Height { get; set; }
Property Value
- double:
The default value is
NaN, which won't set a target height on the Avalonia.Controls.Image control that is created.
Width
The target width of the image.
public double Width { get; set; }
Property Value
- double:
The default value is
NaN, which won't set a target width on the Avalonia.Controls.Image control that is created.
Methods
Convert(object?, Type, object?, CultureInfo)
Converts a value.
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
| Parameter | Type | Description |
|---|---|---|
| value | object | The value to convert. |
| targetType | Type | The type of the target. |
| parameter | object | A user-defined parameter. |
| culture | CultureInfo | The culture to use. |
Returns
- object:
The converted value.
Remarks
This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.
ConvertBack(object?, Type, object?, CultureInfo)
Converts a value.
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
| Parameter | Type | Description |
|---|---|---|
| value | object | The value to convert. |
| targetType | Type | The type of the target. |
| parameter | object | A user-defined parameter. |
| culture | CultureInfo | The culture to use. |
Returns
- object:
The converted value.
Remarks
This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.
CreateImage(IImage)
Creates an Avalonia.Controls.Image control to display the specified Avalonia.Media.IImage source.
protected virtual Image CreateImage(IImage imageSource)
| Parameter | Type | Description |
|---|---|---|
| imageSource | IImage | The Avalonia.Media.IImage to examine. |
Returns
- Image:
The Avalonia.Controls.Image that was created.
Remarks
The default implementation of this method creates a DynamicImage instance.
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()