10

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?

Jedidja
  • 16,610
  • 17
  • 73
  • 112
Ron
  • 121
  • 1
  • 4
  • Install the Silverlight Toolkit on the new machine. – Gabe Dec 22 '10 at 22:43
  • 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 Jun 04 '11 at 19:11
  • See also here http://forums.silverlight.net/forums/p/221036/560937.aspx – Jedidja Jun 04 '11 at 19:14
  • And another similar issue on Connect with another Toolkit control. http://connect.microsoft.com/VisualStudio/feedback/details/664106/silverlight-forum-sl5-numericupdown-control-compile-error – Jedidja Jun 04 '11 at 19:14
  • I tried rebuilding the Silverlight Control Samples under Silverlight 5 and get the same warning, but the sample still works. – Jedidja Jun 09 '11 at 15:44
  • For anyone trying this in Silverlight 5, rebuilding the Toolkit specifically for v5 fixes this problem. – Jedidja Jun 09 '11 at 16:10

5 Answers5

3

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.

Dan
  • 1,396
  • 1
  • 10
  • 21
  • You need: System.Windows.Controls from the Silverlight SDK client library, System.Windows.Controls.Input.Toolkit form the Silverlight toolkit, and System.Windows.Controls.Toolkit from the Silverlight toolkit. – mike gold Mar 29 '11 at 21:23
  • Thanks, this fixed the problem for me. I wasn't referencing the `System.Windows.Controls` DLL; when I added that reference, it fixed the mystery error. – McGarnagle Aug 31 '12 at 19:26
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

sLedgem
  • 501
  • 2
  • 11
1

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);
}
Michael L Perry
  • 7,327
  • 3
  • 35
  • 34
0

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" ... />
Michael
  • 2,268
  • 20
  • 24
0

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

vlad
  • 4,748
  • 2
  • 30
  • 36
  • 2
    It looks like the Silverlight toolkit is installed. Running through the Silverlight .DLLs, the references to MenuItem show up. Also, another part of the application is using MenuItem, but creating it in C# code. This compile error only happens when MenuItem is referenced in XAML. – Ron Feb 25 '11 at 15:17