了解 Windows Phone 8 应用是否 运行 在 Windows 10 上 phone

Know if a Windows Phone 8 app is running on Windows 10 for phone

有什么方法可以知道 Windows Phone 8 应用是否 运行 在 Windows 10 上 phone?

我正在注册 ScheduledActionService,但当应用程序在 Win10 上 运行 时崩溃。

提前致谢。

Rudy Huyn 有一个博客 post,其中有一个辅助方法可以使用反射检测您的应用程序是否在 Windows 10 上 运行。

using System.Reflection;
using Windows.ApplicationModel;

namespace Huyn.Utils
{
    public class Windows10Helper
    {
        private static bool? _isWindows10;
        public static bool IsWindows10()
        {
            if (!_isWindows10.HasValue)
            {
                _isWindows10 = Package.Current.GetType()
                     .GetRuntimeProperty("Status") != null;
            }
            return _isWindows10.Value;
        }
    }
}

请注意,由于状态 属性 是 Windows 10 的新功能,因此这实际上只能用于检测。假设 Microsoft 不会将 Windows 8.1 更新为支持这个新的 属性,这应该非常适合您的场景。

Source