简体   繁体   中英

How to obtain correct windows phone version in Xamarin.Forms

In the recent version Xamarin.Forms the Device.OS property returns for both Windows Phone 8.1 and Windows 10 UWP the "Windows" value. Is there a way to obtain a correct Device OS version to distinguish between the Windows Phone 8.1 and Windows 10 UWP?

if (Device.Idiom == TargetIdiom.Desktop)
{ 
    // UWP
}
else if (Device.OS == TargetPlatform.WinPhone)
{ 
    // WinPhone
}
else if (Device.OS == TargetPlatform.Windows)
{ 
    // Windows 8
}

Just to explain, Windows 8 Idiom is TargetIdiom.Tablet, so the only OS that returns true to TargetIdiom.Desktop is UWP.

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM