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,580 questions
{count} votes

1 answer

Sort by: Most helpful
  1. youzeliang 735 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


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.