I can’t perform gradual scrolling in my .NET Maui App

I am new to .NET Maui and I am creating my first application that first checks the dll file for interface implementation, then the user enters a number and the program should output all prime numbers up to it. The problem came up in the visualization, I have the application itself hangs when a large number is processed, so I decided to make it asynchronous. This didn’t help, because the visualization itself hangs when it tries to list these numbers. Then I decided to add gradual scrolling, but it doesn’t work. In the debug this event just doesn’t work.
This is MainPage.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"
             xmlns:local="clr-namespace:PrimeNumApp"
             x:Class="PrimeNumApp.MainPage">
    
        <VerticalStackLayout
            Padding="30,0"
            Spacing="25">
            <Label
                Text="Cписок простых чисел"
                Style="{StaticResource Headline}"
                SemanticProperties.HeadingLevel="Level1" />
            <Image 
                Source="kitten.gif"
                HeightRequest="200" 
                HorizontalOptions="Center"  
                IsAnimationPlaying="True" />
            <Entry
                x:Name="NumberEntry"
                Placeholder="Введите число" />
            <StackLayout
                Orientation="Horizontal"
                Spacing="5"
                >
                <Button
                    x:Name="LoadBtn"
                    Text="Загрузить сборку" 
                    Clicked="OnLoadClicked"
                    HorizontalOptions="FillAndExpand"
                    BackgroundColor="Gray" />
                <Button
                    x:Name="StartBtn"
                    Text="Посчитать"
                    Clicked="OnStartClicked"
                    IsEnabled="False"
                    HorizontalOptions="FillAndExpand"
                    BackgroundColor="DarkRed" />
            </StackLayout>
            <CollectionView x:Name="PrimeNumCollection"
                            
                            RemainingItemsThreshold="5"
                            RemainingItemsThresholdReached="OnCollectionViewRemainingItemsThresholdReached">
                <CollectionView.ItemsLayout>
                    <LinearItemsLayout Orientation="Vertical" />
                </CollectionView.ItemsLayout>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <TextCell Text="{Binding}"
                  TextColor="White"/>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
        </VerticalStackLayout>

</ContentPage>

This is MainPage.xaml.cs

using Contract;
using Microsoft.Maui.Controls;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Reflection;
using System.Text;

namespace PrimeNumApp
{
    public partial class MainPage : ContentPage, INotifyPropertyChanged
    {
        private bool _isImplemented;
        private Assembly _assembly;
        private string _realizationPath;
        private IPrimeGenerator _primeNumberGenerator;
        private const int PageSize = 5;
        private int _currentPage = 0;
        public ObservableCollection<int> DisplayablePrimeNums { get; set; }
        private List<int> _allPrimeNumbers = new List<int>();
        public MainPage()
        {
            InitializeComponent();
            DisplayablePrimeNums = new ObservableCollection<int>();
            PrimeNumCollection.ItemsSource = DisplayablePrimeNums;
            PrimeNumCollection.RemainingItemsThresholdReached += OnCollectionViewRemainingItemsThresholdReached;
            

        }
        public async void OnStartClicked(object sender, EventArgs e)
        {
            if (int.TryParse(NumberEntry.Text, out int number))
            {
                try
                {
                    _allPrimeNumbers = await Task.Run(() => _primeNumberGenerator!.GetPrimeNumbers(number));
                    DisplayablePrimeNums.Clear();
                    LoadNextPage();
                    
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Ошибка", ex.Message, "OK");
                }
            }
            else
            {
                await DisplayAlert("Ошибка", "Вы ввели не натуральное число", "OK");
            }
                        
        }
        private void LoadNextPage()
        {
            foreach (int number in _allPrimeNumbers.GetRange(_currentPage, PageSize))
            {
                DisplayablePrimeNums.Add(number);
            }

            _currentPage += PageSize;
        }
        public void OnCollectionViewRemainingItemsThresholdReached(object sender, EventArgs e)
        {
            LoadNextPage();
        }
        public async void OnLoadClicked(object sender, EventArgs e)
        {
            await PickDll();
        }
        private async Task PickDll()
        {
            var customFileType = new FilePickerFileType(
                    new Dictionary<DevicePlatform, IEnumerable<string>>
                    {
                    { DevicePlatform.WinUI, new[] { ".dll" } },
                    });

            try
            {
                var result = await FilePicker.PickAsync(new PickOptions()
                {
                    FileTypes = customFileType,
                    PickerTitle = "Выберите файл формата .dll"
                });

                if (result != null)
                {
                    _realizationPath = result.FullPath;
                    await LoadDll();
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Ошибка", "Ошибка при загрузке сборки: " + ex.Message, "OK");
            }
        }
        private async Task LoadDll()
        {
            _assembly = Assembly.LoadFrom(_realizationPath);
            await CheckContractRealization();
        }
        private async Task CheckContractRealization()
        {
            _isImplemented = _assembly.GetTypes().Any(type => type.GetInterfaces().Contains(typeof(IPrimeGenerator)));
            if (_isImplemented)
            {
                LoadBtn.BackgroundColor = Colors.Green;
                StartBtn.IsEnabled = true;
                StartBtn.BackgroundColor = Colors.Gray;
                var primeGeneratorType = _assembly.GetTypes()
                        .Where(type => typeof(IPrimeGenerator).IsAssignableFrom(type) && type.IsClass)
                        .Select(type => type)
                        .First();

                _primeNumberGenerator = (IPrimeGenerator)Activator.CreateInstance(primeGeneratorType)!;
            }
            else
            {
                await DisplayAlert("Ошибка", "Реализация не соответсвует контракту", "OK");
            }
        }

    }

}

I tried changing and removing the scroller itself, displaying DataTemplate inside CollectionView, it didn’t work

New contributor

Марат is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật