tags:

views:

104

answers:

1

Hi,

I have ListBox in my WPF project that gets set to a datasource of "MyObjectCollection". I have managed to get the ListBox to display my collection, and each item to display two string properties from the object. The object also contains an Image, how do i get the image to display in the ListBox?

I am currently using the below code to bind to my DataSource

<UserControl.Resources>
        <DataTemplate x:Key="CustomerTemplate">
            <Border BorderThickness="2" BorderBrush="silver" CornerRadius="5" Padding="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid>
                    <Image Source="{Binding Artwork}" Tag="{Binding Artwork}" VerticalAlignment="Stretch" ></Image>
                        <TextBlock Text="{Binding Name}"  Foreground="#515151"
                       FontSize="16" HorizontalAlignment="Stretch"
                       FontWeight="Bold" />
                    <TextBlock Text="{Binding Length}" Foreground="#515151" Margin="0,25,0,0"
                       FontSize="10" HorizontalAlignment="Stretch"
                       FontWeight="Bold" />
                </Grid>
            </Border>
        </DataTemplate>
</UserControl.Resources>

Thanks, Ben

+1  A: 

May be this article will help you

http://stackoverflow.com/questions/20586/wpf-image-urisource-and-data-binding

Kishore Kumar