【问题标题】:WPF: how can I style DataGridTextColumn in one style class?WPF:如何在一个样式类中设置 DataGridTextColumn 的样式?
【发布时间】:2011-03-27 06:48:10
【问题描述】:

我尝试对 DataGridTextColumn 分别设置 Header 和 Cell 样式进行风格化:

   <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 标题、单元格和其他属性进行样式化吗?

【问题讨论】:

    标签: wpf styles datagridtextcolumn


    【解决方案1】:

    据我所知,这可能是不可能的,因为DataGridTextColumn 不提供自己的模板或样式属性,可用于集体设置其他样式。

    【讨论】:

    • 它提供了一个应该工作的 ElementStyle 属性,但它没有:-(
    • @HiredMind: ElementStyle 如果单元格不是列本身。
    猜你喜欢
    • 2013-12-10
    • 2019-07-22
    • 1970-01-01
    • 2017-11-29
    • 2013-06-22
    • 2013-11-26
    • 2014-11-11
    • 1970-01-01
    • 2014-06-13
    相关资源
    最近更新 更多