HypernovaDesktop Components · docs
Binarymission
WPF › Smart Navigator › PathToImageSourceConverter

PathToImageSourceConverter

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Controls.ListControls

Turns an image path or URI in a binding into an ImageSource – for binding BinarySmartListBoxItem.ItemImage, or any Image, to a string property.

public class PathToImageSourceConverter : IValueConverter

Inherits from / implements: IValueConverter

Remarks

A relative path, an absolute file path or a pack URI can be given, as a string or a Uri; an ImageSource passes through unchanged. A null, empty or malformed path gives no image rather than an error in the binding.

Examples

<Window.Resources>
    <nav:PathToImageSourceConverter x:Key="ToImage" />
</Window.Resources>

<Image Source="{Binding ThumbnailPath, Converter={StaticResource ToImage}}" Width="48" />

Members at a glance

Methods
ConvertConverts a path, a Uri or an ImageSource to an image.
ConvertBackNot supported: the conversion works one way only, from path to image.

Methods

Convert

public object Convert(object o, Type type, object parameter, CultureInfo culture)

Converts a path, a Uri or an ImageSource to an image.

Parameters
o
The value from the binding: a path string, a Uri, or an ImageSource.
type
The type the binding target expects; not used.
parameter
Not used.
culture
Not used.
Returns

The ImageSource as it was, or a BitmapImage loaded from the path or URI; DependencyProperty.UnsetValue for a null, empty or malformed path, so the target shows no image.

ConvertBack

public object ConvertBack(object o, Type type, object parameter, CultureInfo culture)

Not supported: the conversion works one way only, from path to image.

Parameters
o
Not used.
type
Not used.
parameter
Not used.
culture
Not used.
Returns

Never returns.

Exceptions
NotSupportedException
Always.