简体   繁体   中英

XAML Resizing window and all elements inside window

I have a game that I've been writing in C# and XAML, but I've run into an issue. My laptop that I've been creating the game on has a 4k monitor, so I (stupidly) made the XAML to the specifications of a 4k window. When I try to run it on a lower resolution monitor, as you would expect, all of the elements are the wrong size and location. It would be a massive pain to rework everything in the window, and I'm wondering if there's any way to scale the entire window and all of its contents based on the window size?

A few thoughts I had for potential solutions that may be worth exploring:

  1. Is there a way to get the size of the window and modify all of the elements and their positions/margins, etc so that they scale with it?

  2. Is there a way to make a window that's 4k and contains the game window, but the window itself scales so that the game window doesn't have to do any work scaling, because is automatically scaled with the window that contains it?

Let me know if you have any questions that would help you understand my issue or my potential solution suggestions better.

Using a Viewbox will do what I was trying to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM