DataGrid how bind a column with key resource

Apr 7, 2009 at 11:02 AM
i need help about datagrid.

I have a DataGrid bounded(via code) with a myclass that has 2 columns.
in the 1st column there is a description and in the 2nd column there is a string that represent a resource key of an image.
How I can create a column that show the image reading the resource key?



<my:DataGrid Name="dbGrid" AutoGenerateColumns="False" DataContext="{ Binding }">
<my:DataGrid.Columns >
    <my:DataGridTextColumn TextBlock.TextAlignment="Center" Binding="{Binding Path=Description}" Header="Image Description" />
                            <Image Name="Pic"  Source={Binding ?Book?}> </Image>








Image x:Key="Book" Source="Images/Text.png" />






Apr 7, 2009 at 11:17 AM
I would imagine that you can bind the <Image/> Source to the class' property, using a converter that returns an image object when given a resource path as input. (FindResource is your friend.)
Apr 7, 2009 at 11:54 AM
have you an example please?
Apr 7, 2009 at 8:48 PM
Try making your resource an ImageSource rather than an Image.  Then use StaticResource rather than Binding:

ImageSource x:Key="Book">"Images/Text.png"<ImageSource/>

<Image Name="Pic"  Source={StaticResource Book}> </Image>