Reputation: 91
In WPF, you can get global mouse events by registering in App.xaml.cs as below.
EventManager.RegisterClassHandler(typeof(Window), Window.PreviewMouseDownEvent, new MouseButtonEventHandler(OnPreviewMouseDown));
EventManager.RegisterClassHandler(typeof(Window), Window.PreviewMouseUpEvent, new MouseButtonEventHandler(OnPreviewMouseUp));
EventManager.RegisterClassHandler(typeof(Window), Window.PreviewKeyDownEvent, new KeyEventHandler(OnKeyDownEvent));
In UWP, I wonder how I can get a PointerMoved event from App.xaml.cs in my application.
Upvotes: 1
Views: 589
Reputation: 6091
You can access the main window content with the singleton class provided:
Window.Current.Content.PointerPressed += OnPointerPressed;
Window.Current.Content.Pointer... // etc...
Upvotes: 3