question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET MAUI Problem with rendering ListView/CollectionView on Android

See original GitHub issue

This issue has been moved from a ticket on Developer Community.


[severity:It’s more difficult to complete my work]
I have a program on the MAUI platform with the MVVM pattern. I’m doing it now for Android and there is a problem with rendering ListView/CollectionView:
The problem is the long rendering of ListView or CollectionView on Android phones. Here you have an empty application screen with an empty ListView. You click the “Add 20 items” button. And the User interface “freezes for 2 seconds” on the android 10 version is about 3 seconds, on android 13 it is already 1.5 seconds. Provided that you have only 8 Labels, but as soon as you add another picture or more Labels, etc., the loading time will increase even more.

Example:

C#

using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;

namespace MauiApp1;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        BindingContext = new MainPageModel();
    }
}

public class MainPageModel : INotifyPropertyChanged
{

    public event PropertyChangedEventHandler? PropertyChanged;

    public ICommand ButtonCommand => new Command(UpdateList);

    private void UpdateList()
    {
        List list = new();
        for (int i = 0; i < 20; i++)
        {
            list.Add(new MainPageModel()
            {
                Example = "Text",
                Test = "Test"

            });
        }
        MyItems = new ObservableCollection(list);

    }

    public ObservableCollection MyItems
    {
        get => _MyItems;
        set
        {
            _MyItems = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MyItems)));
        }
    }
    private ObservableCollection _MyItems = new ObservableCollection();

    public string Example
    {
        get => _example;
        set
        {
            _example = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Example)));
        }
    }
    private string _example;

    public string Test
    {
        get => _test;
        set
        {
            _test = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Test)));
        }
    }
    private string _test;
}

  

XAML

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.MainPage"
             xmlns:local="clr-namespace:MauiApp1"
             x:DataType="local:MainPageModel">
    <ScrollView Padding="6">
        <VerticalStackLayout>
            <Button Text="Add 20 items" Command="{Binding ButtonCommand}" />
            <ListView ItemsSource="{Binding MyItems}" HasUnevenRows="True">
                <ListView.ItemTemplate>
                    <DataTemplate x:DataType="local:MainPageModel">
                        <ViewCell>
                            <Grid>
                                <VerticalStackLayout>
                                    <VerticalStackLayout Margin="0,12,0,0">
                                        <Label Text="{Binding Example}"  />
                                        <Label Text="{Binding Example}"  />
                                        <Label Text="{Binding Example}"  />
                                        <Label Text="{Binding Example}"  />
                                    </VerticalStackLayout>
                                    <VerticalStackLayout Margin="0,12,0,0">
                                        <Label Text="{Binding Test}"  />
                                        <Label Text="{Binding Test}"  />
                                        <Label Text="{Binding Test}"  />
                                        <Label Text="{Binding Test}"  />
                                    </VerticalStackLayout>
                                </VerticalStackLayout>
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </VerticalStackLayout>
    </ScrollView>
</ContentPage>

PS: Don’t track the rendering using Stopwatch. Since the “user interface” itself freezes, it is easily visible if you add a Gif image next to the button and notice the “GIF freezing” when you click on the button.


Original Comments

Feedback Bot on 12/4/2022, 04:35 PM:

(private comment, text removed)


Original Solutions

(no solutions)

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
PureWeencommented, Mar 2, 2023
0reactions
msftbot[bot]commented, Mar 2, 2023

We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Read more comments on GitHub >

github_iconTop Results From Across the Web

(SOLVED) MAUI Slow/Laggy Scrolling in ListView and ...
I have some issues with my ListView, its very Laggy and scrolling from 1 item to the next take 1-2 seconds sometimes.
Read more >
MAUI - CollectionView and scrolling - not working with IOS ...
Hi I have an issue with my App and CollectionView and scrolling, when testing with IOS emulators. ... It works fine with Android...
Read more >
MAUI: ListView not updating in iOS (works on Android)
I have a ListView, which is populated by an add function like so: (Fig 1: empty list) (Fig 2: one item added) Data...
Read more >
r/xamarindevelopers
Xamarin.Forms/MAUI CollectionView performance issue: it's your own damn fault. · The collection is rendered with Syncfusion's SfListView on iOS, ...
Read more >
Jean-Marie Alfonsi
Forms/MAUI CollectionView performance issue: it's your own damn fault. So I have seen a lot of people complaining about the performance of the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found