Silverlight: Fixing the "Tag Expander Does Not Exist" Compiler Error

If you create a new Silverlight Navigation project, then compile immediately with no changes, you will get the following compiler error:

The tag ‘Expander’ does not exist in XML namespace ‘clr-namespace:System.Windows.Controls;assenbly=System.Windows.Controls’

This is because the Expander element (as well as DockPanel, WrapPanel, HeaderedContentControl, Viewbox, and DataForm have been moved to the Silverlight Toolkit.

To fix this problem:

1. If you haven’t already done so, download and install the Silverlight Toolkit (http://www.codeplex.com/Silverlight)

2. Add the System.Windows.Controls.Toolkit assembly to your project

3. Add the following namespace reference to the top of your project’s ErrorWindow.xaml file:

xmlns:controlsToolkit=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit”4.

4. In the body of the ErrorWindow.xaml file, change the prefix of the Expander control from “controls” to “controlsToolkit”. Remember to do this on both the opening and closing tags:

<controlsToolkit:Expander Grid.Row=”2″ Header=”Details” Margin=”0, 10, 0, 0″ >

   <TextBox Text=”{Binding ErrorDetails}”
Height=”100″
TextWrapping=”Wrap” IsReadOnly=”True”
VerticalScrollBarVisibility=”Auto” />

</controlsToolkit:Expander>

Best Regards,
Kevin McNeish
INETA Speaker
Chieft Architect, MM .NET Application Framework
www.oakleafsd.com

Leave a Reply

Your email address will not be published. Required fields are marked *