Crashing on re-navigating to second page.

Phunction 301 Reputation points
2024-01-31T16:01:09.54+00:00

I have a crashing issue I can't figure out. From my main page I have a button that opens a second page:

await Shell.Current.GoToAsync("newPage");

That second page is setup as a tabbed layout with 2 tabs, both tabs are content pages, one contains a grid the other contains a drawable.

On the first time, it will work fine, on the second time I get the error:

Microsoft.UI.Xaml.Controls.Frame.NavigationFailed was unhandled.

Even if I leave the Draw() method on my drawable blank so it essentials does nothing.

However, if I add a simple Thread.Sleep(500) to the constructor on the drawable, it will work fine and I can open the page over and over.

I am not sure what could be happening, for some reason on the second try (without the pause) it crashes, it seems like it is trying to clear something up but not fast enough? Is there a way to force the app to release everything on navigating back from newPage? It never c rashes on the first open, or as I stated, if I add a pause.

Developer technologies | .NET | .NET MAUI
{count} votes

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.