WPF databind in memory image to Image control

Posted by Ready Cent on Stack Overflow See other posts from Stack Overflow or by Ready Cent
Published on 2011-01-04T18:52:09Z Indexed on 2011/01/04 18:53 UTC
Read the original article Hit count: 146

Filed under:
|

I am using a DataGrid and trying to do the following Databinding

<DataTemplate>
                                    <Grid>
                                        <Image>
                                            <Image.Source>
                                                <BitmapImage  UriSource="{Binding Data.CustomImage}" CacheOption="OnLoad" />
                                            </Image.Source>
                                        </Image>                                            
                                    </Grid>
                                </DataTemplate>

CustomImage is of type BitmapImage. When I run I get the error:

Initialization of 'System.Windows.Media.Imaging.BitmapImage' threw an exception.

The thing is that these images are stored as resources in a different assembly so I can't just point to a location on disk

© Stack Overflow or respective owner

Related posts about wpf

Related posts about databinding