I have a page where I want to display images in a control Template. For this I only get the Image name to show. So I am using a converter to return BitmapImage like this:
return new BitmapImage(new Uri(value.ToString(), UriKind.RelativeOrAbsolute));
in the XAML binding i have:
Image Source="{Binding ThumbNail,Converter={StaticResource MapImagePath}}"/>
For some reason i am not able to see the image at all.
I have changed my image extension to .jpeg but still not working.
Am i doing some thing wrong or suggest me if I am wrong. Thanks.
Modify your converter so that it returns an instance of BitmapImage
. Your converter is currently returning a string or a Uri however the actual type for the Source
property is ImageSource
.
The conversion of a string to a BitmapImage
is some magic that the XamlParser does for us but when we supply the value using a Converter we need to give it the correct type.