Hello,
Is there any way I can do the above?
You can use Shell.Current.GoToAsync to do it . As you said, you have two button click event.
The first button click will open NavigatedPage2 with Modal mode, the second button click will open NavigatedPage2 with Normal mode. when execute the GoToAsync, we can transfer a navigationParameter.
private async void Button_Clicked_1(object sender, EventArgs e)
{
var navigationParameter = new ShellNavigationQueryParameters
{
{ "IsModal", true }
};
await Shell.Current.GoToAsync("NavigatedPage2", navigationParameter);
}
private async void Button_Clicked(object sender, EventArgs e)
{
var navigationParameter = new ShellNavigationQueryParameters
{
{ "IsModal", false }
};
await Shell.Current.GoToAsync("NavigatedPage2", navigationParameter);
}
In the navigatedPage2, if the value of IsModal is ture, we can set Shell.SetPresentationMode(this, PresentationMode.Modal);
. This NavigatedPage2 will be opened by Modal mode.
[QueryProperty(nameof(IsModal), "IsModal")]
public partial class NavigatedPage2 : ContentPage
{
bool isModal;
public bool IsModal
{
get => isModal;
set
{
isModal = value;
if (isModal)
{
Shell.SetPresentationMode(this, PresentationMode.Modal);
}
OnPropertyChanged();
}
}
By the way, please keep one thread for one issue.
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.