This project is read-only.

Change the size of a window

May 2, 2011 at 8:37 PM

Is it possible to define the size of a window by pixels, as opposed to state (minimized, restored, etc.)?

May 3, 2011 at 7:46 AM
Edited May 3, 2011 at 7:50 AM


I use this to resize a window:



/// <summary>
/// Resizes a window.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="high">The high.</param>
public static void ResizeWindow( Window window, double width, double high )
  TransformPattern pattern = window.AutomationElement.GetCurrentPattern( TransformPattern.Pattern ) as TransformPattern;
  if( pattern != null )
    // Resize pattern
    pattern.Resize( width, high );



You can also have a look to the Bounds element of a Window, there are some helpful properties and operations like Scale, Size and Transform



May 3, 2011 at 1:30 PM


I have looked at 'bounds' but I cant figure out how to use it.  When I type 'maindinow.Bounds.' I dont get anymore auto-fill tips.

May 3, 2011 at 2:18 PM


Visual Studio?


Try Strg+Space


May 4, 2011 at 1:39 PM

I am not sure what Strg+Space is, but I can tell you that the only info I can get from VS about Bounds is that it takes a rectangle as an argument.


May 4, 2011 at 2:08 PM
Edited May 4, 2011 at 2:08 PM

Strg+ Space => Short-cut in VisualStudio to open Intellisence


maybe missing References or Using?


if I type window.Bounds I get many operations and properties (Bounds comes from System.Windows.Rect)


I try

Rect rec = _window.Bounds;

=> and rec has  also the same Properties

so not a white problem I think.


Nov 30, 2011 at 12:00 PM

"Strg" is the german name of the "Ctrl"-key :-)