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.
Actually helped me; I was pulling my hair out not noticing there is the difference in the top tag.
Thanks very much, fixed major problems on a C# to VB WPF conversion.
Thanks! That fixed the problem I was having when I copied some Xaml from one Silverlight project to another.
Thanks. I was scratching my head on this one.
Another possible solution for this is to reset the namespace cache. Go to Project in the menu, and to [Name of your project ] Properties… at the bottom.
Where it says Root namespace: , clear the textbox and press Save.
Once it has saved (it can take a few seconds), rebuild your project. It will fail to rebuild.
Next go back to the properties, and put the namespace back to what it was before. Hit save, rebuild, and with any luck Visual Studio will have fixed your issues.
Thanks, this was the best solution. Quick and actually fixed the problem. Please keep up the good work! Cheers, Parveen