Showing a window with WPF, Winforms, and Dual monitors

后端 未结 4 1588
太阳男子
太阳男子 2020-12-11 01:58

I have a 2 monitors and a WinForm app that launches a WPF window. I want to get the screen that the WinForm is on, and show the WPF window on the same screen. How can I do

4条回答
  •  旧巷少年郎
    2020-12-11 02:41

    Another way of doing it is:

    WindowInteropHelper helper = new WindowInteropHelper(this);
    
    this.StartupLocation = System.Windows.WindowStartupLocation.Manual;
    this.Left = System.Windows.Forms.Screen.FromHandle(helper.Handle).Bounds.Left;
    this.Top = System.Windows.Forms.Screen.FromHandle(helper.Handle).Bounds.Top;
    

    this = your WPF Window...

提交回复
热议问题