I’m trying to bind a list of custom objects to a WPF Image like this:
<Image> <Image.Source> <BitmapImage UriSource='{Binding Path=ImagePath}' /> </Image.Source> </Image>
But it doesn’t work. This is the error I’m getting:
‘Property ‘UriSource’ or property ‘StreamSource’ must be set.’
What am I missing?
WPF has built-in converters for certain types. If you bind the Image’s
Sourceproperty to astringorUrivalue, under the hood WPF will use an ImageSourceConverter to convert the value to anImageSource.So
would work if the ImageSource property was a string representation of a valid URI to an image.
You can of course roll your own Binding converter:
and use it like this: