在Xamarin表单中检测Windows Phone 8.1与Windows Phone上的UWPapp

本文关键字:Phone Windows 上的 UWPapp Xamarin 检测 表单 | 更新日期: 2023-09-27 18:13:35

我正试图找到一种方法来区分我的应用程序是否作为手机上的UWP应用程序运行,或者如果它在手机上的WinPhone 8.1和UWP应用程序都有设备。TargetPlatform.Windows操作系统。因此,我无法找到一种方法来确定它是UWP应用程序还是运行在手机上的Windows Phone 8.1应用程序。有什么建议吗?我的示例代码如下:

        if ( Device.OS == TargetPlatform.Windows)
        {
            this.grdButtons.ColumnSpacing = 0;
        }

在Xamarin表单中检测Windows Phone 8.1与Windows Phone上的UWPapp

如果你还在寻找答案

下面:https://learn.microsoft.com/de-de/xamarin/xamarin-forms/platform/device

using-directive Xamarin.Forms提供了一个获取运行时平台的函数。你可以将其与Android, WinRT, WinPhone, macOS, iOS, UWP进行比较。例如:

if (Device.RuntimePlatform.Equals(Device.UWP))
{
}

此外,您还可以比较设备的习惯用法,以确定您的应用程序是否运行在手机,平板电脑,…