Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Wpf.Ui/Controls/Navigation/NavigationView.Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/// <summary>
/// This virtual method is called when ActualWidth or ActualHeight (or both) changed.
/// </summary>
Expand All @@ -129,7 +142,6 @@ protected virtual void OnSizeChanged(object sender, SizeChangedEventArgs e)
protected virtual void OnBackButtonClick(object sender, RoutedEventArgs e)
{
GoBack();
OnBackRequested();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public virtual bool GoBack()

var itemId = Journal[Journal.Count - 2];

OnBackRequested();
return NavigateInternal(PageIdOrTargetTagNavigationViewsDictionary[itemId], null, false, true);
}

Expand Down
13 changes: 12 additions & 1 deletion src/Wpf.Ui/Controls/Navigation/NavigationViewContentPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -78,7 +79,7 @@ protected override void OnInitialized(EventArgs e)
NotifyContentAboutNavigatingTo(eventArgs.Content);
};

Navigated += (sender, eventArgs) =>
Navigated += static (sender, eventArgs) =>
{
var self = (NavigationViewContentPresenter)sender;

Expand All @@ -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)
Expand Down