【发布时间】:2025-12-29 10:40:12
【问题描述】:
说明: 我正在开发一个解决方案,在该解决方案中,我将使用我想要添加的表单调用模板项。
我想知道这是最好的解决方案还是有其他方法。
我的项目
代码:calss1.vstemplate
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>class1.cs</DefaultName>
<Name>Myproject class1</Name>
<Description>Myproject Class</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>Myprojectclass1.png</Icon>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
<Reference>
<Assembly>System.Linq</Assembly>
</Reference>
<Reference>
<Assembly>System.Threading.Tasks</Assembly>
</Reference>
</References>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">class1.cs</ProjectItem>
<CustomParameters>
<CustomParameter Name="$username$" Value="$safeitemrootname$"/>
<CustomParameter Name="$rootnamespace$" Value="$safeitemrootname$"/>
<CustomParameter Name="$registeredorganization$" Value="$safeitemrootname$"/>
</CustomParameters>
</TemplateContent>
//Call my Form
<WizardExtension>
<Assembly>MyProjectWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f7a1fcb8d457e160</Assembly>
<FullClassName>MyProjectWizard.WizardImplementation</FullClassName>
</WizardExtension>
</VSTemplate>
这种方法有效吗? 还有其他方法吗?
【问题讨论】:
-
有效吗?乍一看,这看起来像是我过去的做法,但我无法从屏幕截图和 xml 文件中告诉你它是否完全正确。
-
是的,它有效,我为我想要的项目调用表单,只是想知道是否有其他方法。
-
或者我想知道这个方法是不是调用模板项的最佳方式。
-
据我所知,使用向导是为 VS 模板提供自定义 UI 的唯一方法。
-
在创建项目时,我使用向导创建类/项,我的问题是当我尝试添加新类/项时,我想调用同一个向导来添加更多类/项.
标签: c# visual-studio wizard vsix itemtemplate