Xaml &引用;标签';MenuItem';在XML命名空间中不存在';clr命名空间:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit'&引用;错误

Xaml &引用;标签';MenuItem';在XML命名空间中不存在';clr命名空间:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit'&引用;错误,xaml,silverlight-4.0,silverlight-toolkit,silverlight-5.0,Xaml,Silverlight 4.0,Silverlight Toolkit,Silverlight 5.0,尝试在新机器上构建Silverlight应用程序时出错。(Silverlight 4,Visual Studio 2010)此应用程序在其他四台计算机上编译时不会出错 错误是: the tag 'MenuItem' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit'. 引用似乎是指向正确程序集的指针。其他人有

尝试在新机器上构建Silverlight应用程序时出错。(Silverlight 4,Visual Studio 2010)此应用程序在其他四台计算机上编译时不会出错

错误是:

the tag 'MenuItem' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit'. 

引用似乎是指向正确程序集的指针。其他人有过此问题吗?

看起来您缺少该计算机上的,但它已安装在其他四台计算机上。

出现此问题的另一个原因是缺少对使用工具箱控件部分所需的所有“三个”程序集的引用

如果试图使用工具箱输入(并假设主题也可能),请确保您引用了以下程序集

这解决了我遇到的与错误相关的问题。


它是SL5中重新编译的工具包,只要参考它们,您就可以设置

您可以随时使用代码创建上下文菜单

public LedgerEntryControl()
{
    InitializeComponent();

    ContextMenu contextMenu = new ContextMenu();
    MenuItem voidMenuItem = new MenuItem() { Header = "Void" };
    voidMenuItem.SetBinding(MenuItem.CommandProperty, new Binding("Void"));
    contextMenu.Items.Add(voidMenuItem);
    ContextMenuService.SetContextMenu(this, contextMenu);
}

出于某种原因,NuGet Package Manager提供的SilverLight工具包适用于SL4,即使项目设置为SL5也是如此。您可以直接从CodePlex。请注意,日期是2011年12月,而不像SL4版本那样是2011年2月

如果由于某种原因,MSI没有安装(这发生在我身上),您可以使用提取MSI中包含的文件。我所要做的就是从提取的文件中手动添加对
System.Windows.Controls.Input.Toolkit.dll
的引用,现在我的SL5项目通过其NumericUpDown控件成功编译。令人高兴的是,我的程序现在可以在发布和调试模式下编译

另外,对于那些还没有这样做的人,您可能需要在XAML中有一个对正确工具包的引用。我使用了以下方法:

<sdk:Page xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" ... >

在新机器上安装Silverlight Toolkit。Silverlight 5和最新的Silverlight Toolkit就是这样。所有三个程序集(SYstem.Windows.Controls、SYstem.Windows.Controls.Input.Toolkit和SYstem.Windows.Controls.Toolkit)都被引用。MenuItem也出现在Intellisense中。另请参见此处和另一个类似的问题,即“连接另一个工具箱”控件。我尝试在Silverlight 5下重建Silverlight控件示例并得到相同的警告,但该示例仍然有效。看起来Silverlight工具包已经安装。在Silverlight.dll中运行时,会显示对MenuItem的引用。另外,应用程序的另一部分是使用MenuItem,但使用C#代码创建它。此编译错误仅在XAML中引用MenuItem时发生。您需要:Silverlight SDK客户端库中的System.Windows.Controls、Silverlight工具箱中的System.Windows.Controls.Input.Toolkit和Silverlight工具箱中的System.Windows.Controls.Toolkit。谢谢,这为我解决了问题。我没有引用
System.Windows.Controls
DLL;当我添加引用时,它修复了神秘的错误。
<sdk:Page xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" ... >
<input:NumericUpDown x:Name="myControl" ... />