[UWP]支持两个版本的UWP [英] [UWP]supporting two version of UWP

查看:106
本文介绍了[UWP]支持两个版本的UWP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

xmlns:Windows10version1809 =" http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"

xmlns:Windows10version1809="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)"

使用< NavigationView Windows10version1809:PaneDisplayMode =" Top" .... />

using <NavigationView Windows10version1809:PaneDisplayMode="Top" .... />

导致应用程序在Windows 1803上崩溃

causes app to crash on windows 1803

我希望能够在1809上方导航到1803左上方 

I want to be able to have the navigation on the top on 1809 and to the left on 1803 

目标窗口:1809

目标最小值:1803

target min : 1803

推荐答案

这是预期的行为。如文档所述,PaneDisplayMode是1809版的新版本。请参阅:https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/navigationview#display-modes

This is expected behavior. As documented, PaneDisplayMode is new for version 1809. See: https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/navigationview#display-modes

PaneDisplayMode属性需要Windows 10,版本1809( SDK 17763 )或更高版本,或
Windows UI库
The PaneDisplayMode property requires Windows 10, version 1809 (SDK 17763) or later, or the Windows UI Library.

这为您提供了两类解决方案:

This gives you two categories of solutions:

如果您的用户界面需要设置PaneDisplayMode,那么:

If setting PaneDisplayMode is needed for your UI then:


  • 使用Windows UI库中的Microsoft.UI.Xaml.NavigationPane控件而不是内置的Windows.UI.Xaml.NavigationPane控件

这将为您提供版本之间的一致用户界面。

This will give you a consistent UI between versions.

如果您的用户界面设置PaneDisplayMode不是必需的,或者您希望使用不同的用户界面每个版本然后(代码片段近似):

If setting PaneDisplayMode isn't essential for your UI or if you'd prefer to have different UI for each version then (code snippets approximate):


  • 根本不设置
  • 使用
    条件Xaml
    仅在定义了UniversalApiContract 7时设置它: 
  • Don't set it at all
  • Use Conditional Xaml to set it only if UniversalApiContract 7 is defined: 
<Page
    x:Class="ConditionalTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)">

    <NavigationView contract7Present:DisplayMode="Top" />

</Page>





  • 使用
    版本自适应代码
    ,用于检查PaneDisplayMode是否存在并从代码中调用它后面

    • Use Version adaptive code to check if PaneDisplayMode exists and call it from code behind
    • if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.NavigationView", "PaneDisplayMode")
      {
          myNavigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.Top;
      }
         

      - Rob


      这篇关于[UWP]支持两个版本的UWP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆