locked
How to get the physical size of screen(ie. 5", 12") RRS feed

  • Question

  • Although many devices has a small physical size screen, but the resolution is large. so when we use the control of SplitView, we should show "content" only.

    ie.

    1. a device has a 4" screen, the resolution is 1280 x 800, in this case, we only show "content".

    2. a devoce has a 8" screen, the resolution aslo is 1280 x 800, in this case, we should show "pane" and "content".

    question: how to get the physical size of screen?


    • Edited by oneonce Saturday, August 15, 2015 3:36 PM
    Saturday, August 15, 2015 3:22 PM

Answers

  • You could try basing some code on this approach:

    http://stackoverflow.com/questions/10828179/how-to-get-the-resolution-of-screen-for-a-winrt-app

             void detectScreenType()
        {
            double dpi = DisplayProperties.LogicalDpi;
            var bounds = Window.Current.Bounds;
            double h;
            switch (ApplicationView.Value)
            {
                case ApplicationViewState.Filled:
                    h = bounds.Height;
                    break;
    
                case ApplicationViewState.FullScreenLandscape:
                    h = bounds.Height;
                    break;
    
                case ApplicationViewState.Snapped:
                    h = bounds.Height;
                    break;
    
                case ApplicationViewState.FullScreenPortrait:
                    h = bounds.Width;
                    break;
    
                default:
                    return;
            }
            double inches = h / dpi ;
            string screenType = "Slate";
            if (inches < 10)
            {
                screenType = "Slate";
            } else if (inches < 14) {
                screenType = "WorkHorsePC";
            }
            else 
            {
                screenType = "FamilyHub";
            }
            ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            localSettings.Values["screenType"] = screenType;
        }


    • Marked as answer by oneonce Sunday, August 16, 2015 12:44 PM
    Saturday, August 15, 2015 3:42 PM