Home > Software engineering >  Reload a transient page in .NET MAUI from within the page
Reload a transient page in .NET MAUI from within the page

Time:08-08

I have a .NET MAUI app with a page registered as transient in MauiProgram.cs. I want to be able to reset the page using a button on the page itself but do not know how. Please could someone help me.

I've already tried using this code, but it did not do anything:

[RelayCommand]
public async Task ReloadPageAsync()
{
    await Shell.Current.GoToAsync("../" nameof(MyPage), false);
}

CodePudding user response:

Try this:


// Get current page
var page = Navigation.NavigationStack.LastOrDefault();

// Load new page
await Shell.Current.GoToAsync(nameof(SecondPage), false);

// Remove old page
Navigation.RemovePage(page);

  • Related