BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
This type of styling sometimes do not work properly..
<Style TargetType="syncfusion:GridCell" x:Key="nullCellStyle">
<Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self},
Converter = {StaticResource changebackground}}" />
</Style>
Full code in attachment (issue occurs when scrolling)
not always in same place..
Hi Krzysztof,
We reviewed the attached sample and noticed that you are using a converter to change the background color of the grid cells. In SfDataGrid, UI elements are only created for visible items and are reused for other items when scrolling. For example, if you have 1000 records but only 20 rows are visible at a time, SfDataGrid will create elements for those 20 rows and reuse them for the remaining rows, updating only the data. This is why the style mismatching issue occurs when scrolling. To resolve this issue, you can use the CellStyleSelector concept in SfDataGrid which is to used update the cell styles at runtime.
App.Xaml
<Application.Resources> <Style TargetType="syncfusion:GridCell" x:Key="nullCellStyle" > <Setter Property="Background" Value="LightYellow"/> </Style> </Application.Resources> |
MainWindow.Xaml
<syncfusion:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding Orders}" CellStyleSelector="{StaticResource styleSelector}" AllowFiltering="True" ShowGroupDropArea="True" AutoGenerateColumns="True" > |
public class CellStyleSelector : StyleSelector { public override Style SelectStyle(object item, DependencyObject container) { var record = item as OrderInfo; var gridCell = container as GridCell; if (gridCell.ColumnBase.GridColumn.MappingName == "OrderID") { if (record.OrderID % 2 == 0) return App.Current.Resources["nullCellStyle"] as Style; }
return base.SelectStyle(item, container); } } |