Search This Blog

Tuesday, August 22, 2017

Display XAML window in the second display WPF

WPF > Windows > Forms > Screen

AllScreens gets an array of all displays on the system.

Example

Display window in the second display WPF

private void Window_Loaded(object sender, RoutedEventArgs e)
{
   var screen = System.Windows.Forms.Screen.AllScreens.Where(s => !s.Primary).First();
   var area = screen.WorkingArea;
   Left = area.Left;
   Top = area.Top;
   Width = area.Width;
   Height = area.Height;
}