Legacy content from the old documentation, awaiting rewrite.
OnLoadAsync:
This method is invoked during page initialization. The developer can override it, and it has the following parameter: PageLoadEventArgs: this object has a CancellationToken property that is used to propagate a notification indicating that operations should be canceled.
OnActivatedAsync:
This method is invoked when the page is reactivated (when the tab is selected). The developer can override it, and it has the following parameter: PageActivatedEventArgs: this object has a CancellationToken property that is used to propagate a notification indicating that operations should be canceled.
OnClosingAsync:
This method is invoked when the interface requests closing the current page. The developer can override it, and it has the PageClosingEventArgs parameter. This object has two properties: Cancel: set to true if you want to cancel closing the page. ConfirmationMessage: display a confirmation dialog if this message is not empty.
private bool _confirmAsked;
protected override Task OnClosingAsync(PageClosingEventArgs e)
{
_confirmAsked = (new Random()).NextDouble() >= 0.5;
if (_confirmAsked)
{
e.ConfirmationMessage = "Are you sure?";
// OR
// e.Cancel = true;
// ShowConfirm("Message", ForceCloseAsync);
}
return Task.CompletedTask;
}
OnCloseAsync:
This method is invoked when the current page must be closed. The developer can override it, and it has the EventArgs parameter.
private bool _confirmAsked;
protected override async Task OnCloseAsync(EventArgs e)
{
await base.OnCloseAsync(e);
ShowInformation($"CLOSE ! {_confirmAsked}");
}