2011-03-27 370 views
1

我嘗試風格化DataGridTextColumn設置頁眉和單元格樣式separatly:WPF:如何在一個樣式類中設置DataGridTextColumn的樣式?

<Style x:Key="headerStyle"> 
      <Setter Property="DataGridColumnHeader.Background" ... /> 
    ... 

    <Style x:Key="cellStyle"> 
      <Setter Property="DataGridCell.Background" ... /> 
    ... 


<DataGrid> 
    <DataGrid.Columns> 
    <DataGridTextColumn 
      HeaderStyle="{StaticResource ResourceKey='headerStyle'}" 
      CellStyle="{StaticResource ResourceKey='cellStyle'}" ... /> 

我可以程式化DataGridTextColumn頭,電池等特性於一體樣式聲明?

回答

0

至於我可以告訴大家,也許是不可能的,因爲DataGridTextColumn不提供模板或可用於集中設置其他樣式了自己的Style屬性。

+0

它提供了*應該*應用的ElementStyle屬性,但它不包含:-( – HiredMind 2011-09-14 15:42:32

+0

@HiredMind:['ElementStyle'](http://msdn.microsoft.com/zh-cn/library/system。 windows.controls.datagridboundcolumn.elementstyle.aspx)如果對於單元格而不是列本身。 – 2011-09-14 18:38:23

相關問題