I am trying to find out the display which the user is currently using as primary display for the computer/laptop, so that I can show the available displays to the user, which supports projection and can be used using ProjectionManager
API. Please remember that, this is for UWP application.
DeviceInformationCollection displayDevices = DeviceInformation.FindAllAsync(ProjectionManager.GetDeviceSelector());
DeviceInformation.FindAllAsync(...)
returns a collection of DeviceInformation
. DeviceInformation
has Pairing
property, but that always returns false (Even for Primary Display).
Is there any other APIs which I can use to get the primary display/currently using display?
For example:
DeviceId
I get from DeviceInformation
can be used BluetoothDevice.FromIdAsync(String DeviceId)
for Bluetooth specific API requirements, such as - Connected
status.DeviceId
and match with DeviceInformation.DeviceId
from the collection to discard it?Is something like that available for ProjectionManager
? I have gone through official docs, also github examples and couldn't find anything suitable. So, help needed. Thanks.
Is there any other APIs which I can use to get the primary display/currently using display?
ProjectionManager
has no such api could detect primary display or not. but you could use DisplayRegion
to detect it.
if you want to get primary, you could check if current DisplayRegion WorkAreaOffset
is {0,0}
. and it has device id property, you could use it to get matched monitor.
IReadOnlyList<DisplayRegion> displayRegions = ApplicationView.GetForCurrentView().WindowingEnvironment.GetDisplayRegions();
// count all the DisplayRegions that are marked as available to the app for use.
foreach (DisplayRegion displayregion in displayRegions)
{
if (displayregion.IsVisible)
{
Debug.WriteLine(displayregion.WorkAreaOffset);
}
}
For getting currently using display.
ApplicationView.GetForCurrentView().GetDisplayRegions()[0]
For more code please refer to official code sample.