tags:

views:

158

answers:

2

How to set the Height and width of a WPF application on maximise? Problem I face is because of variable height of the windows taskbar in different computers

Presently, I am doing it like this. Please suggest any better technique

if (this.WindowState == WindowState.Maximized) { this.Height = primaryScreenHeight - 10 - System.Windows.Forms.SystemInformation.SizingBorderWidth; this.Width = primaryScreenWidth + 2 * System.Windows.Forms.SystemInformation.FrameBorderSize.Width; }

+1  A: 

You dont need to do this. If you use a Grid as your layout container, objects within will always expand to use up all the space. Then you can use Margins to arrange sub-panels. Using the various HorizontalAlignment values of Left,Center,Right,Stretch and VerticalAlignment values of Top, Center, Bottom, Stretch, you can make pretty much any scalable layout without having to check if the app is maximized/minimized, etc.

Is there are a particular layout you want to achieve that perhaps I can post an example for?

David