10
votes

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?

5
Install the Silverlight Toolkit on the new machine.Gabe
This is happening with Silverlight 5 and the latest Silverlight Toolkit. All three assemblies (SYstem.Windows.Controls, System.Windows.Controls.Input.Toolkit and System.Windows.Controls.Toolkit) are referenced. MenuItem appears in Intellisense as well.Jedidja
And another similar issue on Connect with another Toolkit control. connect.microsoft.com/VisualStudio/feedback/details/664106/…Jedidja
I tried rebuilding the Silverlight Control Samples under Silverlight 5 and get the same warning, but the sample still works.Jedidja

5 Answers

3
votes

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
votes
1
votes

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

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

0
votes

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" ... />