如何创建 TeachingTip?

How can I create TeachingTip?

我正在尝试以常规方式将 TeachingTip 添加到 Xaml 文件:

<TeachingTip/>

但是我得到一个错误 "The type 'TeachingTip' was not found"。

我尝试在 cpp 文件 (C++/CX) 中以编程方式添加:

TeachingTip^ tip = ref new TeachingTip();

错误是:"Identifier 'TeachingTip' is undefined".

所有其他控件运行良好。

TechingTip control is part of the Windows UI Library, not Windows. As such it resides in namespace Microsoft.UI.Xaml.Controls (as opposed to Windows.UI.Xaml.Controls). To reference that control in XAML, you'll have to use the correct namespace. Getting started with the Windows UI Library有详细说明

以下 XAML 片段应该有效:

<Page x:Class="..."
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
      ...
      >

    <muxc:TeachingTip/>

    ...
</Page>

同样,在代码中引用控件时,您必须指定正确的命名空间。