/// <summary>
 ///		Intent: Fetches the parent window, so we can call "DragMove()"on it. Caches the results in a dictionary,
 ///	    so we can apply this same property to multiple XAML elements.
 /// </summary>
 private static void UIElement_OnMouseMove(object sender, MouseEventArgs mouseEventArgs)
 {
     try
     {
         var uiElement = sender as UIElement;
         if (uiElement != null)
         {
             Window window = GetParentWindow(uiElement);
             if (mouseEventArgs.LeftButton == MouseButtonState.Pressed)
             {
                 // DragMove is a synchronous call: once it completes, the drag is finished and the left mouse
                 // button has been released.
                 window?.DragMove();
                 // See answer in section 'Additional Links' below in the SO answer.
                 //HideAndShowWindowHelper.ShiftWindowIntoForeground(window);
                 // When the use has finished the drag and released the mouse button, we shift the window back
                 // onto the screen, it it ended up partially off the screen.
                 ShiftWindowOntoScreenHelper.ShiftWindowOntoScreen(window);
             }
         }
     }
     catch (Exception ex)
     {
         _log.Warn($"Warning W52344. Exception in {nameof(UIElement_OnMouseMove)}. " +
                   $"This means that we cannot shift and drag the Toast Notification window. " +
                   $"To fix, correct C# code.", ex);
     }
 }
 private static void ControlWindowVisibility(UserControl userControl)
 {
     Application.Current.Dispatcher.Invoke(
         () =>
     {
         try
         {
             if (userControl == null)
             {
                 _log.Warn(
                     $"Warning W62344. In '{nameof(UserControl_Loaded)}', the UserControl is null.");
                 return;
             }
             var parentWindow = userControl.MyGetParentVisualTreeWindow();
             if (parentWindow == null)
             {
                 // This is normal; if we call this before the visual tree has loaded and the 'Loaded' event has fired, it will create a warning.
                 return;
             }
             bool shouldBeVisibleMirror = true;
             lock (_trackVisibilityLock)
             {
                 TrackVisibility trackVisibility;
                 if (_trackVisibility.TryGetValue(userControl, out trackVisibility) == false)
                 {
                     _log.Warn("Warning W62344. Internal program error; could not find stats for Window.");
                     return;
                 }
                 shouldBeVisibleMirror        = trackVisibility.ShouldBeVisible;
                 trackVisibility.ParentWindow = parentWindow;
             }
             if (shouldBeVisibleMirror == true)
             {
                 HideAndShowWindowHelper.ShiftWindowIntoForeground(parentWindow);
                 ShiftWindowOntoScreenHelper.ShiftWindowOntoScreen(parentWindow);
                 _log.Debug($"Showing window: {parentWindow}\n");
             }
             else
             {
                 HideAndShowWindowHelper.ShiftWindowIntoBackground(parentWindow);
                 _log.Debug($"Hiding window: {parentWindow}\n");
             }
         }
         catch (Exception ex)
         {
             _log.Warn($"Warning W19844. Exception in Attached Property '{nameof(EnsureWindowInForeground)}'.", ex);
         }
     });
 }