How do I set the window / screen size in xna?

Sjors Miltenburg picture Sjors Miltenburg · Apr 6, 2009 · Viewed 88.6k times · Source

How can I adjust the size of the window in XNA.

Default it starts in a 800x600 resolution.

Answer

James picture James · Apr 14, 2010

As of XNA 4.0 this property is now found on the GraphicsDeviceManager. Ie. this code would go in your Game's constructor.

graphics = new GraphicsDeviceManager(this);
graphics.IsFullScreen = false;
graphics.PreferredBackBufferHeight = 340;
graphics.PreferredBackBufferWidth = 480;

// if changing GraphicsDeviceManager properties outside 
// your game constructor also call:
// graphics.ApplyChanges();