views:

39

answers:

2

I'm creating a class library that makes available some XAML windows (in theory). To create the XAML, I right clicked on the project and then clicked Add->New Item, and then specified Window (WPF). I then created my XAML, which I had already prototyped in a stand alone application. However, when I go to build my project, I get the following error:

The type name 'MyWindow' does not exist in the type 'MyProjectName.MyProjectName'

The header of my XAML looks like the following:

<Window x:Class="MyProjectName.MyWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MyWindow" WindowStyle="ToolWindow" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Height="300" Width="300">

Unfortunately, it says the error is occurring on line 4 column 25, which ends up being the following unhelpful snippet w" WindowStyle= in the XAML.

The build action for the XAML is Page. What does this error mean and how can I fix it so my windows are available in the class library?

A: 

Well, the first thing that pops to mind. Are you sure you added a project reference from your WPF executable to the library?

Joel Martinez
The errors occur when I am building the class library, so not sure why adding references to the library that doesn't build would solve the problem.
Andrew Austin
+1  A: 

You have a class with the same name as its namespace, which you can do with code-only, but not with XAML-only or XAML+code.

Change the class name or the namespace.

Jay