标记“功能区”在 XML 命名空间中不存在

本文关键字:功能区 命名空间 XML 不存在 标记 | 更新日期: 2023-09-27 18:35:04

我正在尝试在.Net 4.5框架上开发一个带有功能区控制的WPF应用程序。据我所知,MSDN 功能区类现在包含在 Net 4.5 框架中,因此,我不再需要添加它。

但是当我尝试添加此代码时:

<Window x:Class="WpfApplication2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <StackPanel>
        <Ribbon>
        </Ribbon>
    </StackPanel>
</Window>

我收到以下错误。我错过了什么吗?

The tag 'Ribbon' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

编辑:

using System.Windows.Controls.Ribbon;

也不起作用。

The type or namespace name 'Ribbon' does not exist in the namespace 'System.Windows.Controls' (are you missing an assembly reference?)  c:'tmp'tst2'tst2'MainWindow.xaml.cs

标记“功能区”在 XML 命名空间中不存在

您需要

添加对System.Windows.Controls.Ribbon.dll(这是.NET 4.5框架的一部分)的引用。然后,需要将命名空间添加到 XAML,如下所示:

xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"

到你的窗口获取命名空间,然后你可以像这样使用它

<ribbon:Ribbon ... />

就像科尔约翰逊说的那样。

下面是功能区类上的 MSDN 参考,其中显示了所有这些信息。

它是

<功能区:功能区>

您还需要参考功能区的方案