ebook img

Metro Revealed: Building Windows 8 Apps with XAML and C# PDF

106 Pages·2012·1.19 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Metro Revealed: Building Windows 8 Apps with XAML and C#

Metro Revealed Building Windows 8 Apps with XAML and C# Adam Freeman Metro Revealed: Building Windows 8 Apps with XAML and C# Copyright © 2012 by Adam Freeman This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN 978-1-4302-4491-2 ISBN 978-1-4302-4492-9 (eBook) Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. President and Publisher: Paul Manning Lead Editor: Ewan Buckingham Technical Reviewer: Fabio Claudio Ferracchiati Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Louise Corrigan, Morgan Ertel, Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh Coordinating Editor: Jennifer L. Blackwell Copy Editor: Kim Wimpsett Compositor: Spi Global Indexer: Spi Global Artist: Spi Global Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer- sbm.com, or visit www.springeronline.com. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code Dedicated to my lovely wife, Jacqui Griffyth – Adam Freeman Contents at a Glance About the Author ....................................................................................xi About the Technical Reviewer ..............................................................xiii Acknowledgments .................................................................................xv (cid:78) Chapter 1: Getting Started ....................................................................1 (cid:78) Chapter 2: Data, Binding, and Pages ..................................................17 (cid:78) Chapter 3: AppBars, Flyouts, and Navigation .....................................37 (cid:78) Chapter 4: Layouts and Tiles ..............................................................57 (cid:78) Chapter 5: App Life Cycle and Contracts ............................................77 (cid:78) Index ...................................................................................................93 v Contents About the Author ....................................................................................xi About the Technical Reviewer ..............................................................xiii Acknowledgments .................................................................................xv (cid:78) Chapter 1: Getting Started ....................................................................1 About This Book .............................................................................................1 What Do You Need to Know Before You Read This Book? .................................................1 What Software Do You Need for This Book? .....................................................................2 What Is the Structure of This Book? .................................................................................2 More about the Example Metro Application ......................................................................3 Is There a Lot of Code in This Book? .................................................................................4 Getting Up and Running .................................................................................5 Creating the Project ..........................................................................................................5 Exploring the App.xaml File ..............................................................................................7 Exploring the BlankPage.xaml File ...................................................................................8 Exploring the StandardStyles.xaml File ............................................................................9 Exploring the Package.appxmanifest File .......................................................................10 An Incredibly Brief XAML Overview ..............................................................10 Using the Visual Studio Design Surface ..........................................................................11 Configuring Controls in XAML .........................................................................................11 Configuring Controls in Code ..........................................................................................12 vii (cid:78) CONTENTS Running and Debugging a Metro App ...........................................................14 Running a Metro App in the Simulator ............................................................................15 Summary ......................................................................................................16 (cid:78) Chapter 2: Data, Binding, and Pages ..................................................17 Adding a View Model ....................................................................................18 Adding the Main Page ..................................................................................20 Writing the Code .............................................................................................................22 Adding a Resource Dictionary ........................................................................................23 Writing the XAML ............................................................................................................26 Running the Application ...............................................................................29 Inserting Other Pages into the Layout ..........................................................29 Dynamically Inserting Pages into the Layout ...............................................31 Switching Between Pages ..............................................................................................32 Implementing the Embedded Page ................................................................................33 Summary ......................................................................................................36 (cid:78) Chapter 3: AppBars, Flyouts, and Navigation .....................................37 Adding an AppBar .........................................................................................38 Declaring the AppBar ......................................................................................................38 Adapting Predefined AppBar Buttons .............................................................................40 Creating Custom AppBar Button Styles ..........................................................................41 Implementing AppBar Button Actions .............................................................................42 Creating Flyouts ...........................................................................................43 Creating the User Control ...............................................................................................44 Writing the User Control Code ........................................................................................45 Adding the Flyout to the Application ...............................................................................47 Creating a More Complex Flyout .....................................................................................49 viii (cid:78) CONTENTS Navigating within a Metro App .....................................................................53 Creating the Wrapper ......................................................................................................53 Creating the Other View ..................................................................................................55 Testing the Navigation ....................................................................................................56 Summary ......................................................................................................56 (cid:78) Chapter 4: Layouts and Tiles ..............................................................57 Supporting Metro Layouts ............................................................................58 Responding to Layout Changes in Code .........................................................................60 Responding to Layout Changes in XAML ........................................................................62 Breaking Out of the Snapped View .................................................................................64 Using Tiles and Badges ................................................................................65 Improving Static Tiles .....................................................................................................66 Creating Live Tiles ..........................................................................................................67 Updating Wide Tiles ........................................................................................................71 Applying Badges ...........................................................................................73 Summary ......................................................................................................76 (cid:78) Chapter 5: App Life Cycle and Contracts ............................................77 Dealing with the Metro Application Life Cycle ..............................................78 Correcting the Visual Studio Event Code ........................................................................78 Simulating the Life-Cycle Events ....................................................................................79 Testing the Life-Cycle Events .........................................................................................80 Adding a Background Activity ......................................................................81 Extending the View Model ..............................................................................................82 Displaying the Location Data ..........................................................................................83 Declaring the App Capabilities ........................................................................................84 Controlling the Background Task ....................................................................................84 ix (cid:78) CONTENTS Implementing a Contract ..............................................................................88 Declaring Support for the Contract .................................................................................88 Implementing the Search Feature ..................................................................................88 Responding to the Search Life-Cycle Event ....................................................................90 Testing the Search Contract ...........................................................................................91 Summary ......................................................................................................92 Index ......................................................................................................93 x About the Author Adam Freeman is an experienced IT professional who has held senior positions in a range of companies, most recently serving as chief technology officer and chief operating officer of a global bank. Now retired, he spends his time writing and running. xi

Description:
This 88-page primer unveils the key features of Microsoft's eagerly anticipated Windows 8 operating system. Windows 8 contains the revolutionary Metro application framework for building dynamic and responsive touch-enabled applications that target both desktops and mobile devices. With the official
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.