简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM