项目模板中的嵌套文件 [英] Nested Files in Item Template

查看:17
本文介绍了项目模板中的嵌套文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 Visual Studio 项目模板,该模板将创建一个 WPF 窗口,其中包含一个视图模型的附加文件

I am trying to create a Visual Studio Item Template that will create a WPF Window with an attached file for a view model

喜欢下面的

VMWindow.xaml---VMWindow.xaml.cs---VMWindow.vm.cs

VMWindow.xaml ---VMWindow.xaml.cs ---VMWindow.vm.cs

我可以使用以下 .vstemplate 文件创建模板

I am able to create the template with the following .vstemplate file

<VSTemplate Type="Item" Version="2.0.0"
    xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Viewmodel Dialog Box</Name>
    <Description>Viewmodel Dialog Box</Description>
    <Icon>Icon.ico</Icon>
    <ProjectType>CSharp</ProjectType>
    <DefaultName>VMDialog</DefaultName>
  </TemplateData>
  <TemplateContent>
    <ProjectItem TargetFileName="$fileinputname$.xaml" SubType="Window">ViewModelDialogTemplate.xaml</ProjectItem>
    <ProjectItem TargetFileName="$fileinputname$.xaml.cs">ViewModelDialogTemplate.xaml.cs</ProjectItem>
    <ProjectItem TargetFileName="$fileinputname$.vm.cs">ViewModelDialogTemplate.vm.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>

我希望模板在解决方案资源管理器中显示时使用嵌套在主窗口文件中的 .vm.cs 文件创建自己.

I would like for the template to create itself with the .vm.cs file nested inside the main Window file when displayed in Solution Explorer.

我找到了以下方法,但我在使用 Visual Studio 2010 时遇到了问题.2008 年写的,现在还适用吗?

I have found the following howto, I am having trouble following it with Visual Studio 2010 though. It was written in 2008, does this still apply?

代码项目文章

推荐答案

事实证明,同样的方法适用于 VS 2010.需要一些调整,但这 代码项目文章涵盖了基本思想.

As it turns out the same method works for VS 2010. Required a bit of adaptation but this Code Project article covers the basic idea.

这篇关于项目模板中的嵌套文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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