【发布时间】:2012-10-31 14:23:39
【问题描述】:
如果行项的值超过某个值,我想更改数据网格中行的背景。
【问题讨论】:
标签: wpf c#-4.0 wpfdatagrid
如果行项的值超过某个值,我想更改数据网格中行的背景。
【问题讨论】:
标签: wpf c#-4.0 wpfdatagrid
This 是直接在 XAML 中不使用过程代码的方式,这就是样式的归属。
【讨论】:
您可以在LoadingRow 事件中执行此操作,如下所示:
private void dataGridLoadingRow(object sender, DataGridRowEventArgs e)
{
YourObject rowContext = e.Row.DataContext as YourObject;
if (rowContext != null)
{
if (rowContext.YourValue > _someValue)
e.Row.Background = new SolidColorBrush(Colors.Green);
}
}
【讨论】: