你们这些人非常有帮助,我在列表视图上遇到了一些问题,并且想知道是否有人可以帮助我,这是我的代码。
这是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>
这里我试图将一个项添加到person列,但是它说system.windows.controls.listviewitem不包含人的定义,也许我错过了什么?
ListView.Items.Add(new ListViewItem {Person = t.InnerHtml});
答案 0 :(得分:1)
如果ListView绑定到项集合,则无法直接添加它。相反,请执行以下操作:
EmailCollection
的类型为ObservableCollection
EmailCollection