Rob Miles Windows Phone Blue Book
Total Page:16
File Type:pdf, Size:1020Kb
Windows Phone 8 Programming in C# Rob Miles Windows Phone 8 Contents 1 Getting Started with Windows Phone 9 Programmer’s Point: Stuff worth knowing ........................................................... 9 1.1 The Windows Phone Platform .............................................................................. 9 A Windows Phone as a Computer ........................................................................ 9 The Windows Phone Hardware ............................................................................ 9 The Windows Phone Processor ............................................................................ 9 Programmer’s Point: Only Sweat the Speed when you have to ......................... 10 The Windows Phone Operating System ............................................................. 10 Graphical Display ............................................................................................... 10 Touch input......................................................................................................... 11 Location Sensors ................................................................................................ 11 Accelerometer .................................................................................................... 11 Compass ............................................................................................................. 11 Gyroscope ........................................................................................................... 12 Sensor Integration and Simulation ..................................................................... 12 Camera ............................................................................................................... 12 Hardware buttons ............................................................................................... 12 Memory and Storage .......................................................................................... 13 Network Connectivity ........................................................................................ 13 Programmer’s Point: Be able to handle changes of network state ...................... 13 Near Field Communication (NFC) ..................................................................... 14 Bluetooth ............................................................................................................ 14 Platform Challenges ........................................................................................... 14 1.2 The Windows Phone Ecosystem ........................................................................ 14 Connecting a Windows Phone to a Windows PC ............................................... 14 Windows Live and Xbox Live............................................................................ 15 Bing Maps .......................................................................................................... 15 Windows Notification Service............................................................................ 15 Windows Phone and Windows Azure ................................................................ 16 Using the Ecosystem .......................................................................................... 16 1.3 Windows Phone program execution ................................................................... 16 Application Switching on Windows Phone ........................................................ 16 Background Processing ...................................................................................... 17 Windows Phone and Managed Code .................................................................. 17 Windows Phone and Compiled Code with C++ ................................................. 19 The MonoGame Framework and XNA .............................................................. 19 1.4 Windows Phone application development .......................................................... 19 Visual Studio 2012 and Windows Phone ........................................................... 19 The Windows Phone Emulator ........................................................................... 20 Accessing Windows Phone Facilities ................................................................. 21 Windows Phone Connectivity ............................................................................ 21 Data Storage on Windows Phone ....................................................................... 21 Development Tools ............................................................................................ 22 Windows Phone Store ........................................................................................ 22 What We Have Learned .................................................................................................... 23 2 Making a User Interface with XAML 24 2.1 Program Design with XAML ............................................................................. 24 XAML ................................................................................................................ 24 Using Blend for Visual Studio to create XAML ................................................ 25 The Windows Phone Design Style ..................................................................... 25 XAML Elements and Software Objects ............................................................. 26 The Toolbox and Design Surface ....................................................................... 28 Managing Element Names in Visual Studio ....................................................... 30 Properties in XAML Elements ........................................................................... 31 Using Properties ................................................................................................. 32 Page Design with XAML ................................................................................... 34 2.2 Understanding XAML ........................................................................................ 34 Extensible Markup Languages ........................................................................... 35 XAML and pages ............................................................................................... 36 2.3 Putting Program Code into an Application ......................................................... 37 Building the Application .................................................................................... 38 Calculating the Result......................................................................................... 38 Events and Programs .......................................................................................... 39 Events in XAML ................................................................................................ 39 Managing Event Properties ................................................................................ 41 Events and XAML .............................................................................................. 42 What We Have Learned .................................................................................................... 42 3 Visual Studio Solution Management 44 3.1 Getting Started with Projects and Solutions ....................................................... 44 Creating a Windows Phone solution................................................................... 47 Running Windows Phone applications ............................................................... 48 3.2 Debugging Programs .......................................................................................... 49 Using the Windows Phone emulator .................................................................. 49 Visual Studio Debugging ................................................................................... 51 Controlling Program Execution .......................................................................... 52 3.3 Performance Tuning ........................................................................................... 54 What We Have Learned .................................................................................................... 54 4 Constructing a program with XAML 56 4.1 Improving the User Experience .......................................................................... 56 Manipulating Element Properties ....................................................................... 56 4.2 Working with XAML text .................................................................................. 59 Configuring a TextBox to use the numeric keyboard ......................................... 59 Displaying a MessageBox .................................................................................. 62 Adding and Using Graphical Assets ................................................................... 63 Adding Images as Items of Content ................................................................... 65 4.3 Using the TextChanged Event ............................................................................ 67 4.4 Managing Application Page Layout ................................................................... 69 Screen Resolution Issues .................................................................................... 72 Programmer’s Point: Test your program on all screen sizes .............................. 73 Using Containers to Layout displays .................................................................. 73 Programmer’s