Search code examples
silverlightsilverlight-toolkitexpander

Getting the exception "The type 'Expander' was not found"


I have something like this in my Silverlight application:

<navigation:Page x:Class="PPCa.Modules.ProjectManager.Client.Views.ProjectDetailView" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
                 xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" 
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:controls="clr-namespace:PPCa.Common.Infrastructure.Controls;assembly=PPCa.Common.Infrastructure"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" 
                 mc:Ignorable="d"
                 d:DesignHeight="768"
                 d:DesignWidth="1024"
                 Title="ProjectDetailView Page">
    <toolkit:Expander>
    </toolkit:Expander>
</navigation:Page>

It compiles fine, but I get the exception "The type 'Expander' was not found." When I run the application and navigate to the page.

Edits:

I've tried changing the toolkit namespace to:

xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"

and now it still compiles and I get the exception:

The type 'Expander' was not found because 'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit' is an unknown namespace.

Further Edits:

All I had to do was name them. Oddly enough, giving each Expander control a name fixed the problem. Anyone know why this could be?


Solution

  • Since your references seem fine, double check that the Expander class exists in the System.Windows.Controls namespace by viewing the objects in the object browser. If it does, try removing the reference and recompiling. You should receive an error (which is a good thing). If you don't, there must be some other reference somewhere. After removing all references so a compile error is thrown, readd the reference to the System.Windows.Controls.Toolkit dll. It should be the v2.0.50727 and be available from the GAC if everything (Toolkit, SDK, Silverlight) are installed correctly.