Monday, June 4, 2012

Maximize a WPF Window with a custom window chrome and multiple monitors, accounting for the taskbar

A WPF window with WindowStyle set to None does not take the task bar height into account when maximized. This workaround will allow the window to be maximized to the correct size with a multiple monitor configuration. 

public MainWindow()
    LocationChanged += new EventHandler(MainWindow_LocationChanged);

void MainWindow_LocationChanged(object sender, EventArgs e)
    Screen current = Screen.FromHandle(new WindowInteropHelper(this).Handle);
    if(current.Primary) MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
    else MaxHeight = double.PositiveInfinity;

1 comment:

  1. If you are being attentive to learn several strategies then you ought to browse this article, I am certain you'll get much additional from this article.
    Singapore Shelf Companies