Silverlight “Name ‘InitializeComponent’ is not declared”
Posted by anoriginalidea on July 1, 2009
It is quite common in Webforms, Winforms and other environements to copy user interface views from one project to another.
When you copy xaml files from one Silverlight project to another you may experience the error:
“Name ‘InitializeComponent’ is not declared”
This happens because the “x:Class” directive in the top of the xaml file includes the project namespace.
So, open up your xaml file, and change this:
x:Class=”PreviousProject.YourClass”
To the new project namespace:
x:Class=”NewProject.YourClass”
Oh and BTW…..ITS CASE SENSITIVE!
I know this isn’t much of a post, but hopefully it will provide a useful search engine hit for the desperate.


san said
Actually helped me; I was pulling my hair out not noticing there is the difference in the top tag.
NPSF3000 said
Thanks very much, fixed major problems on a C# to VB WPF conversion.
slapout said
Thanks! That fixed the problem I was having when I copied some Xaml from one Silverlight project to another.
Alan J said
Thanks. I was scratching my head on this one.