Sheamus
Sheamus

Reputation: 223

Set window proportions

I would like to set some proportions on a window, like height = half of width. I want to make it adaptive, because I have to consider multiple screen sizes. And I would manage it with a maximum height and width if the window is too big for the screen.

But I've searched on the web and found nothing :D

Edit :

I've tried SizeToContent="WidthAndHeight" but as I have tabs, the window size changes regarding the tabs' content. If possible I would prefer a fixed size.

Upvotes: 0

Views: 340

Answers (1)

Malachi
Malachi

Reputation: 3221

How to Fetch the Current System Resolution in C#:

int hght = Screen.PrimaryScreen.WorkingArea.Height;
int wght = Screen.PrimaryScreen.WorkingArea.Height;

How to Set the height and width of the Form Size:

On Page_Load() event of the Form write the following code

this.Width = Screen.PrimaryScreen.WorkingArea.Width;
this.Height = Screen.PrimaryScreen.WorkingArea.Height ;

how to develop resolution independent Windows Applications in .NET

Upvotes: 4

Related Questions