How to Set Width of a Page in a WPF Application

By Mahesh Chand Oct 07, 2011
How to Set Width of a Page in a WPF Application.

Recently, I have been working on a WPF application that has some Windows and Pages. A Page is hosted within a Windows in an XBAP application. The Width, MaxWidth and MinWidth properties do not apply to a Page. The only way you could change the width of a page is using the WindowWidth property.

The following code snippet sets a Page width.


       Width="1200" Height="768">


You can also set this dynamically from the code on the class constructor or anywhere else.

public DashboardAdministrator(){


       this.WindowHeight = 860;
       this.WindowWidth = 1024; 


Related Readings

Mahesh Chand
Mahesh Chand

C# Corner founder, 10-times Microsoft MVP, technical author, and software architect. Mahesh authored his first book, A Programmer’s Guide to ADO.NET in C# with APress at the age of 25. C# Corner is a memb... Read more