Book Image

Windows Application Development Cookbook

By : Marcin Jamro
Book Image

Windows Application Development Cookbook

By: Marcin Jamro

Overview of this book

Need to ensure you can always create the best Windows apps regardless of platform? What you need are solutions to the biggest issues you can face, so you can always ensure you’re making the right choices and creating the best apps you can. The book starts with recipes that will help you set up the integrated development environment before you go ahead and design the user interface. You will learn how to use the MVVM design pattern together with data binding, as well as how to work with data in different file formats. Moving on, you will explore techniques to add animations and graphics to your application, and enable your solution to work with multimedia content. You will also see how to use sensors, such as an accelerometer and a compass, as well as obtain the current GPS location. You will make your application ready to work with Internet-based scenarios, such as composing e-mails or downloading files, before finally testing the project and submitting it to the Windows Store. By the end of the book, you will have a market-ready application compatible across different Windows devices, including smartphones, tablets, and desktops.
Table of Contents (17 chapters)
Windows Application Development Cookbook
About the Author
About the Reviewer

Creating a new project

Once you have the IDE installed, you can proceed to creating a new project. A project consists of a set of files that specify, for instance, the configuration of an application, or the design of particular pages, as well as code defining the interaction with the user interface.

Getting ready

To use this recipe, you just need Microsoft Visual Studio Community 2015 installed, as explained earlier in this chapter. No other prerequisites are required.

How to do it...

To create a new project, you need to perform the following steps:

  1. Launch Microsoft Visual Studio Community 2015.

  2. Navigate to File | New | Project... from the menu.

  3. Click on the Installed group on the left-hand side. Then, navigate to Templates | Visual C# | Windows | Universal from the tree.

  4. Select Blank App (Universal Windows) on the right-hand side, as shown in the following screenshot.

  5. Type a name of the project (Name, such as CH01), choose a suitable location (Location), as well as type a name of the solution (Solution name).

  6. Click on OK. If an additional window with the possibility of choosing the target and minimum supported platform versions appears, choose proper values and click on OK. The project will then be created automatically.

There's more...

It is worth mentioning the structure of the automatically generated solution to learn more about the various files that you will see while developing UWP applications for the Windows 10 platform. You could easily browse through the solution with the Solution Explorer window, which you can open by navigating to the View | Solution Explorer option from the menu.

The automatically generated structure of the solution is shown as follows:

At the top, you have the CH01 solution that contains only one project, also named CH01. Just after its name, there is an indicator that it is the Universal Windows project, thus it should work on various devices, such as smartphones, tablets, and desktops.

The first group within the project is named Properties. It contains two files, namely AssemblyInfo.cs and Default.rd.xml. This group provides information about the assembly with your application along with runtime directives. In most cases, you will not need to modify such files on your own.


You can open the graphical configuration tool by double-clicking on the Properties group.

The References group performs a very important role because it informs which additional references are used by the application. Such references may include your own class libraries or pre-prepared solutions available for developers. By using packages from the huge number of available ones, it is possible to significantly speed up development as well as limit the chance of introducing bugs while developing such software on your own. What is more, the IDE is supported by the NuGet Package Manager and can find and install packages. You will learn how to use it in the Creating and using a user control recipe in Chapter 2, Designing a User Interface.

The third group is named Assets and contains a set of images necessary for the application, such as for the splash screen, tiles, or logo. Of course, you need to prepare suitable graphics before submitting the application to the store.

The App.xaml file uses the XAML language. You can use this file to define the resources that will be shared between various pages of the application, not to define them multiple times in various files, as shown in the Defining a global style recipe in Chapter 2, Designing a User Interface. Apart from the App.xaml file, there is the App.xaml.cs file, which contains C# code handling a few scenarios regarding the application, such as its launching.

The MainPage.xaml file is another file with XAML-based content. It represents the first page added automatically to the project. By default, it does not contain any controls, except a grid with a specified background color. You will learn more about this control in Chapter 2, Designing a User Interface. Similarly, as in the case of the App.xaml file, the MainPage.xaml file is supported by the dedicated .xaml.cs file, namely MainPage.xaml.cs. It contains the C# code regarding this page.

Among other files, you can also find Package.appxmanifest. It specifies the various properties regarding the application. You will take a look at the various settings available in this file in the Adjusting the manifest file recipe in Chapter 9, Testing and Submission. At the end, it is worth mentioning the project.json file with configuration of the project, including dependency to Microsoft.NETCore.UniversalWindowsPlatform.

See also

  • The Adding a new page recipe

  • The Arranging controls in a gridDefining a global style, and Creating and using a user control recipes in Chapter 2, Designing a User Interface

  • The Creating the view model for a page recipe in Chapter 3, MVVM and Data Binding

  • The Adding a project to the Windows Dev Center, Associating an application with the store, and Adjusting the manifest file recipes in Chapter 9, Testing and Submission