我有一个简单的 RadGridView
,我想在其中更改特定行(= 3 个单元格)的文本颜色。不幸的是,这段代码不起作用:
//add new row to the grid
EventLogGrid.Items.Add(new EventLogRow(eventType, occured, msg));
//change the color of the text of all cells if it's an exception
if (eventType == EventLogger.EventType.Exception)
{
var rows = this.EventLogGrid.ChildrenOfType<GridViewRow>();
rows.Last().Foreground = new SolidColorBrush(Colors.Yellow);
}
如有任何意见,我们将不胜感激。
最佳答案
实际上有一个非常简单的解决方案:
附加一个事件处理器:
EventLogGrid.RowLoaded += EventLogGrid_RowLoaded;
改变行的颜色:
if (((EventLogRow)e.DataElement).MsgType == EventLogger.EventType.Exception) { e.Row.Foreground = new SolidColorBrush(Colors.Red); }
关于c# - RadGridView 改变文字颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14103539/