I am using the following code to bind an image from my database (compact sql) to my image control:
<Image MaxHeight="100" Stretch="UniformToFill">
<Image.Source>
<BitmapImage DecodePixelHeight="200"
StreamSource="{Binding ImageData}" />
</Image.Source>
</Image>
The reason for using BitmapImage is because I found that when I used image, the thumbnails presented were so large that it slowed the program down. I intend on using the DecodePixelHeight property within bitmapimage to allow me to use a smaller thumbnail size and hence keep my program from slowing down.
The issue I get when binding this to my image is an error saying I have not set StreamSource correctly. I have a feeling this is because my image is stored as bytes in the database (converted before hand) and that BitmapImage (unlike the standard Image) does not support automatic converting into an image format.
Is this correct? If so, do I simply need to implement a converter?
The issue you face is most probably related to a fact that your
ImageDatais not type ofStream, which is actually required by theStremSourceproperty.The hypothetical code, could be something like this:
Assuming that in this case
ImageDatamodel viewer property is of typeStream.Hope this helps.