HypernovaDesktop Components · docs
Binarymission
WPF › Tree List View › PathToImageSourceConverter

PathToImageSourceConverter

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

Turns an image's address – a file path, a pack URI or a web address, as a string or a Uri – into an ImageSource, so a row object can name its icon as text.

public class PathToImageSourceConverter : IValueConverter

Inherits from / implements: IValueConverter

Remarks

An ImageSource passes through unchanged, and a value that is empty or not an address gives UnsetValue, so the binding's fallback applies.

Examples

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

<GridViewColumn Header="Name">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding IconPath, Converter={StaticResource ToImage}}" Width="16" Height="16" Margin="0,0,6,0" />
                <TextBlock Text="{Binding Name}" />
            </StackPanel>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

with xmlns:conv="clr-namespace:Binarymission.WPF.Controls.TreeControls.Converters;assembly=Binarymission.WPF.Controls.BinaryTreeListView".

Members at a glance

Methods
ConvertConverts an image address into an image.
ConvertBackNot supported: an image cannot be turned back into its address.

Methods

Convert

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

Converts an image address into an image.

Parameters
o
A path or URI as a string, a Uri, or an ImageSource.
type
Not used.
parameter
Not used.
culture
Not used.
Returns

The image, or UnsetValue when o is empty or not an address.

ConvertBack

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

Not supported: an image cannot be turned back into its address.

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

Never returns.

Exceptions
System.NotSupportedException
Always.