How to set WPF window position in secondary display

后端 未结 3 2025
栀梦
栀梦 2020-12-15 18:46

I have two displays. I want to make a media player and I want to play video full screen on my secondary display. So I’m trying to make a media player using WPF

Here

3条回答
  •  时光取名叫无心
    2020-12-15 19:30

    5 years later! But for anyone else that stumbles across this as I did ...

    If you can't or do not want to add the entire System.Windows.Forms dll reference, you can use WpfScreenHelper by micdenny (search in NuGet)

      Screen screen = WpfScreenHelper.AllScreens[0];
      Left = screen.Bounds.Left;
      Top = screen.Bounds.Top;
      Width = screen.Bounds.Width;
      Height = screen.Bounds.Height;
    

    Micdenny has ported the Windows Forms Screen helper for WPF. This is excellent when you have other WPF refs that do not play nice with Forms (Like WPF Live-Charts).

提交回复
热议问题