0
//你好!我需要將我的數據放入多列的列表框中,我看到這個鏈接stackoverflow.com...,但它沒有提及我可以將列項添加到列的方式,而只是解釋如何將數據項添加到列中,並且非常感謝。我做成功了下面的事情WPF將數據綁定到ListBox多列
<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" });
}
}
感謝編輯我試圖讓它像這樣,但我不能;) – Yasser