I'm trying to set image source with BitmapImage from converted path
MainWindow.xaml
<local:PathToImageConverter x:Key="PathToImageConverter"/>
<DataTemplate x:Key="GraphicItem">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Height="24" Width="24" HorizontalAlignment="Left" Source="/Handy Clipboard;component/Resources/image.png" />
<StackPanel Grid.Column="1">
<TextBlock Text="{Binding VisibleName}">
<TextBlock.ToolTip>
<Image Source="{Binding Path=ImagePath, Converter={StaticResource PathToImageConverter}}" />
</TextBlock.ToolTip>
</TextBlock>
</StackPanel>
</Grid>
</DataTemplate>
PathToImageConverter Class
public class PathToImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Console.WriteLine(value as string); // "Images\image name.png"
return new BitmapImage(new Uri(value as string, UriKind.Relative));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
DataContext of this template is GraphicListItem
public class GraphicListItem : ListItem
{
public ImageSource Content
public string ImagePath
public GraphicListItem() { }
public GraphicListItem(string visibleName, ImageSource content)
public GraphicListItem(string visibleName, ImageSource content, string imagePath)
}
I've tried to bind Content and ImagePath with converter but results are the same - empty tooltip (2x2 px rectangle)
Please help, I don't know even why this isn't working