Having read about this, I feel there is still an un-answered question about detecting whether a UWP app is running on a device where it would be appropriate to display in portrait only.
The optimal page layouts for our UWP app are such that on a phone, it's best that we disable landscape mode (we don't need such a restriction for larger format devices). What would be the best-practice approach to accomplish this?
UWP XAML framework – this is the part of Windows 10/11 that you use to build your UWP apps with, it contains XAML and the visual layer that is necessary to render your app, including user input functionality. UWP XAML controls – the controls that you use in your UWP apps, they're also part of Windows 10/11.
NET Core. UWP is also known as Windows 10 UWP application. This application does not run on previous versions of Windows but will only run on future version of Windows. Following are a few exceptions where UWP will run smoothly.
You can detect the device family using AnalyticsInfo.VersionInfo.DeviceFamily
.
if(AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") {
// It's a phone
}
else {
// It's not a phone
}
if ((Window.Current.Bounds.Width < 640) && (Window.Current.Bounds.Height < 550))
{
//Do something
}
Best of luck .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With