CHANNEL9 S WINDOWS PHONE 8.1 DEVELOPMENT FOR ABSOLUTE BEGINNERS

Similar documents
Lesson 10: Exercise: Tip Calculator as a Universal App

Fundamentals of XAML and Microsoft Expression Blend

NE Fundamentals of XAML and Microsoft Expression Blend

A Quick Tour GETTING STARTED WHAT S IN THIS CHAPTER?

[MS10553]: Fundamentals of XAML and Microsoft Expression Blend

UWP Working with Navigation

windows-10-universal #windows- 10-universal

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

The Basics of PowerPoint

Getting started 7. Setting properties 23

Getting Started with Access

Windows Presentation Foundation Programming Using C#

Microsoft Excel 2010 Basic

Lesson 9: Exercise: Tip Calculator

Getting Started with Word

Microsoft Word. Introduction

Lesson 1: Getting Started with

PowerPoint Instructions

Introduction. Watch the video below to learn more about getting started with PowerPoint. Getting to know PowerPoint

Microsoft Expression Web Quickstart Guide

Changing Button Images in Microsoft Office

PowerPoint Launching PowerPointX

Section 4 Working with Text

PAGES, NUMBERS, AND KEYNOTE BASICS

Developing Intelligent Apps

Section 1 Getting Started

The Fundamentals. Document Basics

CST272 Getting Started Page 1

WPF. Source Module 01: Lesson1

PowerPoint X. 1. The Project Gallery window with the PowerPoint presentation icon already selected. 2. Click on OK.

Introduction to PowerPoint 2007

Text box. Command button. 1. Click the tool for the control you choose to draw in this case, the text box.

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney

Windows Presentation Foundation (WPF)

Interactive Powerpoint. Jessica Stenzel Hunter Singleton

Word 2013 Quick Start Guide

Lab 2. Task 1 : Learning basic tasks with PowerPoint. Estimated time

Microsoft Excel 2007

Using PowerPoint - 1

Make Your Documents Accessible Worksheet (Microsoft Word 2010)

Inspiration Quick Start Tutorial

Interface. 2. Interface Adobe InDesign CS2 H O T

Photoshop and Lightroom for Photographers

Word Introduction. SmartArt graphics. Video: SmartArt Graphics in. Word To insert a SmartArt illustration: SmartArt Graphics

Unit 2: Using Windows 7 Lesson 9

SQL Server 2005: Reporting Services

BASIC MICROSOFT POWERPOINT

SQL Server. Management Studio. Chapter 3. In This Chapter. Management Studio. c Introduction to SQL Server

PowerPoint Tips and Tricks

Developing Windows Applications with Microsoft Visual Studio 2010

Using Dreamweaver. 4 Creating a Template. Logo. Page Heading. Home About Us Gallery Ordering Contact Us Links. Page content in this area

Rev. A 02/02/2016 Downers Grove Public Library Page 1 of 50

SPARK. User Manual Ver ITLAQ Technologies

Introduction. Using Styles. Word 2010 Styles and Themes. To Select a Style: Page 1

1. Move your mouse to the location you wish text to appear in the document. 2. Click the mouse. The insertion point appears.

Getting started 7. Setting properties 23

Beginning PowerPoint: 2010 A Presentation Software

This walkthrough assumes you have completed the Getting Started walkthrough and the first lift and shift walkthrough.

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

Developing Native Windows Phone 7 Applications for SharePoint

Welcome. Microsoft PowerPoint 2010 Fundamentals Workshop. Faculty and Staff Development Program

Downloaded from

Telerik Corp. Test Studio Standalone & Visual Studio Plug-In Quick-Start Guide

Getting Started with. PowerPoint 2010

Dreamweaver MX The Basics

Display Systems International Software Demo Instructions

How to Use Serif WebPlus 10

Microsoft Office Training Skills 2010

Slides & Presentations

Contents. I. Starting a New Presentation Try it! II. Choosing a Theme III. Tailoring the theme IV Background Styles...

While the press might have you believe that becoming a phoneapp

Gloucester County Library System. Microsoft 2010 PowerPoint

MICROSOFT OFFICE. Courseware: Exam: Sample Only EXCEL 2016 CORE. Certification Guide

Templates and Forms A Complete Overview for Connect Users

Sample Chapters. To learn more about this book, visit the detail page at: go.microsoft.com/fwlink/?linkid=192147

Office 2010: Transition from Office Contents. Moving to Microsoft Office Microsoft Office 2010 Project Transition from Office 2003

Hands-On Lab. Hello Windows Phone

Developing Windows Applications with Microsoft Visual Studio 2010 (MS 10262)

2009 Microsoft Corporation. All rights reserved. Page 1

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline

Getting Started with BarchartX

Step-by-Step Guide to Set Up Your Challenge Opt-In Page with MailChimp and LeadPages (last updated August 6, 2017)

XcreenKey Verti. User Guide v2.0. Legal Before You Start Using XcreenKey Verti

Introduction to IBM Rational HATS For IBM System z (3270)

TDMobile Architecture & Overview of the TD Mobile IDE. Horst de Lorenzi

PowerPoint Essentials 1

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

Introduction. SmartArt Graphics. Word 2010 SmartArt Graphics. Video: SmartArt Graphics in Word To Insert a SmartArt Illustration: Page 1

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

Photoshop Fundamentals

PowerPoint Introduction. Video: Slide Basics. Understanding slides and slide layouts. Slide Basics

Discovering Computers & Microsoft Office Office 2010 and Windows 7: Essential Concepts and Skills

CS3240 Human-Computer Interaction Lab Sheet Lab Session 3 Designer & Developer Collaboration

ArtOfTest Inc. Automation Design Canvas 2.0 Beta Quick-Start Guide

INTRODUCTION TO VISUAL BASIC 2010

Excel 2010: Getting Started with Excel

TABLE OF CONTENTS TABLE OF CONTENTS... 1 INTRODUCTION... 2 USING WORD S MENUS... 3 USING WORD S TOOLBARS... 5 TASK PANE... 9

Handout created by Cheryl Tice, Instructional Support for Technology, GST BOCES

PowerPoint 2002 Manual

Transcription:

CHANNEL9 S WINDOWS PHONE 8.1 DEVELOPMENT FOR ABSOLUTE BEGINNERS Full Text Version of the Video Series Published April, 2014 Bob Tabor http://www.learnvisualstudio.net

Contents Introduction... 2 Lesson 1: Series Introduction... 5 Lesson 2: Exercise: Writing your First Windows Phone 8.1 App... 7 Lesson 3: Introduction to XAML... 20 Lesson 4: Understanding XAML Layout and Events... 32 Lesson 5: Overview of the Common XAML Controls... 44 Lesson 6: Themes and Styles XAML... 67 Lesson 7: Understanding the Navigation Model... 73 Lesson 8: Working with the package.appxmanifest... 79 Lesson 9: Exercise: Tip Calculator... 88 Lesson 10: Exercise: Tip Calculator as a Universal App...103 Lesson 11: Working with the Windows Phone 8.1 Emulator...113 Lesson 12: Understanding the App s Lifecycle and Managing State...129 Lesson 13: Working with the Web View App Template...143 Lesson 14: Exercise: Whack-a-Bob App...152 Lesson 15: Understanding the Hub App Template Overview and Navigation...177 Lesson 16: Understanding the Hub App Template s Sample Data Model...184 Lesson 17: Understanding Data Binding, Data Sources and Data Contexts...189 Lesson 18: Understanding MVVM: ObservableCollection<T> and INotifyPropertyChanged...197 Lesson 19: Understanding async and Awaitable Tasks...202 Lesson 20: Playing Video and Audio in a MediaElement Control...206 Lesson 21: Exercise: I Love Cupcakes App...210 Lesson 22: Storing and Retrieving Serialized Data...233 Lesson 23: Working with the Command Bar...242 Lesson 24: Binding to Commands and CommandParameters...248 Lesson 25: Advanced Binding with Value Converters...257 Lesson 26: Exercise: The Daily Rituals App...267 Lesson 27: Working with the Map Control and the Geolocation and GeoPosition Classes...304 Lesson 28: Working with Animations in XAML...320 Lesson 29: Exercise: The Map Notes App...329 Lesson 30: Series Conclusion...359 Windows Phone 8.1 Development for Absolute Beginners Page 4

Lesson 2: Exercise: Writing your First Windows Phone 8.1 App If you recall from the C# Fundamentals For Absolute Beginners Series on Microsoft Virtual Academy and Channel 9, near the end of that series I demonstrated how event work by creating two apps: an ASP.NET Web Forms app and a WPF, or rather, Windows Presentation Foundation app. I took the same basic steps to create both of those apps and they essentially perform the same operation; a button, you click on it, and it displayed a simple Hello World message in a label. In this lesson, I want to re-create that example, except this time creating a simple Windows Phone app. Note: Before we get started, make sure that you already have the Visual Studio 2013 Update 2 installed, which will include the Windows Phone 8.1 Tooling, like we talked about in the previous lesson. If you already have that installed, then we're ready to move forward. I ll begin by creating a new project: In the New Project Dialog, on the left select (1) Templates (2) Visual C# (3) Store Apps (4) Windows Phone Apps. In the center select the (5) Blank App (Windows Phone) project template. (6) Change the project name to: HelloWorld, then (7) Click OK: Windows Phone 8.1 Development for Absolute Beginners Page 7

In the Solution Explorer, double-click the MainPage.xaml file: When MainPage.xaml loads into the main area of Visual Studio, you ll notice that it has a (1) preview pane on the left and the (2) XAML code editor view on the right: Windows Phone 8.1 Development for Absolute Beginners Page 8

The preview pane displays the chrome of a Windows Phone to help us visualize the changes we make to the user interface. Often in these lessons I ll resize the default preview so that it can fit in the space available (so that we don t have to scroll around to see our changes). To do this, (1) I ll change the percentage to 40%, and (2) that should make the entire phone preview visible: Windows Phone 8.1 Development for Absolute Beginners Page 9

Next, I ll hover my mouse cursor over the Toolbox tab docked to the right. This will display the Toolbox. (1) I ll pin down (or rather, I ll disable auto-hide), then (2) drag a Button control (3) and drop it on the design surface: Windows Phone 8.1 Development for Absolute Beginners Page 10

I ll repeat by (1) dragging a TextBlock control and (2) dropping it on the designer surface: Notice that by dragging and dropping controls from the toolbox on to the designer surface, XAML is produced in the code editor along with some properties set such as default content or text, some sizing and positioning set, and so on: Windows Phone 8.1 Development for Absolute Beginners Page 11

I can also affect the XAML that is generated by Visual Studio using the Properties window. For example, I ll put my mouse cursor into the Button control s XAML definition OR I ll select the button control on the design surface, then give the Button a name: clickmebutton: You ll notice that by giving the Button control a name in the Properties window, it generated a x:name property in XAML and set that Name to clickmebutton. Likewise, when I modify the Content property of the Button in the Properties window setting the property to Click Me, there s a change to both the XAML and to the preview pane: Windows Phone 8.1 Development for Absolute Beginners Page 12

The key idea here is that these are three perspectives of the same fundamental object: a Button, a TextBlock, etc. so changes you make in any of the panels affect the others. Having said that, my personal belief is that you will become much more productive using the XAML text editor than the other panes. It will give you a full fidelity control over the properties that control appearance and positioning and as a result, I ll almost exclusively edit the XAML by hand in this series of lessons. However, for now I ll make continue to use Properties window as a gentle introduction to building a user interface for our Phone app. I ll select text TextBlock in the XAML or preview pane, then change its Name in the Properties window to: resulttextblock. You may find it odd that, by default, XAML controls do not have a Name property already created. This is because, as we ll learn, XAML is a very concise language that is used by the Windows Phone API for layout. You only need a name for a control if you plan on accessing that control programmatically in C# code. We ll do that in a moment. I ll also change the font size of the text that we ll fill into the TextBlock control. With the TextBlock still selected, I ll find the Text properties and set the font size to 48, which will in turn modify the FontSize attribute in the XAML code: Windows Phone 8.1 Development for Absolute Beginners Page 13

Next, I ll select the Button control again (whether in XAML or in the preview pane), then I ll select the lightning bolt icon next to the Name property to view the events that can be handled for this control: Now you should be able to see all of the events for the Button. I ll double-click the white area / text box next to the Click event to automatically create a method called: clickmebutton_click which will in turn create a method stub in the code behind for our MainPage.xaml. In other words, the MainPage.xaml.cs file opens in the main area of Visual Studio allowing us to write C# code in response to events that are triggered by the user (or in the case of other events, they could possibly be triggered by the life-cycle of the app itself). Windows Phone 8.1 Development for Absolute Beginners Page 14

Inside of the method stub for the clickmebutton_click event handler, I ll add one line of code to set the Text property of our resulttextblock (the TextBlock we added earlier) to the string value Hello World. Now I ll attempt to run the app in debug mode. As we learned in the C# Fundamentals for Absolute Beginner s Series, while running our app in debug mode, we can set break points, view the values of variables, etc. When building a Widows Phone app, there s one more great feature: we can see our Phone app working without needing to deploy our app to an actual, physical Windows Phone. In this case, we ll select the green triangular Run button notice that we ll be launching our app in the Emulator 8.1 WVGA 4 inch 512 MB. What does this mean? It specifies which physical phone we ll be emulating, including the screen size and memory on the phone. As you ll learn, there are several different emulators we can use that will allow us to see how our app performs on different hardware: Windows Phone 8.1 Development for Absolute Beginners Page 15

Once we run the app, we ll see it sitting inside of a software representation of a physical phone. For now, let s focus on the app itself, and we ll devote an entire lesson to learning more about the Emulator in an upcoming lesson. If you use your mouse cursor to click the Click Me button (simulating the use of your finger to tab the button on the Phone s screen) it will display the message Hello World! in a large font: To stop running the app in the Emulator, return to Visual Studio and press the red square Stop button: Alternatively, you could shut down the Emulator using the large X icon in the toolbar to the right, however that is not necessary. You should get into the habit of leaving the Emulator running even when you re not debugging. There are two reasons for this. First, the Emulator is running as a virtual machine, and it takes time to re-boot. Second, any data that your app saved to the phone between debugging runs will be lost when you shut down the Emulator. Windows Phone 8.1 Development for Absolute Beginners Page 16

Hopefully you were able to see the relationship between the work we did in XAML and the finished app. There are some key takeaways from this lesson as we're getting started. First of all, you're going to be able to leverage your existing knowledge of creating user interfaces and Visual Studio and apply that to creating Windows Phone Apps. It's easy and it's fun, and certainly there's a lot to learn here, but there's nothing to be intimidated about. We have the option of making changes in the most visual way by dragging and dropping items from the Toolbox onto the designer surface. We see how that created the XAML code, which looks very much like HTML. We'll learn more about this mysterious XAML syntax in the next lesson. We can also make changes in the properties window to modify the various attributes of the controls that we see on screen. Furthermore, just like ASP.NET Web Forms and the Windows Presentation Foundation apps we created, every screen, or rather, every Page has a code behind that's associated with it, where we can write event handler code to perform operations whenever the user interacts with our application in a given way. The phone API provides this rich collection of controls and other options, as well as classes per form various operations or allow us to retrieve values produced by the Phone s sensors. As developers we can tap into that API to enable powerful functionality in our apps. The API is similar to working with Windows applications in so much that you have classes with properties and methods and events. Some of those affect the life-cycle of the app, some affect the visual qualities, like the visual controls or the layout of the app, and then some affect the navigation from page to page, which we haven't seen yet, but we will discuss in a later lesson. We'll talk about those in detail in just a little bit and they'll help us to build more complex and complex applications. The third takeaway is that, like the Windows Presentation Foundation app example from the C# Fundamentals for Absolute Beginners Series, Phone apps are composed of a combination of both XAML and C# syntax. We can see there s a relationship between the MainPage.xaml and the MainPage.xaml.cs files because they re named similarly, and they re also visually related in the Solution Explorer. As we ll learn, these two files actually represent two parts of a whole. In the MainPage.xamlcs file, notice that this class is named MainPage: Windows Phone 8.1 Development for Absolute Beginners Page 17