locked
Universal App Screen Resolution

    Question

  • Ok, what's the best way of getting the screen resolution on a WP8.1 device.   I've tried this

    http://msdn.microsoft.com/en-us/library/windows/apps/jj247549(v=vs.105).aspx

    and I get a deprecation warning

    warning C4973: 'Windows::Graphics::Display::DisplayPropertiesEventHandler' : marked as deprecated

    1>          Message: 'The DisplayProperties type and related event handlers may be altered and or unavailable for releases after Windows 8.1. Instead, use DisplayInformation.'
    Sunday, October 19, 2014 12:05 PM

Answers

  • Sorry, the answer is no, there is no way that can work both for Windows Store App and Windows Phone.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Pappaxray Tuesday, October 21, 2014 11:11 AM
    Tuesday, October 21, 2014 8:45 AM
    Moderator

All replies

  • Hi Pappaxray,

    Why not use DisplayInformation instead? The documentation you read is only workable for WP 8.0 but not 8.1.

    RawPixelsPerViewPixel | rawPixelsPerViewPixel property could help you I think.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, October 20, 2014 3:32 AM
    Moderator
  • I tried DisplayInformation but I believe RawPixelsPerViewPixel only exists for the windows phone version.  Is there a way of doing this for both Windows and Windows Phone versions without resorting to platform specific code?
    Monday, October 20, 2014 11:42 AM
  • Sorry, the answer is no, there is no way that can work both for Windows Store App and Windows Phone.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Pappaxray Tuesday, October 21, 2014 11:11 AM
    Tuesday, October 21, 2014 8:45 AM
    Moderator
  • Its not that much platform specific code,

    var bounds = Window.Current.Bounds;

    double height = bounds.Height;
    double width = bounds.Width;

    #if WINDOWS_PHONE_APP
         height *= DisplayInformation.GetForCurrentView().RawPixesPerViewPixel;
         width *= DisplayInformation.GetForCurrentView().RawPixesPerViewPixel;
    #endif

    Wednesday, January 21, 2015 2:00 AM