PopupPage p = new PopupPage();
Application.Current.MainPage.ShowPopup(p);
await new TaskFactory().StartNew(() => { Thread.Sleep(5000); });
p.Close();
<Button
Command="{Binding CloseClickCommand}"
CommandParameter="{Binding Source={RelativeSource Mode=FindAncestor, AncestorType={x:Type mct:Popup}}}"
Text="Close" />
public async Task CloseClickCommand(object obj)
{
if (obj is Popup popup)
{
popup.Close();
}
}
<toolkit:Popup
x:Class="VSTORE.Views.Popups.UserAdresPopupView"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:vm="clr-namespace:VSTORE.ViewModels.PopupsViewModel"
x:Name="MYPOPUP"
<Button
Command="{Binding CloseCommand}"
CommandParameter="{Binding Source={x:Reference MYPOPUP}}"
Style="{StaticResource ConfirmButton}"
Text="CLOSE" />
[RelayCommand]
public async Task Close(Popup popup)
{
popup.Close();
await DisplayToast("Closed using button");
}