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

♀尐吖头ヾ 提交于 2019-12-23 07:26:34

问题


I'm getting an error trying to build a Silverlight application on a new machine. (Silverlight 4, Visual Studio 2010) This application compiles without error on four other machines.

The error is:

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

The references appear to be pointer to the correct assemblies. Has anyone else ever had this problem?


回答1:


Another reason this issue may occur is due to missing a reference to all "three" assemblies required to use the portions of the the Toolkit controls.

Make sure you have reference to the following assemblies if attempting to use the Toolkit inputs (and assuming the themes also possibly).

System.Windows.Controls
System.Windows.Controls.Toolkit
System.Windows.Controls.Input.Toolkit

This solved the problem I was having in relation to the error.




回答2:


http://marktinderholt.wordpress.com/2011/07/12/silverlight-toolkit-for-silverlight-5-beta

its the recompiled toolkit in SL5, just reference those and you're set




回答3:


You can always fall back on creating the context menu in code.

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);
}



回答4:


looks like you're missing the Silverlight Toolkit on that machine, but it's installed on the four other ones.




回答5:


For some reason, the SilverLight Toolkit from NuGet Package Manager is for SL4, even when the project is set to SL5. You can download the SL5 version directly from CodePlex. Note that the date is December 2011, instead of February 2011 like the SL4 version.

If for some reason the MSI does not install (which happened to me), you can extract the files contained in the MSI using 7-zip. All I had to do was manually add a reference to System.Windows.Controls.Input.Toolkit.dll from the extracted files, and my SL5 project now compiles successfully with its NumericUpDown control. Happily, my program now compiles both in Release and Debug mode.

Also to add, for those who have not already done so, you may need to have a reference in the XAML to the correct toolkit. I used the following:

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

Note that the first part, where is says input, is what needs to be typed in the XAML to use the control:

<input:NumericUpDown x:Name="myControl" ... />


来源:https://stackoverflow.com/questions/4514388/the-tag-menuitem-does-not-exist-in-xml-namespace-clr-namespacesystem-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!