DataGrid.RowStyle是否覆盖DataGridColumn.CellStyle? [英] Does DataGrid.RowStyle override DataGridColumn.CellStyle?

查看:212
本文介绍了DataGrid.RowStyle是否覆盖DataGridColumn.CellStyle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 DataGrid 我自动生成列。

我想指定一个 ToolTip 在一系列列上,(跳过第一个,最后4个)。

我想我应该可以用来做到这一点DataGridColumn.CellStyle

但是,我想在有错误的行上覆盖它,所以 ToolTip 解释了行错误。

我已经有了Row错误样式:

I have a DataGrid that I'm AutoGenerating the columns.
I want to specify a ToolTip on a range of the columns, (skipping the first one, and last 4).
I'm thinking I should be able to do this with the DataGridColumn.CellStyle.
However, I want to override this on rows with errors so the ToolTip explains the row error.
I already have the Row error styling:

<DataGrid.RowStyle>
  <Style TargetType="DataGridRow">
    <Style.Triggers>
      <DataTrigger Binding="{Binding Path=Row.HasErrors}"
                   Value="True">
        <Setter Property="ToolTip"
                Value="{Binding Path=Row.RowError}" />
        <Setter Property="Foreground"
                Value="White" />
        <Setter Property="Background"
                Value="Red" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
</DataGrid.RowStyle>



我可以添加 DataGridColumn.CellStyle 但仍然有 DataGrid.RowStyle 优先?

有没有更好的方法来实现这个目标?





看来 DataGridColumn.CellStyle 取代 DataGrid .RowStyle :(

[/ Edit]


Can I add the DataGridColumn.CellStyle but still have the DataGrid.RowStyle take precedence?
Is there a better way to accomplish this?


It appears the DataGridColumn.CellStyle supercedes the DataGrid.RowStyle :(
[/Edit]

推荐答案

它覆盖了样式,因为Cell总是更多特定于行或列。它是在framewor中设计的。 ican认为最快的解决方案是将一些数据触发器放入单元格样式中,以检测行上的任何更改,如样式或特定属性
It overwrite the style because a Cell its always more specific than a Row or Column. It is designed that way in the framewor. The quickest solution ican think is to put some lind of datatrigger in the cell style that detects any of the changes on the row like the style or an especific property


这篇关于DataGrid.RowStyle是否覆盖DataGridColumn.CellStyle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆