This is very strange.
I have an XAML file that looks as follows...
I become unable to find InitializeComponent, and other XAML-related UI bits from the code behind the moment I add my PCL (which contains my data classes) into the solution.
:|
But if I remove the PCL one .. it can be found again.
Regardless, whether its found or not - I can still compile. I just can't autocomplete when i type code.
Maybe you have a PCL project in your solution? (I don't know how to fix this yet)
Looks like this was a kink in Visual Studio 2008.
If I create a new file (i.e. Title2), copy/paste the code and XAML, then change all 'Title' to 'Title2', everything works fine again.
This happened to me because Visual Studio sets the "Build action" to some random action when you copy/paste or move an XAML file from one project to another within a solution.
Solution: Make sure your "Build action" is set to page for you XAML.
I hope this helps if it's the same case for you.
I had the same problem with a Visual Studio 2010 sample project that I manually reverted to Visual Studio 2008. I found I had forgotten to set the Target Framework of the project to .NET Framework 3.5. It was empty in the project reverted to Visual Studio 2008, initially set to 4.0 in the original Visual Studio 2010 project.
To set Target Framework of a project, go to project properties, access the first tab called Application, and select .NET Framework 3.5 in the Target Framework dropdown.
Of course, I'd prefer Visual Studio giving me an error or at least a warning that I had not set my Target Framework, but hey, that's part of developing in Visual Studio, I guess.
When namespaces are all correct changing the target platform from x86 to x64 or vice versa and rebuilding the project often does the trick.
I had come across the same problem when i got a project sample from msdn. the issue was it was a 4.0 project and i did not have the 4.0 in my system, couple of referenced dlls were missing(system.xaml and another one) removed them. tried to compile, would always throw the initializecomponent method not found. went into the project properties changed the target framework to 3.5 and it is not complaining anymore.