Skip to content

CollectionView for WinUI flicker problem in 8.0.6 #20043

@enkaradag

Description

@enkaradag

Description

Hi

CollectionView of WinUI started to flicker while scrolling with version 8.0.6. It was flickering at version 7 (had another problems also), fixed at 8.0.3 (again had another problems like drawing all rows at itemsource is set) waited for two months for fixes, now started to flicker again at 8.0.6

This is a simple implementation of 1 Checkbox and 5 Labels in a Grid as DataTemplate. Yes it is a recycling work but is that really that hard to smoothly draw them? Or is CV designed to add 1 or 2 labels only? Or am i missing something at layout? (width/height constraints, some layoutoptions or whatever)

Tried listview also, it is almost the same.

There is no problem for Android, IOS and MacCatalyst

(below gif is captured in release mode. windows 11, 32g of ram, i7 12th gen cpu)

collectionview_winui_806

Steps to Reproduce

No response

Link to public reproduction project repository

https://github.com/enkaradag/collectionview_flicker_test

       public class ROW
       {
           public string FIELD1 { get; set; }
           public string FIELD2 { get; set; }
           public string FIELD3 { get; set; }
           public string FIELD4 { get; set; }
           public string FIELD5 { get; set; }

       }

       public ObservableCollection<ROW> ROWS = new ObservableCollection<ROW>();

       private void btn_fill_Clicked(object sender, EventArgs e)
       {

           for (int i = 0; i < 1000; i++)
               ROWS.Add(new ROW()
               {
                   FIELD1 = Guid.NewGuid().ToString(),
                   FIELD2 = Guid.NewGuid().ToString(),
                   FIELD3 = Guid.NewGuid().ToString(),
                   FIELD4 = Guid.NewGuid().ToString(),
                   FIELD5 = Guid.NewGuid().ToString(),
               });


           view.ItemTemplate = new DataTemplate(() =>
           {
               Grid g = new Grid();
               g.RowDefinitions.Add(new RowDefinition(new GridLength(50)));
               g.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(50)));   //for checkbox
               g.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(50)));
               g.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(100)));
               g.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(200)));
               g.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(300)));
               g.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(100)));

               g.Add(new CheckBox(), 0, 0);
               Label labelFIELD1 = new Label();
               Label labelFIELD2 = new Label();
               Label labelFIELD3 = new Label();
               Label labelFIELD4 = new Label();
               Label labelFIELD5 = new Label();
               labelFIELD1.SetBinding(Label.TextProperty, "FIELD1");
               labelFIELD2.SetBinding(Label.TextProperty, "FIELD2");
               labelFIELD3.SetBinding(Label.TextProperty, "FIELD3");
               labelFIELD4.SetBinding(Label.TextProperty, "FIELD4");
               labelFIELD5.SetBinding(Label.TextProperty, "FIELD5");
               g.Add(labelFIELD1, 1, 0);
               g.Add(labelFIELD2, 2, 0);
               g.Add(labelFIELD3, 3, 0);
               g.Add(labelFIELD4, 4, 0);
               g.Add(labelFIELD5, 5, 0);

               return g;

           });

           view.ItemsSource = ROWS;
       }

Version with bug

8.0.6

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions