I have the following XAML that displays a cover image for a book using a URI:
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding CoverUrl}" />
</Rectangle.Fill>
However, the image I would like to use is not on disk anywhere or accessible via a URI; it comes from inside a binary file that I parse out into a BitmapImage object.
When I create a BitmapImage object via code, the resulting object’s BaseUri and UriSource properties are null. How can I get the ImageBrush to use a BitmapImage that resides in memory instead of reading it in from a URI?
The ImageSource property is of type ImageSource, not Uri or string… actually, a conversion happens when you assign a Uri to it. You can bind the ImageBrush directly to a property that returns an ImageSource