![](/img/trans.png)
[英]Is there a way in the WPF Toolkit datagrid to have a header below the column headers but above the first row
[英]Styling WPF Toolkit DataGrid Column Headers
我在樣式WPF Datagrid時遇到問題,我已經設置了列標題(類型為ColumnHeader)。
但是,當列中的數據不能填滿網格的整個寬度時,會添加另一列以填充網格。 該列將忽略ColumnHeader樣式,並且看起來不合適,因為該元素具有不同的類型,我在對象瀏覽器中瀏覽了庫,但找不到該元素。 我也考慮過固定大小,因此不需要此列,但這不是可行的選擇。
以下文章中演示了該問題: http : //blogs.msdn.com/jaimer/archive/2009/01/20/styling-microsoft-s-wpf-datagrid.aspx我的意思是在右上角的元素,就在綠色第3列的右側,並位於帶有行背景箭頭的單元格的上方。
將最后一列的Width
設置為*,以使該列填充剩余的可用空間。 您的樣式仍然適用,並且不會剩下該填充欄
<toolkit:DataGrid>
<toolkit:DataGrid.Resources>
<Style TargetType="{x:Type toolkit:DataGridColumnHeader}" >
<Setter Property="Foreground" Value="Red" />
</Style>
</toolkit:DataGrid.Resources>
<toolkit:DataGrid.Columns>
<toolkit:DataGridTextColumn Header="1" />
<toolkit:DataGridTextColumn Header="2" Width="*" />
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
這似乎已在最新版本的網格中得到修復
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.