Handle overlay dismiss in dialog screen view model
MODIFY
WalletWasabi.Fluent/Controls/Dialog.xaml.cs
WalletWasabi.Fluent/Controls/Dialog.xaml.cs
@@ -52,16 +52,7 @@ namespace WalletWasabi.Fluent.Controls
base.OnApplyTemplate(e);
var overlayButton = e.NameScope.Find<Panel>("PART_Overlay");
- overlayButton.PointerPressed += (_, __) =>
- {
- if (DataContext is IScreen screen)
- {
- // Reset navigation when Dialog is using IScreen for navigation instead of the default IDialogHost.
- screen.Router.NavigationStack.Clear();
- }
-
- IsDialogOpen = false;
- };
+ overlayButton.PointerPressed += (_, __) => IsDialogOpen = false;
}
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/DialogScreenViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/DialogScreenViewModel.cs
@@ -8,12 +8,28 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
{
public class DialogScreenViewModel : ViewModelBase, IScreen
{
+ private bool _isClosing;
private bool _isDialogVisible;
public DialogScreenViewModel()
{
Observable.FromEventPattern(Router.NavigationStack, nameof(Router.NavigationStack.CollectionChanged))
- .Subscribe(_ => IsDialogVisible = Router.NavigationStack.Count >= 1);
+ .Subscribe(_ =>
+ {
+ if (!_isClosing)
+ {
+ IsDialogVisible = Router.NavigationStack.Count >= 1;
+ }
+ });
+
+ this.WhenAnyValue(x => x.IsDialogVisible).Subscribe(x =>
+ {
+ if (!x)
+ {
+ // Reset navigation when Dialog is using IScreen for navigation instead of the default IDialogHost.
+ Close();
+ }
+ });
}
public RoutingState Router { get; } = new RoutingState();
@@ -27,8 +43,16 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
}
public void Close()
+ {
+ if (!_isClosing)
+ {
+ _isClosing = true;
+ if (Router.NavigationStack.Count >= 1)
{
Router.NavigationStack.Clear();
}
+ _isClosing = false;
+ }
+ }
}
}
\ No newline at end of file

Handle overlay dismiss in dialog screen view model