C#, VB, and C++ project templates for Store apps
Learn how Microsoft Visual Studio project templates can help you create apps for the Windows and Windows Phone 8.1. This topic describes each template, and helps you choose one.
To learn about project templates for Blend for Visual Studio, see Create a new project.
To get the templates, you need a version of Visual Studio that supports Windows development. For more info, see Get the Tools.
Important The information in this topic has been updated for Windows 8.1. For information on migrating to the new templates, see Windows 8 to Windows 8.1 for XAML developers and Retarget your Windows 8 app to Windows 8.1.
Roadmap: How does this topic relate to others? See these topics:
The New Project dialog box organizes templates into three groups: Windows Apps, Windows Phone Apps, and Universal Apps. This image shows each group. To learn more about each of them, see Choose what type of app you want to build.
Each group contains a list of templates. Although templates appear in a single list, you can think of these templates as belonging to one of the following categories.
- Templates that you use to create an app.
- Templates that you use to build pieces of an app.
- Templates that you can use to test your app.
You'll typically start with one of these templates.
|Blank||A project for a single-page Windows Store app or Windows Phone Store app that has no predefined controls or layout. Use this template if you want to build an app from the ground up without any starter code or XAML.|
Important Blank projects don't handle the back button of a Windows Phone. By default, the app closes when users press that button. If you create a Blank project for a Windows Phone Store app, please see Handling the back button of a phone in Blank projects.
|Hub||A project for a three-page Windows Store app or Windows Phone Store app that uses a Hub control. Dedicated pages display group and item details. |
For more information, see Hub.
|Grid||A project for a three-page Windows Store app or Windows Phone Store app that navigates among grouped items arranged in a grid. Dedicated pages display group and item details.|
For more information, see Grid.
|Split||A project for a two-page Windows Store app or Windows Phone Store app that navigates among grouped items. the first page allows group selection while the second displays an item list alongside details for the selected item.|
For more information, see Split.
|Pivot||A project for a Windows Phone Store app that uses a Pivot control and the Windows Runtime.|
For more information, see Pivot.
|WebView||A project for a Windows Phone Store app that uses a WebView control and the Windows Runtime.|
For more information about the WebView control, see Webview
|DirectX||A project for a Windows Store app or Windows Phone Store app that uses DirectX and the Windows Runtime.|
For more information, see Use the Microsoft Visual Studio 2013 DirectX templates..
|DirectX and XAML||A project for a Windows Store app or Windows Phone Store app that uses DirectX, XAML, and the Windows Runtime.|
For more information, see Use the Microsoft Visual Studio 2013 DirectX templates.
Note The names of some templates have (Windows Phone Silverlight) appended to the end. Consider using these templates if you've previously developed for Windows Phone 8 and just want to access some of the new features available to Windows Phone apps without having to significantly modify your existing code. For more information about these templates and why you might use them, see Silverlight 8.1 apps for Windows Phone.
As your app becomes more sophisticated, you might decide to add functionality as components by using one of these templates.
|DLL||(C++ only) A project for a native dynamic-link library (DLL) that can be used by a Windows Store app, Windows Phone Store app, or Windows Runtime component that is written in C++.|
For more information, see DLLs in Visual C++.
|Static Library||(C++ only) A project for a native static link library (LIB) that can be used by a Windows Store app, Windows Phone Store app, or Windows Runtime component that is written in C++.|
For more information, see Walkthrough: Creating and Using a Static Library (C++).
|Class Library||A project for creating a managed class library (.dll) for Windows Store apps or Windows Phone Store apps that are written in C# or Visual Basic.|
|Class Library (Portable)||A project for creating a managed class library (.dll) for Windows Store apps, Windows Phone Store apps, and Silverlight apps that are written in C# or Visual Basic.|
For more information, see Cross-Platform Development with the .NET Framework.
|Windows Runtime Component||A project for creating either a C++ or managed Windows Runtime component that can be consumed by any Windows Store app, regardless of the programming language in which the app is written.
For more information, see Creating Windows Runtime Components.
As you get closer to publishing your app, you might consider using one of these templates to optimize performance and code quality.
|Unit Test Library||A project that contains unit tests that can be used to test Windows Store apps, Windows Runtime components, or class libraries for Windows Store apps.|
For more information, see Create and run unit tests for a Windows Store app in Visual Studio.
|Coded UI Test||A project that contains Coded UI tests for automated UI Testing of Windows Store apps.|
For more information, see Verifying Code by Using UI Automation.
Unless you start with a Blank template and build your app from scratch, you'll probably get started by using a Hub, Grid, Split, Pivot, or project template. Here's a closer look at each one.
If you want to learn more about how to use the DirectX and DirectX and XAML templates, see Use the Microsoft Visual Studio 2013 DirectX templates.
The Hub template is similar to the Panorama template in Windows Phone 8.
Use this template to display content in a horizontally panning view that provides a variety of ways to access content.
The main Hub page organizes content into sections such as new items, highlighted items, and categories of items. This template is a great fit for a shopping, news, sports, or media hub app.
If the user taps an interactive section heading (indicated by a ">"), the app opens the section page, which lists the items from that section. If they choose an item from the home page or section page, a full-page view shows details about the item. This image shows the home page of a Hub app that has at least three sections.
These sections that appear in the designer are examples of the sort of content that you could display. You can easily add and remove sections so that your app shows the content that you want and in the way that you want.
The sections of the template include static content, so you can easily provide globalized resources. The sample resource file provides localized strings for the en-us locale.
You see example of how you can use Hub project template to help users shop for real estate, see Quickstart: Read data from a service..
The Grid App template is another way to enable users to browse through categories of content. This template is a great fit for a shopping, news, photo, or video app.
The Grid app shows a list of groups. If the user selects a group, the app opens the group details page, which displays a list of the items on the right side. The user can select an item on the home page or group details page. This opens a full-page view that can be used to show the item details. This image shows the home page of a Grid app.
The Split App template shows a list of items and item details in a two-column view. Users can switch quickly between the items and view information in lists that might be updated dynamically. This template is a great fit for a news reader, sports score or email app.
The Split app template shows a list of groups. When the user selects a group by tapping or clicking it, the app opens the split-view page. This image shows the split-view page.
The split-view page displays a two-column view (or master/detail view), where the details on the right side change when a user selects an item on the left side. Imagine a list of news stories on the left side and the actual stories on the right side.
A Pivot app template provides a quick way to manage views or pages. It can be used for filtering large data sets, viewing multiple data sets, or switching app views. For example, flicking or panning left to right on the page advances to the next page of content. This image shows the home page of the Pivot app.
Blank projects don't handle the back button of a Windows Phone. By default, the app closes when a user presses the back button.
Other project templates handle the back button with the use of the NavigationHelper .cs|.vb|.cpp|.h file. To get a copy of the NavigationHelper .cs|.vb|.cpp|.h file, add a Basic Page to your project.
After your project contains the NavigationHelper .cs|.vb|.cpp|.h file, you can delete the Basic page from your project if you don't want it. Then, to handle the back button of a Windows Phone, add a private field named navigationHelper of type NavigationHelper to the Blank page. Then, add the following line of code to the constructor of the Blank page:
Pages in the Hub, Grid, Split, Pivot already implement navigation, state management and data binding.
The navigation model that the template uses is the recommended navigation model for apps using C++, C#, or Visual Basic. In this model, XAML pages get loaded into a central frame as the content of the default Window, and then users navigate to other pages using that frame. The pages are loaded as needed, typically in response to user actions. Web developers often refer to this type of navigation model as single-page navigation.
The navigation model is implemented in Common\NavigationHelper. The single-page navigation model provides a smoother, app-like transition between pages, and also makes it easier to manage app state through the single app-wide context.
The navigation model enables your app to maintain multiple states. For example, suppose a user starts a music app from a primary tile, selects an artist, and then closes the app. Then, the user starts the music app by clicking the tile for a specific song. The user plays a song, pauses the music player, and closes the app.
The user can return to the artist page by clicking the primary tile. The user can continue listening to their song by clicking the secondary tile. The state of both sessions are preserved independent of one another.
While the templates provide the infrastructure for this scenario, you'll still have to write a little code.
Other project templates such as the Blank template do not include this NavigationHelper file. For that template, you'll have to add the NavigationHelper project file manually or implement custom navigation.
For more info on navigation and an example of using single-page navigation in Windows Store app using C++, C#, or Visual Basic, see Quickstart: Navigating between pages.
The Hub, Grid, and Split, and Pivot App project templates contain a sample data file and classes that help you show data from that file when you run the app. That data also appears in pages as you design them. You can find these classes and the sample data file in the Data Model folder of your solution.
Data is organized into items and groups. Each page has its own collection of name value pairs called a view model. The controls in each page are bound to information in that view model. To see how you can plug your data into this model see either of these topics:
Code in the pages of your solution obtains information from the data classes in your Data Model folder and
After you create your project, the pages of your app appear in Solution Explorer. For example, if you a project based on the Hub app template, you'll see three xaml pages: a home page that shows sections of items (HubPage.xaml), a page that shows a category of items (SectionPage.xaml), and a page that shows the full-page view for an item (ItemPage.xaml).
Each page has a code-behind file that implements various behavioral aspects of the page. The following table describes several other files that your solution might contain depending on what type of project you create.
|BooleanNegationConverter .cs|.vb|.cpp|.h||Converter for use in XAML. This file negates a Boolean. This file is present in the Common folder contains only if you add a ShareTarget item template.|
|BooleanToVisibilityConverter .cs|.vb|.cpp|.h||Converter for use in XAML. This file converts a Boolean to a visibility state.|
|ReadMe.txt||Contains important information about the template. This readme might change as templates are updated. We recommend that you read this file whenever you use a new template.|
|RelayCommand .cs|.vb|.cpp|.h||ICommand used by NavigationHelper for the GoBack and GoForward commands.|
|SuspensionManager cs|.vb|.cpp|.h||Manages the saving and restoration of the app's transient state. For example, when the system runs low on resources, the state of the current app is saved and the app is suspended. When the user returns to the app, the app is relaunched with the saved state. App.xaml and the NavigationHelper use this class to enable PLM support.|
|App.xaml||Page that is loaded first and provides markup for the content host (where each page is loaded into the main window).|
|package.appxmanifest||Describes the app package for Windows.|
|PFX file||used to sign the appxmanifest file. (This file is included as a project file to support building from a command prompt.)|
|SampleDataSource.cs|.vb|.cpp|.h||Data-source object that exposes the data to the app. If you're creating an app that has a similar structure, you can save time by using the data model for items and groups.|
|SampleData.json||Contains the sample data that the app uses. The sample data is in the form of hardcoded strings. You should replace this sample data with a data-access layer that references your own data.|
|Various image files||For example: SplashScreen.png for the splash-screen image and StoreLogo.png, which is used for Windows Store.|
|Sample resource file||Contains localization strings (Resources.resw).|
When you're ready to start creating an app, visit one of the following topics depending on your preferred programming language.
- Navigation model (using C#/VB/C++ and XAML)
- Adding data to a project template (using C#/VB/C++ and XAML)
- C#, VB, and C++ item templates for Windows Store apps