File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,8 @@ private async void OnMainPageLoaded(object sender, RoutedEventArgs e)
299299
300300 _ = ApplyDynamicThemeForCurrentTrackAsync ( ) ;
301301 UpdatePlayerVisualState ( false ) ;
302+
303+ AddHandler ( PointerPressedEvent , new PointerEventHandler ( OnGlobalPointerPressed ) , true ) ;
302304 }
303305 catch ( Exception ex )
304306 {
@@ -319,6 +321,8 @@ private void OnMainPageUnloaded(object sender, RoutedEventArgs e)
319321
320322 // Dispose the tray icon control to prevent "Exception Processing Message 0xc0000005" errors on exit.
321323 AppTrayIconHost ? . Dispose ( ) ;
324+
325+ RemoveHandler ( PointerPressedEvent , ( PointerEventHandler ) OnGlobalPointerPressed ) ;
322326 }
323327
324328 /// <summary>
@@ -545,4 +549,20 @@ private async Task RestorePaneStateAsync()
545549 }
546550 }
547551
552+ /// <summary>
553+ /// Handles global pointer pressed events to enable back navigation using the mouse side button.
554+ /// This is registered with handledEventsToo: true to catch events even if child controls swallow them.
555+ /// </summary>
556+ private void OnGlobalPointerPressed ( object sender , PointerRoutedEventArgs e )
557+ {
558+ var point = e . GetCurrentPoint ( sender as UIElement ) ;
559+ var properties = point . Properties ;
560+
561+ if ( properties . PointerUpdateKind == Microsoft . UI . Input . PointerUpdateKind . XButton1Pressed )
562+ {
563+ TryGoBack ( ) ;
564+ e . Handled = true ;
565+ }
566+ }
567+
548568}
You can’t perform that action at this time.
0 commit comments