You guys are so helpful and I had some trouble binding to a listview and was wondering if someone can help me, here is my code.
here is the xaml
<ListView Name="ListView" Margin="0,0,16,145" ItemsSource="{Binding EmailCollection}" AllowDrop="True" HorizontalAlignment="right" Width="704" IsEnabled="True" Background="White" Foreground="Black" BorderBrush="#FF313131">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Pic}" Width="140" Header="Picture"/>
<GridViewColumn DisplayMemberBinding="{Binding Person}" Width="140" Header="Person" />
<GridViewColumn DisplayMemberBinding="{Binding Email}" Width="200" Header="Email" />
<GridViewColumn DisplayMemberBinding="{Binding Location}" Width="160" Header="Location" />
<GridViewColumn DisplayMemberBinding="{Binding Age}" Width="50" Header="Age" />
</GridView>
</ListView.View>
</ListView>
here I am trying to add an item to the person column but it says system.windows.controls.listviewitem does not contain a definition for person maybe I am missing something?
ListView.Items.Add(new ListViewItem {Person = t.InnerHtml});
If the ListView is bound to an items collection, then you can't add to it directly. Instead, do the following:
EmailCollection
is of type ObservableCollection
EmailCollection
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.