public class cls1
{
public string col1{ set; get; } = "";
public string col2{ set; get; } = "";
}
this.dgData.Columns.Add(new()
{
Title = "列1",
SortingEnabled = true,
PropertyName = "col1",
Width = 100
});
this.dgData.Columns.Add(new()
{
Title = "列2",
SortingEnabled = true,
PropertyName = "col2",
Width = 100
});
ObservableCollection<cls1> oc1 = new();
oc1.Add(new(){});/这里直接加数据
照你的方法我把LISTVIEW换在DATAGRID。两个结果 都一样。界面一片空白。占用了位置。
标题头正常显示。WINDOWS下一切正常。
我传不了图片上来。
this.dgData.ItemsSource = oc1;