0

I have a ListView whose ItemsSource is bound to a collection. One of the columns of the ListView is an image. This image source must be set to a resource file, and the resource is determined by a property of the item.

How Can the converter return the Image source as resource file?

<ListView ItemsSource="{Binding Persons}">
    <ListView.View>
        <GridView>
            <GridView.Columns>
                <GridViewTemplateColumn Header="" Width="20" IsReadOnly ="True">
                    <GridViewTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Path=Male}" />
                        </DataTemplate>
                    </GridViewTemplateColumn.CellTemplate>
                </GridViewTemplateColumn>
                <GridViewColumn Header="{Binding Resources.Name,
                                Source={StaticResource resourceHelper}}"
                                Width="SizeToCells"
                                DisplayMemberBinding="{Binding Path=Fullname}"/>
                <GridViewColumn Header="{Binding Resources.Address,
                                Source={StaticResource resourceHelper}}"
                                Width="SizeToCells"
                                DisplayMemberBinding="{Binding Path=Address}" />

            </GridView.Columns>
        </GridView>
    </ListView.View>
</ListView>

So in above case, if it is Male then show icon1 else show icon2.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
xaria
  • 842
  • 5
  • 24
  • 47
  • Not related to your question: You are having a gridview inside a list view. I don't think that this is good practice. Why you not only use GridView? – fhnaseer Apr 02 '13 at 05:56
  • Thanks, But That is not what my question is about. – xaria Apr 02 '13 at 06:37
  • Try out this solution, http://stackoverflow.com/questions/7402386/how-do-you-access-to-your-image-resources-in-mvvm-wpf-applications – fhnaseer Apr 02 '13 at 07:14

0 Answers0