你们太有帮助了,我在绑定到列表视图时遇到了一些麻烦,想知道是否有人可以帮助我,这是我的代码。
这是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 不包含 person 的定义,也许我遗漏了什么?
ListView.Items.Add(new ListViewItem {Person = t.InnerHtml});