项目模板中的嵌套文件

编程入门 行业动态 更新时间:2024-10-23 19:29:27
本文介绍了项目模板中的嵌套文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试创建一个 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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 13:15:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1154909.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   模板   文件   项目

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!