Datagrid Row Background Color scrolling bug

Posted by: fatica on 19 September 2017, 10:40 am EST

  • Posted 19 September 2017, 10:40 am EST

    Please see here for a video demonstration of an example of what appears to be a rendering/painting bug on the background color of these rows.

    http://screencast.com/t/PIB12yz4ux7

    We’re using simple triggers to set the backgroundcolor property of the row based on a boolean value in the Row.Dataitem object. Can you confirm that this is a bug and if so what we need to do to workaround? Thanks!

    [xml] <c1:C1DataGrid

    BorderThickness=“1” ColumnHeaderStyle=“{StaticResource ResourceKey=HeaderStyle}” GroupRowStyle=“{StaticResource ResourceKey=DataGridGroupRowStyle}” Name=“RateHistoryDetailsDataGrid” AutoGenerateColumns=“False” IsReadOnly=“True” CanUserAddRows=“False” CanUserEditRows=“False”

    ItemsSource=“{Binding HistoryDetailsListCollection}” SelectionMode=“SingleRow” >

    c1:C1DataGrid.CellStyle



    <Style.Triggers>













    </Style.Triggers>



    </c1:C1DataGrid.CellStyle>



    [/xml]

  • Posted 19 September 2017, 10:40 am EST

    Hi,

    I could replicate the behavior. However, this seems to be working fine with the latest

    WPF build. Download the latest build and verify if this fixes the issue or not.

    http://prerelease.componentone.com/dotnet40/c1wpflibrary/2012-t2/C1WPFBasicLibrary.4_4.0.20122.257.zip

    Regards,

  • Posted 19 September 2017, 10:40 am EST

    I’m not sure I can upgrade the component. We have many other dependencies. I’ll check with management.

  • Posted 19 September 2017, 10:40 am EST

    Is there a workaround?

  • Posted 19 September 2017, 10:40 am EST

    We aren’t able to upgrade at the moment: The C1 new release breaks some of our stuff and it will require a coordinated effort from all teams when/before it can be done.

    Is there something else we can use to effect row highlighting? Is this bug with all highlighting or something specific to how we’re using it? Is there another approach?

  • Posted 19 September 2017, 10:40 am EST

    Well another option is to use LoadedCellPresenter events to apply the color settings instead

    of using Triggers. Here is the suggested code for your reference.

    [vb]

    Private Sub c1DataGrid1_LoadedCellPresenter(sender As Object, e As C1.WPF.DataGrid.DataGridCellEventArgs) Handles c1DataGrid1.LoadedCellPresenter

    If CType(e.Cell.Row.DataItem, MyDataClass).Salary = 19000 Then

    e.Cell.Presenter.Background = New SolidColorBrush(Colors.Red)

    ElseIf CType(e.Cell.Row.DataItem, MyDataClass).Salary = 23000 Then

    e.Cell.Presenter.Background = New SolidColorBrush(Colors.Yellow)

    End If

    End Sub

    Private Sub c1DataGrid1_UnloadedCellPresenter(sender As Object, e As C1.WPF.DataGrid.DataGridCellEventArgs) Handles c1DataGrid1.UnloadedCellPresenter

    e.Cell.Presenter.Background = Nothing

    End Sub

    [/vb]

    Please do implement the UnloadedCellPresenter event as well. For any property set in the

    LoadedCellPresenter, set that to nothing in UnloadedCellPresenter. Hope this helps.

    Regards,

  • Posted 5 December 2019, 1:41 am EST

    Try like this it may be work for you…

    Style s = new Style(typeof(C1.WPF.DataGrid.DataGridCellPresenter));
    s.Setters.Add(new Setter(C1.WPF.DataGrid.DataGridCellPresenter.BackgroundProperty, Brushes.Yellow));
    s.Setters.Add(new Setter(C1.WPF.DataGrid.DataGridCellPresenter.ForegroundProperty, Brushes.White));
    
    dataGridView1.Rows[rowIndexValue].CellStyle = s;
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels