How to feed a custom ImageSource to Image in XAML <p>One way to set an ImageSource for Image in XAML is like this:</p> <pre><code>&lt;Image Width="75" Height="75"&gt; &lt;Image.Source&gt; &lt;BitmapImage UriSource={Binding Uri} DecodePixelWidth="75" DecodePixelHeight="75" /&gt; &lt;Image.Source&gt; &lt;/Image&gt; </code></pre> <p>This code contains a nice optimization, since a potentially large bitmap will be decoded to 75x75 pixels.</p> <p>I'd like to be able to replace BitmapImage with my custom class like this:</p> <pre><code>&lt;Image Width="75" Height="75"&gt; &lt;Image.Source&gt; &lt;custom:PictureBitmap Picture={Binding Picture} Width="75" Height="75" /&gt; &lt;Image.Source&gt; &lt;/Image&gt; </code></pre> <p>My application implements the Picture class, which maps to a database table. Picture class has everything I need to create an instance of BitmapImage. So PictureBitmap is essentially an adapter for the BitmapImage.</p> <p>Here is how I started:</p> <pre><code>public class PictureBitmap : BitmapSource { // TODO: create Picture Dependency Property // TODO: create a BitmapImage from Picture // TODO: implement abstract methods by delegating calls to BitmapImage } </code></pre> <p>Although BitmapSource is abstract, the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.media.imaging.bitmapsource%28v=vs.105%29.aspx" rel="nofollow">API reference</a> doesn't explain how to implement it.</p> <p>Does anyone know how to feed a custom object to Image.Source?</p> <p>My app supports Windows Phone Mango (7.5) and up.</p> <p>Thanks!</p>