i cant bind an image to source from converter?
<!-- Works fine -->
<Image Grid.Row="0" Grid.Column="4" Grid.RowSpan="6" Margin="5">
<Image.Source>
C:\pictures\Becker.png
</Image.Source>
</Image>
<!-- Works not -->
<Image Source="{Binding ClientPicture, Converter={StaticResource clientpictureconv}, ConverterParameter={Binding ClientNumber}}"/>
In the converter i give back the hardcoded picture Uri (from the top). If i replace the Image with Textblock, the full uri is shown. But the picture in Image not.
What can i do?
That’s because Image.Source does not take a
URIobject; it takes anImageSourceobject. Your converter should create one of those and pass it back. Put this in your converter, and it’ll work:Note that
BitmapImageis a type ofImageSource.Your first example works because XAML implicitly converts the URI string to an ImageSource for you. It can’t do that when you explicitly pass back a URI object using your converter.