Suppose I have string Name and Image Photo as properties of a class in my DataContext. I need to bind them to controls is a DataTemplate.
I thought this would work but it doesn't:
<Image Source="{Binding Photo}"/>
Why not? Should I my Photo have another type? (BitmapImage perhaps?)
How can I bind an Image control to an Image property?
Thanks!
Edit: As usual, after clicking submit I saw that the error is very clear: there's no converter from Image to ImageSource. How would my converter be to convert Image to ImageSource?
It doesn't really makes sense to have a data property of type Image, since Image is a control (if you really want to do that you could bind to Photo.Source). You should use an ImageSource instead (or a BitmapImage, like you did, since BitmapImage inherits from ImageSource).
Yes, if I make my property BitmapImage it all works just fine. Sorry for the stupid question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With