Windows-8.1

Universal Windows App Project Setup

This tutorial is a part of the series on Building a Universal Windows app using MVVM pattern. In this tutorial we will setup a new project for building a Universal Windows app.

Setting up the Project

In Visual Studio click on New Project and choose Blank App (Universal Windows 8.1) from the existing Templates. If you are unable to find this template in your Installed templates list then head over to the following link to download the latest SDK for Windows Phone.

https://dev.windows.com/en-us/develop/download-phone-sdk

Structure of Universal Windows app

When you first open up the Solution, the project structure looks something like this.

Each of the platform specific projects contain an Assets folder and a MainPage.xaml file. The shared project contains the App.xaml file which is shared by both the Windows 8.1 and Windows Phone 8.1 apps. The Windows and Windows Phone projects are platform projects and are responsible for creating the application packages (.appx), targeting the respective platforms. The shared project is a container for code that runs on both platforms. They don’t have a binary output, but their contents are imported by the platform projects and used as part of the build process to generate the app packages (.appx).

Switching between Startup projects

To set the startup project, right-click on the project node in the Solution Explorer and choose the option Set as Startup Project. You can quickly switch the startup project from the Debug target drop-down that now enumerates all the possible projects in the solution. The project that you choose is shown in bold in the Solution Explorer. The available debug targets change when switching startup projects.

  • When the Windows project is the startup project, the Debug target drop-down displays options for the Windows Simulator or Local Machine.
  • When the Windows Phone project is the startup project, the drop-down displays options for Device as well as various emulators.

Switch context in Code Editor

When writing code in a shared project, you can use the project context switcher in the navigation bar to select the platform you are actively targeting, which in turn customizes the IntelliSense experience in the code editor.

Cross-Platform Code in Shared Project

In the shared project, you typically write code that is common to both platforms. To isolate sections of code that are platform-specific, use the #ifdef directive. The constants WINDOWS_APP and WINDOWS_PHONE_APP are predefined for you.

We are done setting up our project and getting familiar with a few handy features of Visual Studio while building a Universal app. You could reference the following article to create your first universal Windows app.

Creating Your First Universal Windows App

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app experiences.

  • nzmike

    This is definitely NOT a Windows 10 Universal Windows Platform app so why it is listed under
    “Windows 10”? The UWP does NOT set up separate projects for each deployment platform (desktop/mobile/tablet/etc) as the default project uses the universal set of API’s by default thereby only needing one project (not including domain model libraries etc). It is very misleading for people coming here having searched how to do MVVM for WINDOWS 10 UWP (as I did) and end up getting Windows a 8.1 tutorial…. you should remove this tutorial from the Windows 10 section of your website!!

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close