开发者

How can I link a ListView to ModelView?

开发者 https://www.devze.com 2023-02-22 03:34 出处:网络
I want to create a ListView with the names and the codes of the products in my ModelView but when I do:

I want to create a ListView with the names and the codes of the products in my ModelView but when I do:

<ListView Items开发者_JAVA技巧Source="{Binding Path=Products}" 
SelectedValue="{Binding Path=Product}" />

Only the Product Guids are showed.

How could I create a column with the Product.Name property and another onew with the Product.Code property?


Use a GridView. Perhaps like this:

<ListView ItemsSource="{Binding Products}">
  <ListView.View>
    <GridView>
      <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/>
      <GridViewColumn Header="Code" DisplayMemberBinding="{Binding Code}"/>
    </GridView>
  </ListView.View>
</ListView>
0

精彩评论

暂无评论...
验证码 换一张
取 消