protected override void OnDrawText(DrawingContext drawingContext, RowInfo rowInfo, CellInfo cellInfo, string cellValue)
{
double thickness = 0;
var contentrect = AddBorderMargins(cellInfo.CellRect, new Thickness(5, Math.Ceiling(thickness / 2), 5, Math.Ceiling(thickness / 2)));
FormattedText formattedText = GetFormattedText(rowInfo, cellInfo, cellValue);
var textalignment = TextAlignment.Left;
var textwrap = TextWrapping.NoWrap;
if (rowInfo.RowType == RowType.HeaderRow || rowInfo.RowType == RowType.StackedHeaderRow)
{
textalignment = TextAlignment.Center;
textwrap = TextWrapping.Wrap;
}
else if(cellInfo.ColumnName != "" && (rowInfo.Record is Group))
{
//-->here sets the Font weight as Bold for the Summary Row
formattedText.SetFontWeight(FontWeights.Bold);
}
else if (cellInfo.ColumnName != "" && !(rowInfo.Record is Group))
{
textalignment = GetColumnTextAlignment(cellInfo.ColumnName);
textwrap = GetColumnTextWrapping(cellInfo.ColumnName);
//-->Here we have applied the Foreground color for the record row
var index = dataGrid.View.Records.IndexOfRecord(rowInfo.Record);
if (index % 2 == 0)
formattedText.SetForegroundBrush(Brushes.Bisque);
}
if (contentrect.Width > 0 && contentrect.Height > 0)
{
formattedText.MaxTextWidth = contentrect.Width;
formattedText.MaxTextHeight = contentrect.Height;
formattedText.TextAlignment = textalignment;
if (textwrap != TextWrapping.NoWrap)
formattedText.Trimming = TextTrimming.None;
else
{
formattedText.Trimming = TextTrimming.CharacterEllipsis;
formattedText.MaxLineCount = 1;
}
drawingContext.DrawText(formattedText, contentrect.TopLeft);
}
} |