Maui Performance Issue while set Application.Current.Mainpage as My CustomPage

Muhesh Kumar 0 Reputation points
2024-08-09T07:49:18.6566667+00:00

In Maui, when we set MainPage using Application.Current.MainPage right? there while I set my custompage as MainPage its take around 15 to 30 seconds to initialize page in UI part, apart from the loading custompage

code for example:

Application.Current.MainPage = new mycustompage() // here its take around 15 to 30 seconds to render and loading in the UI..

and i tried with this too after initialize page and set as mainpage still have issue -->
CustomPage page = new CustomPage();
Application.Current.MainPage = page; // still have performance issue

It would be more helpful if this issue have any fix, Thanks in Advance

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,981 questions
{count} votes

2 answers

Sort by: Most helpful
  1. youzeliang 885 Reputation points
    2024-08-25T16:47:41.3666667+00:00

    The performance issue you're experiencing when setting Application.Current.MainPage to your custom page could be due to several factors. Here are some potential causes and solutions to improve the performance:

    1. Page Initialization Overhead
    • Cause: If your custom page has complex UI elements, heavy data bindings, or resource-intensive operations (like large images, heavy layouts, or network calls), it might take longer to render.
    • Solution: Optimize the UI by reducing unnecessary complexity. Consider lazy loading certain elements or delaying resource-heavy operations until after the page is displayed. For example, use placeholders for images or data that can load asynchronously.
    1. Resource Dictionaries and Styles
    • Cause: If your custom page uses multiple resource dictionaries, styles, or large amounts of XAML, these can slow down the page rendering.
    • Solution: Minimize the use of large resource dictionaries or styles that are not essential. Consolidate or defer the loading of certain resources where possible.

    if you think it useful, could you accpet my answer


  2. Muhesh Kumar Nagarajan 0 Reputation points
    2025-03-06T12:32:43.5533333+00:00

    Found the issue and fixed, Thank you everyone who helped me for this issue the root cause is when already initailized any observablecollection when reload page with rendered in xaml with some more collections inside the template its take some time to render for each item, thats why it was taken a lot of time after do changes to the observablecollection...if we dont have any change in list and again reinitialize it will not take so much time but after do update/add/delete it will take time to render xaml the fix for this when reinitialize for whole page with the observable collection just remove binding of the observablecollection and after that it will loads fast, but if going to use same page dont remove binding, only if reload page with same observable collection which already rendered the xaml with that collection only have this fix Thank you all

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.