user1744147
user1744147

Reputation: 1147

Get available screen size

How can I get the screen size of max size the app can be resized to on Win 10 UWP?

Also is it possible to detect if the app is maximized or running in phone/tablet mode vs. in windowed mode?

Upvotes: 4

Views: 4000

Answers (4)

Chuck Walbourn
Chuck Walbourn

Reputation: 41127

There's no 'maximum size' per se. Windows 10 support for 8K resolutions (7680*4320) has been mentioned in the press, so that's as close to a 'maximum size' as you are going to see and is certainly not going to be a common display size in the near future.

Remember that universal Windows apps and Windows 8 Store apps express window size as a combination of logical size and DPI. You convert it to physical pixels with the following math:

// Converts a length in device-independent pixels (DIPs) to a length in physical pixels.
inline float ConvertDipsToPixels(float dips, float dpi)
{
    static const float dipsPerInch = 96.0f;
    return floorf(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer.
}

Information about the display is obtained from the WinRT class DisplayInformation, and you can control some aspects of 'mode' using ApplicationView.

Upvotes: 0

George Lanetz
George Lanetz

Reputation: 300

ApplicationView.GetForCurrentView().IsFullScreen can help you to detect if your app is in fullscreen mode. I suppose this is what you need.

Upvotes: 1

Lucian Wischik
Lucian Wischik

Reputation: 2336

Maximum size the app can be resized to (i.e. the "work area", i.e. the screen size minus the taskbar)? There's no way to get this information.

Note: you can call ApplicationView.GetForCurrentView().TryResizeView(New Size(500, 500)) to programmatically resize. But this won't resize larger than the work area.

Is it possible to detect what mode the app is in?

UIViewSettings.GetForCurrentView.UserInteractionMode says whether you're in "mouse mode" (windowed) or "touch mode" (phone/tablet).

ApplicationView.GetForCurrentView.TryEnterFullScreenMode() will try to put you into full-screen mode (on the desktop, it means your app is the full screen with no taskbar; on phone, it means there's no statusbar and no "soft navigation buttons"). You can also call ExitFullScreenMode(). The property IsFullScreenMode will say whether you've entered full-screen mode via that API. (there's another deprecated API called "IsFullScreen" that you shouldn't use).

I don't know how to detect if it's maximized.

Upvotes: 5

thezapper
thezapper

Reputation: 496

As an idea: check if the app is running on a phone/tablet/pc you could use custom VisualStateTriggers and checking the device-familly. There are some samples in the net.

Maybe that helps?!

Upvotes: 0

Related Questions