I am trying to set a image as a background of a button through XAML. I have a value converter that converts the icon path and returns a Bitmap Image
public static BitmapImage GetImage(String name)
{
//return new BitmapImage from the location of the Path
}
I tried directly setting the Image object as a Content of the Button but that didnt work. Then I tried setting the Source Of the ImageBrush Tag in the Button.BackGround but that still doesnt work.
<Button Margin="3" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="0">
<Button.Background>
<ImageBrush ImageSource="{Binding Path=IconPath, Converter={StaticResource ImageSourceConverter}}" />
</Button.Background>
</Button>
Its not specifically the problem with the Converter since the Same logic works to display the images in my treeview nodes. What am I doing wrong here?
If I unterstood you right, initially you would like to bind the content of the button to an icon:
Edit:
Added debug for DataBinding.