2010-02-22 56 views
0

我想替換以下XAML代碼:WPF數據網格列寬代碼隱藏

在代碼隱藏<Custom:DataGridTextColumn Header=" " Width="*"/>。此XAML代碼填充我的頭與我的風格到底..

這是我想要得到

|名稱|數字|此區域使用「mystyle」網格結束 - > |

這就是我現在得到的:

| name |數字|無風格的地區!網格結束 - > |

如你看到的,我想,以填補我的風格無樣式區域,使用XAML做到了這一點: 現在需要在CB PLS)

+1

您的代碼沒有顯示出來。將代碼放在代碼示例塊中,並在發佈之前檢查預覽。 – 2010-02-22 14:39:24

回答

0
tc.Width = New DataGridLength(1.0, DataGridLengthUnitType.Auto); 
+0

我已經試過這個,它不起作用。例如,如果我調整其中的表格的大小,表頭會增長,但沒有風格。 – mikemuhl 2010-02-22 14:59:58

+0

好吧,我的答案只針對列寬部分。至於風格,你想應用哪種風格?你可以設置dataGrid.Style,dataGrid.ColumnHeaderStyle,dataGridTextColumn.ElementStyle或者dataGridTextColumn.CellStyle – kenwarner 2010-02-22 16:44:05

0

好吧,我知道這是有點晚,但我只是有同樣的問題,我解決了使用DataGridLengthUnitType.Star問題(以及實際上我用的電網,但它應該是相同的)

tc.Width = New DataGridLength(2.0, DataGridLengthUnitType.Star); // this will make the colum to be twice as big as the others