如何将WPF窗口添加到类库项目 [英] How to add a WPF Window to a Class Library Project

查看:49
本文介绍了如何将WPF窗口添加到类库项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天遇到了这个问题,我想将WPF窗口添加到我现有的类库项目中,但是添加新项"列表中不存在该窗口.

I came across this problem today where I wanted to add a WPF Window to my existing class library project but it didn't exist in the Add New Item list.

我找到了一个解决方案,只想将其发布在这里,因为我在其他地方找不到它.

I found a solution and just wanted to post it here as i couldn't find it elsewhere.

推荐答案

解决方案是在文本编辑器(如记事本)中打开.csproj.

The solution is to open the .csproj in a text editor like notepad.

在第一个PropertyGroup xml标记下添加以下行.

Add the following line under the first PropertyGroup xml tag.

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

保存更改并重新加载项目.现在,该项目将能够正常添加WPF Windows.

Save the changes and reload the project. The project will now be able to add WPF Windows as normal.

完整的PropertyGroup xml应该如下所示:

The complete PropertyGroup xml should look something like this:

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{11EE2F8C-DFCF-451D-BA3E-84A4FB858848}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>TestApp</RootNamespace>
    <AssemblyName>TestApp</AssemblyName>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
  </PropertyGroup>

这篇关于如何将WPF窗口添加到类库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆