【问题标题】:How to distinguish winphone from UWP in xamarin PCL如何在xamarin PCL中区分winphone和UWP
【发布时间】:2018-02-24 15:25:34
【问题描述】:

我有一个 xamarin 原生项目。

在 PCL 中,我想区分它运行的是 winphone 还是 uwp

我可以轻松区分 iOS、Android 和 Windows(winphone 和 UWP)

我不知道如何区分winphone和UWP

这是我尝试过的

 var platform = CrossDeviceInfo.Current.Platform;
            if (platform != Plugin.DeviceInfo.Abstractions.Platform.Windows && platform != Plugin.DeviceInfo.Abstractions.Platform.WindowsPhone){

 }

甚至 uwp 项目都说它的 windowsphone ..

我希望 xamarin.winphone 是 windowsphone 而 uwp 是 windows.. 但结果两者都是 winphone

我正在使用 CrossDeviceInfo .. 我找不到这样做的方法

【问题讨论】:

    标签: xamarin portable-class-library xamarin.uwp xamarin.winphone cross-device


    【解决方案1】:

    使用Device.RuntimePlatform

    if (Device.RuntimePlatform == Device.WinPhone) ...
    if (Device.RuntimePlatform == Device.Windows) ...
    

    【讨论】:

    • 它适用于 xamarin.forms.. 我正在使用 xamarin Native
    猜你喜欢
    • 2017-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-23
    • 2017-02-27
    • 2017-03-10
    • 1970-01-01
    相关资源
    最近更新 更多