diff --git a/src/Wpf.Ui/Controls/Navigation/NavigationView.Base.cs b/src/Wpf.Ui/Controls/Navigation/NavigationView.Base.cs index 9ac3ae058..15c3caeed 100644 --- a/src/Wpf.Ui/Controls/Navigation/NavigationView.Base.cs +++ b/src/Wpf.Ui/Controls/Navigation/NavigationView.Base.cs @@ -14,6 +14,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Windows; +using System.Windows.Input; using Wpf.Ui.Common; namespace Wpf.Ui.Controls.Navigation; @@ -115,6 +116,18 @@ protected virtual void OnUnloaded(object sender, RoutedEventArgs e) } } + protected override void OnMouseDown(MouseButtonEventArgs e) + { + //Back button + if (e.ChangedButton is MouseButton.XButton1) + { + GoBack(); + e.Handled = true; + } + + base.OnMouseDown(e); + } + /// /// This virtual method is called when ActualWidth or ActualHeight (or both) changed. /// @@ -129,7 +142,6 @@ protected virtual void OnSizeChanged(object sender, SizeChangedEventArgs e) protected virtual void OnBackButtonClick(object sender, RoutedEventArgs e) { GoBack(); - OnBackRequested(); } /// diff --git a/src/Wpf.Ui/Controls/Navigation/NavigationView.Navigation.cs b/src/Wpf.Ui/Controls/Navigation/NavigationView.Navigation.cs index 56412eecd..3ac3bf52f 100644 --- a/src/Wpf.Ui/Controls/Navigation/NavigationView.Navigation.cs +++ b/src/Wpf.Ui/Controls/Navigation/NavigationView.Navigation.cs @@ -119,6 +119,7 @@ public virtual bool GoBack() var itemId = Journal[Journal.Count - 2]; + OnBackRequested(); return NavigateInternal(PageIdOrTargetTagNavigationViewsDictionary[itemId], null, false, true); } diff --git a/src/Wpf.Ui/Controls/Navigation/NavigationViewContentPresenter.cs b/src/Wpf.Ui/Controls/Navigation/NavigationViewContentPresenter.cs index 47578afa5..d4f79eb5b 100644 --- a/src/Wpf.Ui/Controls/Navigation/NavigationViewContentPresenter.cs +++ b/src/Wpf.Ui/Controls/Navigation/NavigationViewContentPresenter.cs @@ -10,6 +10,7 @@ using System.ComponentModel; using System.Windows; using System.Windows.Controls; +using System.Windows.Input; using System.Windows.Navigation; using Wpf.Ui.Animations; @@ -78,7 +79,7 @@ protected override void OnInitialized(EventArgs e) NotifyContentAboutNavigatingTo(eventArgs.Content); }; - Navigated += (sender, eventArgs) => + Navigated += static (sender, eventArgs) => { var self = (NavigationViewContentPresenter)sender; @@ -89,6 +90,16 @@ protected override void OnInitialized(EventArgs e) }; } + protected override void OnMouseDown(MouseButtonEventArgs e) + { + if (e.ChangedButton is MouseButton.XButton1 or MouseButton.XButton2) + { + e.Handled = true; + } + + base.OnMouseDown(e); + } + private static void NotifyContentAboutNavigatingTo(object content) { if (content is INavigationAware navigationAwareNavigationContent)