【问题标题】:Styling of data in data grid in wpfwpf中数据网格中数据的样式
【发布时间】:2009-10-03 07:20:18
【问题描述】:

我将数据填充到我的数据网格中。现在,在最后一列中,我有诸如“失衡”和“失衡”之类的数据。我希望显示器将所有“不平衡”数据显示为带下划线并以红色显示,而“平衡”数据显示为绿色而没有任何下划线。请注意,存储的过程最初会给我所有“输出”平衡”记录,然后是“不平衡”记录。请帮助。我对 WPF 世界完全陌生,必须在星期一之前给出解决方案。提前致谢

【问题讨论】:

    标签: wpf datagrid styling


    【解决方案1】:

    您可以使用 TemplateColumn:

    <Controls:DataGrid.Columns>
      <Controls:DataGridTemplateColumn>
        <Controls:DataGridTemplateColumn.CellTemplate>
          <DataTemplate>
            <TextBlock Text="{Binding Data1}" Foreground="Red" TextDecorations="Underline"/>
          </DataTemplate>
        </Controls:DataGridTemplateColumn.CellTemplate>
      </Controls:DataGridTemplateColumn>
    </Controls:DataGrid.Columns>
    

    【讨论】:

      猜你喜欢
      • 2010-10-07
      • 1970-01-01
      • 2014-05-06
      • 2012-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多