Hi,
The proper solution would be to reuse the cells when using a custom column. Here is an example:
public class MyCustomColumn : GridViewDataColumn
{
public MyCustomColumn()
{
Background = Brushes.Red;
}
public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
{
HighlightTextBlock highlightTextBlock = cell.Content as HighlightTextBlock;
if (ShouldCreateNewTextBlock(highlightTextBlock))
{
highlightTextBlock = new HighlightTextBlock
{
DataType = DataType,
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Center,
};
highlightTextBlock.SetBinding(HighlightTextBlock.TextProperty, DataMemberBinding);
}
Validation.SetErrorTemplate(highlightTextBlock, new ControlTemplate());
return highlightTextBlock;
}
private bool ShouldCreateNewTextBlock(HighlightTextBlock highlightTextBlock)
{
return highlightTextBlock == null || highlightTextBlock is not HighlightTextBlock;
}
public override bool CanEdit(object item) => true;
}Regards,
Dimitar
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.