自定义 ItemTemplate 未显示在 Visual Studio 2010 中 - 添加新项目 [英] Custom ItemTemplate not showing up in Visual Studio 2010 - Add New Item

查看:28
本文介绍了自定义 ItemTemplate 未显示在 Visual Studio 2010 中 - 添加新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前在 VS2005/2010 中创建过 ItemTemplates,从来没有遇到过任何问题.

I have created ItemTemplates before in VS2005/2010 and never had any problem.

在 Windows8 上使用 VS 2012 Ultimate 版时,我创建的 ItemTemplate 没有显示在添加新项目列表中.

With VS 2012 Ultimate edition on Windows8, the ItemTemplate I am creating isn't showing up in the Add New Item list.

仅尝试了此处提到的基本步骤:http://msdn.microsoft.com/en-us/library/tsyyf0yh.aspx

Tried just the basic steps mentioned here: http://msdn.microsoft.com/en-us/library/tsyyf0yh.aspx

创建了一个新的 Windows 8 Store App(xaml) 空白项目.它有一个主页.我在主页上添加了一个 TextBlock 以使其看起来不同.然后导出模板.

Created a new Windows 8 Store App(xaml) Blank Project. It has a MainPage. I added a TextBlock to the mainpage to make it look different. Then exported the template.

.zip 文件被添加到 ItemTemplates 文件夹和我的导出模板文件夹,但不会显示在列表中.我确实重新启动了我的 VS 几次,但没有重启.

The .zip file gets added to the ItemTemplates folder and My Exported Templates folder but won't show up in the list. I did restart my VS several times but no go.

有什么想法吗?我想知道我是否缺少一些 VS 选项?

Any idea? I wonder if I am missing some VS option?

推荐答案

我不确定这是 VS2012 中的错误还是我遗漏了什么,但这是我如何能够在添加新项目"菜单中显示我的模板.

I am not sure if it's a bug in VS2012 or I missed something but here's how I was able to get my Template showing up in the Add New Item menu.

1:我解压了最初创建的模板.

1: I unzipped my Template created initially.

2:打开 Visual Studio 2012 自带的默认模板.

2: Opened an default Template that comes with Visual Studio 2012.

C:\Program Files (x86)\Microsoft Visual Studio11.0\Common7\IDE\ItemTemplates\CSharp\Windows Store\1033\BlankPage

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Windows Store\1033\BlankPage

3:将 BlankPage.vstemplate 与 MyTemplate.vstemplate 进行比较.让我的模板文件看起来像这样:

3: Compared the BlankPage.vstemplate with MyTemplate.vstemplate. Made my template file look like this:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
  <TemplateData>
    <DefaultName>CustomStoryPage.xaml</DefaultName>
    <Name>CustomStoryPage</Name>
    <Description>Template for custom storypage</Description>
    <TemplateID>Microsoft.CS.WinRT.CustomStoryPage</TemplateID>
    <TemplateGroupID>WinRT-Managed</TemplateGroupID>
    <ProjectType>CSharp</ProjectType>
    <SortOrder>10</SortOrder>
    <TargetPlatformName>Windows</TargetPlatformName>
    <RequiredPlatformVersion>8</RequiredPlatformVersion>
  </TemplateData>
  <TemplateContent>
    <References />
    <ProjectItem ItemType="Page" SubType="Designer" CustomTool="MSBuild:Compile" TargetFileName="$fileinputname$.xaml" ReplaceParameters="true">StoryPageTemplate.xaml</ProjectItem>
    <ProjectItem SubType="Code" TargetFileName="$fileinputname$.xaml.cs" ReplaceParameters="true">StoryPageTemplate.xaml.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>

4:再次压缩文件夹.

上面的某些内容可能是不必要的,但现在我已经解决了我的问题.我需要一一搞清楚到底需要哪些物品.

Some stuff might be unnecessary above but for now I have my issue fixed. I need to do one by one to find out what exactly are required items.

这篇关于自定义 ItemTemplate 未显示在 Visual Studio 2010 中 - 添加新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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