开发者

How do I make WPF windows available in a class library?

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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜