Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload a transient page in .NET MAUI from within the page

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);
}
like image 330
JPA Avatar asked Sep 08 '25 00:09

JPA


1 Answers

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);

like image 140
PEK Avatar answered Sep 10 '25 00:09

PEK