Пример #1
0
        private static void HandleIsFullscreenChanged(DependencyObject d, DependencyPropertyChangedEventArgs <bool> e)
        {
            if (!(d is Window window))
            {
                return;
            }

            if (e.NewValue)
            {
                var tracker = new WindowStateTracker(window);
                SetTracker(window, tracker);

                // Normal first as maximize definitely needs to happen after windowstyle=none
                //  if it's already maximized that would break this
                window.WindowState = WindowState.Normal;
                window.WindowStyle = WindowStyle.None;
                window.WindowState = WindowState.Maximized;

                // Force topmost by changing it (false first gurantees change)
                window.Topmost = false;
                window.Topmost = true;

                //((FrameworkElement)window.Content).Margin = GetFullscreenRootOffsetMargin(window);
                tracker.WatchForStateChange();
            }
            else
            {
                var tracker = GetTracker(window);

                // Check if the tracker exists, if it
                if (tracker != null)
                {
                    tracker.Restore();
                }
            }
        }
Пример #2
0
 protected override void OnSizeChanged(EventArgs e)
 {
     base.OnSizeChanged(e);
     WindowStateTracker.SetWindowState(this);
 }
Пример #3
0
 private static void SetTracker(DependencyObject obj, WindowStateTracker value) => obj.SetValue(TrackerProperty, value);