Monday, December 29, 2025

Upgrading Maui Code to .NET 10 - MainPage

 I've got a project that I keep around to do all of the .NET Maui stuff that I need to do.  It is currently in .NET 8/9 (I'm not sure which).  I'm starting to upgrade it to .NET 10.  I have a lot of warnings of code that is found to be obsolete.  I'm going to document for my personal usage, what did I need to change to get ride of all of these warnings.

The first warning I saw was "MainPage is now obsolete." or something like that.  Ok, what do I need to do.  Copilot is not hope.  I stuck the message into Google and I got an immediate answer.  I needed to remove setting the MainPage to a value.  Take that out.  Then I had to add in the following method in my App.cs file:

        protected override Window CreateWindow(IActivationState activationState)

        {

            // Set the initial page on the new Window instance

            return new Window(new TabbedNavPage()); // Or any other page

        }

Problem solved.

No comments: