问题描述
限时送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:关键词]
发布评论