Building a Universal App

With the basics out of the way, let’s put our combined knowledge of Windows Phone apps (covered in the first part of this chapter) and Windows Store apps (covered in Chapter 23) and build a simple Universal app. To demonstrate the Visual Studio project templates and the core concepts of lifecycle management, data persistence, and the MVVM approach, we’ll build a simple master-detail application that allows you to keep track of restaurant bills, compute a tip, and determine the total for each party if you decide to “split the tab.”


Note

Although we provide extensive code listings in this chapter and walk through the major pieces of this project, we explicitly do not cover every little element or line of code needed to assemble the full, cross-platform, Universal app. Our recommendation is that you open the full sample application from this book’s website and then use that as a backdrop as you work through this Universal app content: www.informit.com/title/9780672337369.


The application should support the following three end user requirements:

Image A meal bill/tab can be split equally among two or more parties; the app should also be able to handle a single party.

Image The app will generate the grand total by adding a specific tip (percentage) onto the total; the app will also compute the total owed by each party.

Image Once the meal cost has been allocated and computed, the details will be added to the master list of meal bills.

And for our purposes here, we’ll cater to the following nonfunctional requirements:

Image The app should use an MVVM approach to simplify maintenance of the code and optimize the built-in data binding features in XAML apps.

Image The app will save the meal data to a form of persistent storage.

Image The app will run equally well, with no loss of functionality, between Windows 8.1 and Windows Phone 8.1.

The goal is to have a similar look and feel across devices but also to cater to each device. If we were to sketch out a quick design for both the phone version and the Windows 8 version, we would quickly see that we likely need two pages to make this work on the phone: the master list page and then a details page for each entry. For the Windows version, with additional screen real estate available (and with a common landscape orientation to that real estate), we will likely find it better to create just a single page. Figures 24.9 through 24.11 show our quick and dirty prototype.

Image

FIGURE 24.9 Windows Phone design—master list page.

Image

FIGURE 24.10 Windows Phone design—details page.

Image

FIGURE 24.11 Windows design.

As always, we start the adventure by selecting a project type in Visual Studio.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset