//你好!我需要将我的数据放入包含多个列的列表框中我看到了这个链接stackoverflow.com...但它谈到了每一件事而没有提到我可以将项目添加到列中的方式你能解释一下如何将数据项添加到列,非常感谢。我成功地做了以下事情
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="1" Width="100" DisplayMemberBinding="{Binding Path=Field1}" />
<GridViewColumn Header="2" Width="100" DisplayMemberBinding="{Binding Path=Field2}" />
<GridViewColumn Header="3" Width="100" DisplayMemberBinding="{Binding Path=Field3}" />
</GridView.Columns>
</GridView>
</ListView.View>`
public sealed class MyListBoxItem
{
public string Field1 { get; set; }
public string Field2 { get; set; }
public string Field3 { get; set; }
}
public sealed class MyViewModel
{
public ObservableCollection<MyListBoxItem> Items { get; private set; }
public MyViewModel()
{
Items = new ObservableCollection<MyListBoxItem>();
Items.Add(new MyListBoxItem { Field1 = "One", Field2 = "Two", Field3 = "Three" });
}
}