GraphicsDevice.DisplayMode Property

Retrieves the display mode's spatial resolution, color resolution, and refresh frequency.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in

public DisplayMode DisplayMode { get; }

Property Value

Data describing the display mode of the adapter, as opposed to the display mode of the GraphicsDevice, which may be inactive if the GraphicsDevice does not own full-screen mode.

For a list of all supported display modes for an adapter, see the SupportedDisplayModes property.

This simple example checks for a supported display mode and sets the back buffer dimensions to match the resolution of the desired display mode.

public class Game1 : Microsoft.Xna.Framework.Game
    GraphicsDeviceManager graphics;

    public Game1()
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";

        graphics.PreparingDeviceSettings +=
            new EventHandler<PreparingDeviceSettingsEventArgs>(

    /// <summary>
    /// Modifies the display mode for the graphics device 
    /// when it is reset or recreated.
    /// </summary>
    void graphics_PreparingDeviceSettings(object sender,
        PreparingDeviceSettingsEventArgs e)
        foreach (Microsoft.Xna.Framework.Graphics.DisplayMode displayMode
            in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            if (displayMode.Width == 640 && displayMode.Height == 480)
                    BackBufferFormat = displayMode.Format;
                    BackBufferHeight = displayMode.Height;
                    BackBufferWidth = displayMode.Width;

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone 7

Community Additions