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.Comm开发者_如何学运维on.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?
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.
I had the same problem with the C1Expander class. Giving the control a name didn't work for me. Initially, I used the namespace
xmlns:c1Ext="clr-namespace:C1.Silverlight.Extended;assembly=C1.Silverlight.Extended.5"
Using a different namespace name
xmlns:ComponentOneExtensions="clr-namespace:C1.Silverlight.Extended;assembly=C1.Silverlight.Extended.5"
instead fixed it. Note that only the name changed an not the clr-namespace stuff. Don't know why though...
Just Added a x:Name"controlName" to control from other assembly and bingo..Its working just completely fine. Can anybody explain the behavior.?
Had simlar issue with DataGrid. Adding x:Name also works for me.
精彩评论