看起來像一個簡單的問題,但不知何故,我找不到正確的答案。我有wpf中的datagrid,我想在其中更改c#中列的寬度。代碼是如何更改wpf中datagrid中列的寬度
DataTable table = new DataTable();
DataColumn col1 = new DataColumn("From", typeof(string));
table.Columns.Add(col1);
table.Columns.Add(new DataColumn("To", typeof(string)));
table.Columns.Add(new DataColumn("Occurrence", typeof(int)));
dataGrid1.ItemsSource = table.DefaultView;
但是DataColumn沒有寬度選項。在這種情況下如何改變列的寬度?謝謝。