C#, VB, and C++ item templates for Store apps

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

Item templates are app files that contain commonly used code that can be added to a project template to reduce development time.

The item templates contain the appropriate references and script tags to support Windows Store apps and Windows Phone Store apps. Some of the item templates implement a contract, which is like an agreement that one or more apps can use specific APIs. When you add a contract template (File Open Picker Contract, Share Target Contract), the app manifest is updated with the appropriate declarations to notify Windows or Windows Phonethat your app supports this contract. You can see the settings for these declarations on the Declarations tab of the Manifest Designer.

You can add an item template to a project by right-clicking the project in Solution Explorer and then clicking Add > New Item.

Template descriptions

This table summarizes the types of item templates available in Visual C#, Visual Basic, or Visual C++ for Windows Runtime apps.

Template

Description

Requires common files

Pages

Basic Page

A minimal page, containing a title and a back button, that uses NavigationHelper.

Yes

Blank Page

A blank page.

No

Group Detail Page

A page that displays details for a single group and previews each item in the group.

Yes

Grouped Items Page

A page that displays item previews arranged in groups.

Yes

Hub Page

A page that displays item previews arranged in sections and that uses a varied presentation for each section.

Yes

Item Detail Page

A page that displays one item in detail along with navigation to adjacent items in the same group.

Yes

Items Page

A page that displays a collection of items.

Yes

Search results page

A page that supports displaying search results.

Yes

Split Page

A page that displays a list of items and the details for a selected item.

Yes

Note  

The navigation model used in the Page Control item templates is also used in the Hub, Grid, Split, and Navigation project templates. We recommend using this item template when you add pages to these project templates. For more info, see Quickstart: Navigating between pages.

 

 

Contracts
File Open Picker Contract An app contract that enables supplying files to other apps. This item template enables an app to expose its data as files to other apps. For example, you can use this template to create a photo picker dialog box from which the user can pick a photo from Facebook, even if the photo isn't stored on the local hard drive. For more info, see Integrating with file picker contracts. Yes
Share Target Contract An app contract that supports receiving items shared by other apps. This item template enables an app to coordinate data sharing among other apps. For example, you can use this template to enable users to post a photo from Flickr on Facebook. This template includes code that enables the app to receive shared content. The app that contains this item template is started when the app is selected in the share UI. For more information, see QuickStart: receiving shared content. Yes

 

Other
Resource Dictionary An empty, keyed collection of XAML resources. No
Resources File (.resw) A file for storing string and conditional resources for your application. To help localize a Windows Store app, you can add one or more Resources File item templates to your project. For more info, see Globalizing your app. No
Settings Flyout A blank Settings Flyout page. No
Templated Control A blank custom control with the appropriate default styling. No
User Control A blank user control. No

 

Adding required files

Some of the Windows Store and Windows Phone item templates defined above are complex pages and have dependencies on NavigationHelper, SuspensionManager, and other common files included in the project templates. These files are located in the Common folder that's automatically added when you create an app using the Hub App, Grid App, or Split App project templates. If any of the required references can't be found, you'll be prompted to add the required files.

Note  The required files vary depending on the specific item template you are adding. The complete list of common files includes: NavigationHelper, SuspensionManager, RelayCommand, BooleanNegationConverter, and BooleanToVisibilityConverter. For more info on these files, see C#/VB/C++ project templates for Windows Store apps.

 

The following table provides info on how to proceed when prompted to add required files.

Action Why choose this? What happens?
Yes
  • You created your app from the Blank App project template. None of the common items are added by default, and this is the only way to add them automatically.
  • You removed a few of the files in the Common folder because you weren't using them. But the newly added item might require the removed files and you want to add them again.

The required dependencies are added to the Common folder. If the folder already exists, all missing items are added. No existing files are modified. If the folder doesn't exist, it's created and all items are added to it.

No
  • The required files already exist but you have renamed the files or classes.
  • You reorganized your project and moved the files from the Common folder to another location, such as different folders or a linked class library.

The new item is added. No other files are added or modified.

Cancel
  • You decide that you no longer want the item to be added.

The project isn't changed, and the item isn't added.

 

C#/VB/C++ project templates for Windows Store apps

Adding a Page Control item template (using C#/VB/C++ and XAML)

Adding a Search Contract item template (using C#/VB/C++ and XAML)