In This Article

ImageDataTemplateSelector Class

An Avalonia.Controls.Templates.IDataTemplate implementation that selects an appropriate Avalonia.Controls.Templates.ITypedDataTemplate for images from its ActiproSoftware.UI.Avalonia.Controls.Templates dictionary based on data type, walking up the Type inheritance tree as needed.

public class ImageDataTemplateSelector : TypedDataTemplateSelector, IDataTemplate, ITemplate<object?, Control?>
Inheritance:
object TypedDataTemplateSelector object
Implements:
IDataTemplate ITemplate<object, Control>

Remarks

This class is specifically designed to be used for presenting an image and includes the ability to use string data to lookup an image through GetImageSource(string).

Constructors

ImageDataTemplateSelector()

Initializes an instance of the class.

public ImageDataTemplateSelector()

Properties

Provider

The explicit ImageProvider to be used when loading images from string data.

public ImageProvider? Provider { get; set; }

Property Value

ImageProvider

Remarks

When an explicit value is not specified, Default will be used.

Methods

TryGetTemplateForObject(object?, out IDataTemplate?, out object?)

Tries to resolve an Avalonia.Controls.Templates.IDataTemplate for use with the given data.

protected override bool TryGetTemplateForObject(object? data, out IDataTemplate? template, out object? buildParameter)
Parameter Type Description
data object

The data to example.

template IDataTemplate

When successful, outputs the Avalonia.Controls.Templates.IDataTemplate to be used.

buildParameter object

When successful, outputs the object to be passed when building the template. This object can also replace the default data context of the templated content.

Returns

bool:

true if the template was resolved and output through the template parameter; otherwise false.

Fields

DefaultIImageDataTemplateKey

The key for a resource which defines the default Avalonia.Controls.Templates.IDataTemplate for values of type Avalonia.Media.IImage.

public const string DefaultIImageDataTemplateKey = "ImageDataTemplateSelectorDefaultIImageDataTemplateKey"

DefaultStreamGeometryDataTemplateKey

The key for a resource which defines the default Avalonia.Controls.Templates.IDataTemplate for values of type Avalonia.Media.StreamGeometry.

public const string DefaultStreamGeometryDataTemplateKey = "ImageDataTemplateSelectorDefaultStreamGeometryDataTemplateKey"

Inherited Members

Extension Methods