Handle hardware buttons in Dialogs. #2380
-
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
Unfortunately, this was reported as a bug #1862 long time ago and a way to fix it was available at least 6 months ago but it hasn't been fixed yet. I stopped using this feature completely because of that bug. |
Beta Was this translation helpful? Give feedback.
-
So, a solution here is just not to use XAML dialog showing Command="{prism:ShowDialog Name={x:Static const:DialogNames.AppExitConfirmationDialog}}" With regular binding to the view model command it work ok and does not disable the button. <Button Style="{StaticResource IconButtonWithForegroundColorChangeStyle}"
Text="{x:Static const:MaterialIconsRound.Shutdown}"
Command="{Binding ShutdownClickedCommand}"/> private ICommand? _shutdownClickedCommand;
public ICommand ShutdownClickedCommand =>_shutdownClickedCommand ??= new DelegateCommand(ShutdownClicked);
private void ShutdownClicked()
{
_dialogService.ShowDialog(DialogNames.AppExitConfirmationDialog);
} |
Beta Was this translation helpful? Give feedback.
-
But then, on double tap you will have two popups.... |
Beta Was this translation helpful? Give feedback.
-
Here is my workaround: private readonly object _locker = new();
private readonly HashSet<string> _openDialogs = new();
public void OnNavigatedTo(INavigationParameters parameters)
{
_openDialogs.Clear();
}
private ICommand? _shutdownButtonClickedCommand;
public ICommand ShutdownButtonClickedCommand =>
_shutdownButtonClickedCommand ??= new DelegateCommand(ShutdownButtonClicked);
private void ShutdownButtonClicked()
{
lock (_locker)
{
if (!_openDialogs.Contains(D.AppExitConfirmationDialog))
{
_openDialogs.Add(D.AppExitConfirmationDialog);
_dialogService.ShowDialog(D.AppExitConfirmationDialog);
}
}
} |
Beta Was this translation helpful? Give feedback.
-
With PR #2391 handling the Android Back Button is now supported for both regular navigation and Dialogs. |
Beta Was this translation helpful? Give feedback.
Here is my workaround: