DisplayInformation DisplayInformation DisplayInformation DisplayInformation DisplayInformation Class

Definition

Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

[Contains prerelease APIs.]
Monitors and controls physical display information. The class provides events to allow clients to monitor for changes in the display.

public : sealed class DisplayInformation : IDisplayInformation, IDisplayInformation2, IDisplayInformation3, IDisplayInformation4
struct winrt::Windows::Graphics::Display::DisplayInformation : IDisplayInformation, IDisplayInformation2, IDisplayInformation3, IDisplayInformation4
public sealed class DisplayInformation : IDisplayInformation, IDisplayInformation2, IDisplayInformation3, IDisplayInformation4
Public NotInheritable Class DisplayInformation Implements IDisplayInformation, IDisplayInformation2, IDisplayInformation3, IDisplayInformation4
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

To handle DisplayInformation events, use an event handler for the specific event. For example, for DisplayInformation.DpiChanged, use "TypedEventHandler<DisplayInformation, Object> DpiChanged."

Any property change event of DisplayInformation might trigger if your app is moved from one monitor to another monitor. ColorProfileChanged is triggered when the display’s color profile changes. DpiChanged is triggered when either the LogicalDpi or ResolutionScale property changes because a user selected a different zoom level or changed the screen resolution. OrientationChanged is triggered if a user changes the screen orientation.

Properties

AutoRotationPreferences AutoRotationPreferences AutoRotationPreferences AutoRotationPreferences AutoRotationPreferences

Gets and sets the preferred orientation of the app.

public : static DisplayOrientations AutoRotationPreferences { get; set; }
static DisplayOrientations AutoRotationPreferences();

static void AutoRotationPreferences(DisplayOrientations autorotationpreferences);
public static DisplayOrientations AutoRotationPreferences { get; set; }
Public Static ReadWrite Property AutoRotationPreferences As DisplayOrientations
var displayOrientations = Windows.Graphics.Display.DisplayInformation.autoRotationPreferences;
displayInformation.autoRotationPreferences = displayOrientations;
Value
DisplayOrientations DisplayOrientations DisplayOrientations

The orientation of a rectangular monitor.

Remarks

This property is static.

CurrentOrientation CurrentOrientation CurrentOrientation CurrentOrientation CurrentOrientation

Gets the current orientation of a rectangular monitor.

public : DisplayOrientations CurrentOrientation { get; }
DisplayOrientations CurrentOrientation();
public DisplayOrientations CurrentOrientation { get; }
Public ReadOnly Property CurrentOrientation As DisplayOrientations
var displayOrientations = displayInformation.currentOrientation;
Value
DisplayOrientations DisplayOrientations DisplayOrientations

The current orientation of a rectangular monitor.

Remarks

The value of the DisplayInformation::CurrentOrientation property corresponds to the orientation of the display or monitor and not necessarily to the orientation of your app. To determine the orientation of your app for layout purposes, use the ApplicationView.Value property.

DiagonalSizeInInches DiagonalSizeInInches DiagonalSizeInInches DiagonalSizeInInches DiagonalSizeInInches

Diagonal size of the display in inches.

public : IReference<double> DiagonalSizeInInches { get; }
IReference<double> DiagonalSizeInInches();
public Nullable<double> DiagonalSizeInInches { get; }
Public ReadOnly Property DiagonalSizeInInches As Nullable<double>
var nullable = displayInformation.diagonalSizeInInches;
Value
Nullable<double> Nullable<double> Nullable<double>

Returns the diagonal size of the display in inches. May return null when display size information is not available or undetermined (when connected to a projector, or displays are duplicated).

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

LogicalDpi LogicalDpi LogicalDpi LogicalDpi LogicalDpi

Gets the pixels per logical inch of the current environment.

public : float LogicalDpi { get; }
float LogicalDpi();
public float LogicalDpi { get; }
Public ReadOnly Property LogicalDpi As float
var float = displayInformation.logicalDpi;
Value
float float float

The pixels per logical inch of the current environment.

Remarks

The logical dots per inch (DPI) can change based on scaling. For info about the meaning of logical DPI, see DPI and Device-Independent Pixels.

NativeOrientation NativeOrientation NativeOrientation NativeOrientation NativeOrientation

Gets the native orientation of the display monitor, which is typically the orientation where the buttons on the device match the orientation of the monitor.

public : DisplayOrientations NativeOrientation { get; }
DisplayOrientations NativeOrientation();
public DisplayOrientations NativeOrientation { get; }
Public ReadOnly Property NativeOrientation As DisplayOrientations
var displayOrientations = displayInformation.nativeOrientation;
Value
DisplayOrientations DisplayOrientations DisplayOrientations

The native orientation of the display monitor.

Remarks

NativeOrientation returns only the Landscape or Portrait value. NativeOrientation never returns the LandscapeFlipped or PortraitFlipped value.

RawDpiX RawDpiX RawDpiX RawDpiX RawDpiX

Gets the raw dots per inch (DPI) along the x axis of the display monitor.

public : float RawDpiX { get; }
float RawDpiX();
public float RawDpiX { get; }
Public ReadOnly Property RawDpiX As float
var float = displayInformation.rawDpiX;
Value
float float float

The raw dots per inch (DPI) along the x axis of the display monitor.

Remarks

This property can return 0 when the monitor doesn't provide physical dimensions and when the user is in a clone or duplicate multiple-monitor setup.

RawDpiY RawDpiY RawDpiY RawDpiY RawDpiY

Gets the raw dots per inch (DPI) along the y axis of the display monitor.

public : float RawDpiY { get; }
float RawDpiY();
public float RawDpiY { get; }
Public ReadOnly Property RawDpiY As float
var float = displayInformation.rawDpiY;
Value
float float float

The raw dots per inch (DPI) along the y axis of the display monitor.

Remarks

This property can return 0 when the monitor doesn't provide physical dimensions and when the user is in a clone or duplicate multiple-monitor setup.

RawPixelsPerViewPixel RawPixelsPerViewPixel RawPixelsPerViewPixel RawPixelsPerViewPixel RawPixelsPerViewPixel

Gets a value representing the number of raw (physical) pixels for each view (layout) pixel.

public : double RawPixelsPerViewPixel { get; }
double RawPixelsPerViewPixel();
public double RawPixelsPerViewPixel { get; }
Public ReadOnly Property RawPixelsPerViewPixel As double
var double = displayInformation.rawPixelsPerViewPixel;
Value
double double double

A value representing the number of raw (physical) pixels for each view (layout) pixel.

See Also

ResolutionScale ResolutionScale ResolutionScale ResolutionScale ResolutionScale

Gets the scale factor of the immersive environment.

public : ResolutionScale ResolutionScale { get; }
ResolutionScale ResolutionScale();
public ResolutionScale ResolutionScale { get; }
Public ReadOnly Property ResolutionScale As ResolutionScale
var resolutionScale = displayInformation.resolutionScale;
Value
ResolutionScale ResolutionScale ResolutionScale

The scale factor of the immersive environment.

ScreenHeightInRawPixels ScreenHeightInRawPixels ScreenHeightInRawPixels ScreenHeightInRawPixels ScreenHeightInRawPixels

Returns the current height resolution of the logical monitor.

public : unsigned int ScreenHeightInRawPixels { get; }
uint32_t ScreenHeightInRawPixels();
public uint ScreenHeightInRawPixels { get; }
Public ReadOnly Property ScreenHeightInRawPixels As uint
var uint = displayInformation.screenHeightInRawPixels;
Value
uint uint uint

Returns the current resolution of the logical monitor containing the application’s view. When the application’s view is moved to another logical monitor, this property will reflect the new logical monitor’s resolution.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ScreenWidthInRawPixels ScreenWidthInRawPixels ScreenWidthInRawPixels ScreenWidthInRawPixels ScreenWidthInRawPixels

Returns the current width resolution of the logical monitor.

public : unsigned int ScreenWidthInRawPixels { get; }
uint32_t ScreenWidthInRawPixels();
public uint ScreenWidthInRawPixels { get; }
Public ReadOnly Property ScreenWidthInRawPixels As uint
var uint = displayInformation.screenWidthInRawPixels;
Value
uint uint uint

Returns the current resolution of the logical monitor containing the application’s view. When the application’s view is moved to another logical monitor, this property will reflect the new logical monitor’s resolution.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

StereoEnabled StereoEnabled StereoEnabled StereoEnabled StereoEnabled

Gets a value that indicates whether the device supports stereoscopic 3D.

public : Platform::Boolean StereoEnabled { get; }
bool StereoEnabled();
public bool StereoEnabled { get; }
Public ReadOnly Property StereoEnabled As bool
var bool = displayInformation.stereoEnabled;
Value
bool bool bool

TRUE if the device is capable of stereoscopic 3D and stereoscopic 3D is currently enabled; FALSE otherwise.

Methods

GetAdvancedColorInfo() GetAdvancedColorInfo() GetAdvancedColorInfo() GetAdvancedColorInfo() GetAdvancedColorInfo()

Prerelease. Retrieves the Advanced Color information.

public : AdvancedColorInfo GetAdvancedColorInfo()
AdvancedColorInfo GetAdvancedColorInfo() const;
public AdvancedColorInfo GetAdvancedColorInfo()
Public Function GetAdvancedColorInfo() As AdvancedColorInfo
var advancedColorInfo = displayInformation.getAdvancedColorInfo();
Returns

The Advanced Color information.

Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

GetColorProfileAsync() GetColorProfileAsync() GetColorProfileAsync() GetColorProfileAsync() GetColorProfileAsync()

Asynchronously gets the default International Color Consortium (ICC) color profile that is associated with the physical display.

public : IAsyncOperation<IRandomAccessStream> GetColorProfileAsync()
IAsyncOperation<IRandomAccessStream> GetColorProfileAsync() const;
public IAsyncOperation<IRandomAccessStream> GetColorProfileAsync()
Public Function GetColorProfileAsync() As IAsyncOperation( Of IRandomAccessStream )
Windows.Graphics.Display.DisplayInformation.getColorProfileAsync().done( /* Your success and error handlers */ );
Returns

Object that manages the asynchronous retrieval of the color profile.

Remarks

The asynchronous operation fails if no physical display is attached to the computer on which the app is running (for example, if the app is running over Remote Desktop Connection), if no color profile is associated with the display, or if the profile doesn't match the signature of an ICC color profile. Additionally, not all device families support returning the display's color profile; currently only the Desktop device family implements this API.

Applications should catch any exceptions thrown by this API. In these cases, there is no valid ICC color profile associated with the display, and the app should handle this by assuming a default color space such as sRGB.

GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView()

Gets the current physical display information.

public : static DisplayInformation GetForCurrentView()
DisplayInformation GetForCurrentView() const;
public static DisplayInformation GetForCurrentView()
Public Static Function GetForCurrentView() As DisplayInformation
var displayInformation = Windows.Graphics.Display.DisplayInformation.getForCurrentView();
Returns

A DisplayInformation object that contains the current physical display information.

Remarks

This method is static.

Events

AdvancedColorInfoChanged AdvancedColorInfoChanged AdvancedColorInfoChanged AdvancedColorInfoChanged AdvancedColorInfoChanged

Prerelease. Raised when the advanced color information is changed.

public : event TypedEventHandler AdvancedColorInfoChanged<DisplayInformation, object>
// Register
event_token AdvancedColorInfoChanged(TypedEventHandler<DisplayInformation, object> const& handler) const;

// Revoke with event_token
void AdvancedColorInfoChanged(event_token const& cookie) const;

// Revoke with event_revoker
AdvancedColorInfoChanged_revoker AdvancedColorInfoChanged(auto_revoker_t, TypedEventHandler<DisplayInformation, object> const& handler) const;
public event TypedEventHandler AdvancedColorInfoChanged<DisplayInformation, object>
Public Event TypedEventHandler AdvancedColorInfoChanged( Of ( Of DisplayInformation ), ( Of object ))
function onAdvancedColorInfoChanged(eventArgs){/* Your code */}


displayInformation.addEventListener("advancedColorInfoChanged", onAdvancedColorInfoChanged);
displayInformation.removeEventListener("advancedColorInfoChanged", onAdvancedColorInfoChanged);
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

Remarks

This is an event registration API which will register an event notification for the UWP apps so that they can be notified whenever there is any change in the Advanced Color info on the monitor corresponding to their CoreWindow. The app can then call the GetAdvancedColorInfo API to know the latest capabilities and state. The app needs to track which values are changed and respond accordingly if needed, event API will not indicate which values changed. Note that this event will remove any existing notification which the app previously registered for changes in Advanced Color info.

ColorProfileChanged ColorProfileChanged ColorProfileChanged ColorProfileChanged ColorProfileChanged

Occurs when the physical display's color profile changes.

public : event TypedEventHandler ColorProfileChanged<DisplayInformation, object>
// Register
event_token ColorProfileChanged(TypedEventHandler<DisplayInformation, object> const& handler) const;

// Revoke with event_token
void ColorProfileChanged(event_token const& cookie) const;

// Revoke with event_revoker
ColorProfileChanged_revoker ColorProfileChanged(auto_revoker_t, TypedEventHandler<DisplayInformation, object> const& handler) const;
public event TypedEventHandler ColorProfileChanged<DisplayInformation, object>
Public Event TypedEventHandler ColorProfileChanged( Of ( Of DisplayInformation ), ( Of object ))
function onColorProfileChanged(eventArgs){/* Your code */}


displayInformation.addEventListener("colorProfileChanged", onColorProfileChanged);
displayInformation.removeEventListener("colorProfileChanged", onColorProfileChanged);

Remarks

The ColorProfileChanged event is only triggered when the display’s color profile changes. You must then call the DisplayInformation::GetColorProfileAsync method to asynchronously retrieve the new color profile.

DisplayContentsInvalidated DisplayContentsInvalidated DisplayContentsInvalidated DisplayContentsInvalidated DisplayContentsInvalidated

Occurs when the display requires redrawing.

public : event TypedEventHandler DisplayContentsInvalidated<DisplayInformation, object>
// Register
event_token DisplayContentsInvalidated(TypedEventHandler<DisplayInformation, object> const& handler) const;

// Revoke with event_token
void DisplayContentsInvalidated(event_token const& cookie) const;

// Revoke with event_revoker
DisplayContentsInvalidated_revoker DisplayContentsInvalidated(auto_revoker_t, TypedEventHandler<DisplayInformation, object> const& handler) const;
public event TypedEventHandler DisplayContentsInvalidated<DisplayInformation, object>
Public Event TypedEventHandler DisplayContentsInvalidated( Of ( Of DisplayInformation ), ( Of object ))
function onDisplayContentsInvalidated(eventArgs){/* Your code */}


displayInformation.addEventListener("displayContentsInvalidated", onDisplayContentsInvalidated);
displayInformation.removeEventListener("displayContentsInvalidated", onDisplayContentsInvalidated);

Remarks

This event is static.

Because this event is static, we recommend that you directly access it from the DisplayInformation object and not from the current physical display info that you get from a call to the DisplayInformation.GetForCurrentView method.

DpiChanged DpiChanged DpiChanged DpiChanged DpiChanged

Occurs when the LogicalDpi property changes because the pixels per inch (PPI) of the display changes.

public : event TypedEventHandler DpiChanged<DisplayInformation, object>
// Register
event_token DpiChanged(TypedEventHandler<DisplayInformation, object> const& handler) const;

// Revoke with event_token
void DpiChanged(event_token const& cookie) const;

// Revoke with event_revoker
DpiChanged_revoker DpiChanged(auto_revoker_t, TypedEventHandler<DisplayInformation, object> const& handler) const;
public event TypedEventHandler DpiChanged<DisplayInformation, object>
Public Event TypedEventHandler DpiChanged( Of ( Of DisplayInformation ), ( Of object ))
function onDpiChanged(eventArgs){/* Your code */}


displayInformation.addEventListener("dpiChanged", onDpiChanged);
displayInformation.removeEventListener("dpiChanged", onDpiChanged);

OrientationChanged OrientationChanged OrientationChanged OrientationChanged OrientationChanged

Occurs when either the CurrentOrientation or NativeOrientation property changes because of a mode change or a monitor change.

public : event TypedEventHandler OrientationChanged<DisplayInformation, object>
// Register
event_token OrientationChanged(TypedEventHandler<DisplayInformation, object> const& handler) const;

// Revoke with event_token
void OrientationChanged(event_token const& cookie) const;

// Revoke with event_revoker
OrientationChanged_revoker OrientationChanged(auto_revoker_t, TypedEventHandler<DisplayInformation, object> const& handler) const;
public event TypedEventHandler OrientationChanged<DisplayInformation, object>
Public Event TypedEventHandler OrientationChanged( Of ( Of DisplayInformation ), ( Of object ))
function onOrientationChanged(eventArgs){/* Your code */}


displayInformation.addEventListener("orientationChanged", onOrientationChanged);
displayInformation.removeEventListener("orientationChanged", onOrientationChanged);

Remarks

The OrientationChanged event occurs only when orientation of the display or monitor changes and not necessarily when the orientation of your app changes. To determine the orientation of your app for layout purposes, use the ApplicationView.Value property.

StereoEnabledChanged StereoEnabledChanged StereoEnabledChanged StereoEnabledChanged StereoEnabledChanged

Occurs when the StereoEnabled property changes because support for stereoscopic 3D changes.

public : event TypedEventHandler StereoEnabledChanged<DisplayInformation, object>
// Register
event_token StereoEnabledChanged(TypedEventHandler<DisplayInformation, object> const& handler) const;

// Revoke with event_token
void StereoEnabledChanged(event_token const& cookie) const;

// Revoke with event_revoker
StereoEnabledChanged_revoker StereoEnabledChanged(auto_revoker_t, TypedEventHandler<DisplayInformation, object> const& handler) const;
public event TypedEventHandler StereoEnabledChanged<DisplayInformation, object>
Public Event TypedEventHandler StereoEnabledChanged( Of ( Of DisplayInformation ), ( Of object ))
function onStereoEnabledChanged(eventArgs){/* Your code */}


displayInformation.addEventListener("stereoEnabledChanged", onStereoEnabledChanged);
displayInformation.removeEventListener("stereoEnabledChanged", onStereoEnabledChanged);

See Also