How to resize a Game
Demonstrates how to handle the resizing of the active game window.
Overview
On Desktop, it is normally possible for the user to change how the game window is sized, either by moving from full-screen to windowed, or by altering the resolution of their screen. In these cases an event is fired to enable you to handle these changes.
Note
Ideally, your games drawing should always take account of the Aspect Ratio and dimensions of the displayed screen, regardless of device, else content may not be always drawn where you expect it to.
To handle player window resizing to a game
Derive a class from Game.
Set Game.GameWindow.AllowUserResizing to true.
Add an event handler for the ClientSizeChanged event of Game.Window.
this.Window.AllowUserResizing = true; this.Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged);
Implement a method to handle the ClientSizeChanged event of Game.Window.
void Window_ClientSizeChanged(object sender, EventArgs e) { // Make changes to handle the new window size. }
See Also
Concepts
Reference
© 2012 Microsoft Corporation. All rights reserved.