Getting Display Width And Height On Windows Phone Is Buggy

Hi,

This appears to be not working correctly, on my Lumia 520 which is 480*800 I get…

GraphicsDeviceManager.PreferredBackBufferWidth = 0; WRONG
GraphicsDeviceManager.PreferredBackBufferHeight = 0; WRONG

GraphicsDevice.DisplayMode.Width = 600; WRONG
GraphicsDevice.DisplayMode.Width = 800; CORRECT

I have been able to hack correct values by referencing the native properties…

Application.Current.Host.Content.ActualWidth; 480
Application.Current.Host.Content.ActualHeight; 800

…and this works (though there is some thread lock in accessing these values so I had to do some hacky static variable stuff to be able to access them from within my game loop).

cheers

Have you tried using GraphicsDevice.Viewport.Bounds.Width and GraphicsDevice.Viewport.Bounds.Height?

I have now - these are OK!

Thanks!

Now I’m just curious. I’ve had the same “issue” here, and I’m wondering why GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width displays the wrong value (600 instead of 480) while GraphicsDevice.Viewport displays it correctly. Is this hardware-related?

… Where are the other 120 pixels?