0

I have a Window that pops up and allows a user to enter the details of a Company. When the resolution of the user's screen is 1920x1080 the Window size is perfect, the text is readable etc etc..

However, as I set the Width and Height like so Height="380" Width="1200", if the user is on say a laptop with resolution of 1366x768, the Window is far too big for the screen and they actually can't see the text.

Instead of specifically setting the Width and Height which does not work for me at different resolutions, how can I take advantage of WPF to allow the Window to change size dependent on say, the resolution of the user's monitor or maybe the parent Window which is fullscreen?

CBreeze
  • 2,925
  • 4
  • 38
  • 93

1 Answers1

1

You should set the width and height using these:

width = System.Windows.SystemParameters.PrimaryScreenWidth * 0.8;
height = System.Windows.SystemParameters.PrimaryScreenHeight * 0.8;

The 0.8 at the end makes your window 80% the screen size. You can do better things for example set a maximum amount for width and height and etc.

Hope it helps.

Emad
  • 3,809
  • 3
  • 32
  • 44