void RegisterEventHandlersForWindow(AppWindow window) { //Set up the activation handler InputActivationListener activationListener = InputActivationListenerPreview.CreateForApplicationWindow(window); activationListener.InputActivationChanged += ActivationListener_InputActivationChanged; // Make sure we release the reference to this window, and release XAML resources, when it's closed appWindow.Closed += delegate { appWindow = null; appWindowFrame.Content = null; }; }
private void AppWindow_Changed(AppWindow sender, AppWindowChangedEventArgs args) { // InputActivationListener.CreateForApplicationWindow throws an exception if called too early // Delay it until the window visibility has changed if (args.DidVisibilityChange && _appWindowActivationListener == null) { _appWindowActivationListener = InputActivationListenerPreview.CreateForApplicationWindow(_window); _windowActivated = _appWindowActivationListener.State != InputActivationState.Deactivated; _appWindowActivationListener.InputActivationChanged += AppWindow_InputActivationChanged; UpdateBrush(); } }