简体   繁体   English

特定版本Windows 10的目标代码,例如Build 10586

[英]Target code for a specific version of Windows 10, like Build 10586

As you know ElementCompositionPreview.GetElementVisual is accessible on Windows 10 Build 10586, I would like to have one application that can target both Build 10586 and Build 10240. 如您所知,在Windows 10 Build 10586上可以访问ElementCompositionPreview.GetElementVisual,我希望有一个可以同时针对Build 10586和Build 10240的应用程序。

Does anyone have an idea of how I could use Compositor and ElementCompositionPreview.GetElementVisual when the application is running on Build 10586 and something else when it is running the build 10240. 有没有人知道如何在Build 10586上运行应用程序时使用Compositor和ElementCompositionPreview.GetElementVisual,以及运行build 10240时的其他内容。

Something like this: 像这样的东西:

  #if WINDOWS_UWP Build 10586
       _compositor = new Compositor();
       _root = ElementCompositionPreview.GetElementVisual(myElement);
  #endif


 #if WINDOWS_UWP Build 10240
  //other code
 #endif

Any idea? 任何的想法?

As you know ElementCompositionPreview.GetElementVisual is accessible on Windows 10 Build 10586, I would like to have one application that can target both Build 10586 and Build 10240 如您所知,在Windows 10 Build 10586上可以访问ElementCompositionPreview.GetElementVisual,我希望有一个可以同时针对Build 10586和Build 10240的应用程序

For UWP app, there is only one Target version, for your requirement, we can set Target version to Build 10586 and the Min version: Build 10240 对于UWP应用程序,只有一个Target版本,根据您的要求,我们可以将Target版本设置为Build 10586和Min版本:Build 10240 在此输入图像描述

Does anyone have an idea of how I could use Compositor and ElementCompositionPreview.GetElementVisual when the application is running on Build 10586 and something else when it is running the build 10240. 有没有人知道如何在Build 10586上运行应用程序时使用Compositor和ElementCompositionPreview.GetElementVisual,以及运行build 10240时的其他内容。

Please use Windows.Foundation.Metadata.ApiInformation API to dynamically detect features: 请使用Windows.Foundation.Metadata.ApiInformation API动态检测功能:

if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview"))
{
                if (Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", "GetElementVisual"))
                {
                    _compositor = new Windows.UI.Composition.Compositor();
                    _root = Windows.UI.Xaml.Hosting.ElementCompositionPreview.GetElementVisual(btn1);
                }
                else
                {
                    //Do other things
                }
}

Here is a good article to introduce this API: Dynamically detecting features with API contracts (10 by 10) 以下是介绍此API的好文章: 使用API​​合同动态检测功能(10 x 10)

I think you can use System.Reflection to get the OS version from your app for example like this: 我认为您可以使用System.Reflection从您的应用程序获取操作系统版本,例如:

var analyticsInfoType = Type.GetType("Windows.System.Profile.AnalyticsInfo, Windows, ContentType=WindowsRuntime");
var versionInfoType = Type.GetType("Windows.System.Profile.AnalyticsVersionInfo, Windows, ContentType=WindowsRuntime");

if (analyticsInfoType == null || versionInfoType == null)
{
    //not on Windows 10
    return;
}

var versionInfoProperty = analyticsInfoType.GetRuntimeProperty("VersionInfo");

object versionInfo = versionInfoProperty.GetValue(null);
var versionProperty = versionInfoType.GetRuntimeProperty("DeviceFamilyVersion");
object familyVersion = versionProperty.GetValue(versionInfo);
long versionBytes;
if (!long.TryParse(familyVersion.ToString(), out versionBytes))
{
    //can't parse version number
    return;
}

Version DeviceVersion = new Version((ushort)(versionBytes >> 48),
  (ushort)(versionBytes >> 32),
  (ushort)(versionBytes >> 16),
  (ushort)(versionBytes));

if ((ushort)(versionBytes >> 16) == 10586)
{
    _compositor = new Compositor();
    _root = ElementCompositionPreview.GetElementVisual(myElement);
}
else
{
    //other code
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 问:VS2015社区更新3是否在Win7SP1上为Win10 Build 10586编译Windows UWP应用程序? - Q: Does VS2015 Community Update 3 compile Windows UWP Apps for Win10 Build 10586 on Win7SP1? UWP,Windows 11月10日更新的哈希密码(10586) - UWP, Hashing Password for Windows 10 November Update (10586) Windows 10 Pro x64 10586 无法运行 VS 2008 C# .exe - Windows 10 Pro x64 10586 won't run VS 2008 C# .exe's Unity:代码在编辑器中运行良好,但在构建版本中失败(Windows 10 64位) - Unity: Code works great in editor but fails in build version (Windows 10 64 bit) C#,如何为Windows版本(例如Windows 8或Windows 10)制作if循环语句? - C#, how make a if loop statement for windows version like windows 8 or windows 10? 如何从UWP获取Windows的用户友好版本名称,如“Windows 10 Pro” - How can I get User Friendly version name of Windows like 'Windows 10 Pro' from UWP 定位程序集的非特定版本 - Target non specific version of an assembly 从Windows 10定位到.NET 4.0? - Target .NET 4.0 from Windows 10? 如何使用Windows 10创建特定于设备系列的项目,如W8.1 / WP8.1? - How to create device-family-specific projects with Windows 10, like on W8.1/WP8.1? 共享目标通用应用程序Windows 10方法 - Sharing target Universal Apps Windows 10 approach
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM