
Praise for Programming the Windows Runtime by Example “This is a great from-the-ground-up, very complete book on building Windows Store Apps. You’ll find it on your desk a year from now all dog-eared and marked up from use.” Dave Campbell , MVP, WindowsDevNews.com “ Programming with Windows Runtime by Example is a must-have book for any professional developer building apps for WinRT/Win8.1, especially in the LOB space for modern apps on Windows 8.1. For me it is the reference I provide my team building LOB applications for WinRT. Jeremy and John have done a great job putting together a great reference and educational book on professional development for the WinRT platform.” David J. Kelley , CTO, Microsoft MVP “Jeremy and John are both very much IT masters from the old guard of software development. With countless years of bending, shaping, and influencing the world of software development behind them both, they continue to do so as they push forward into new and emerging technologies. “As with everything they do, this book also reflects their ongoing dedication and passion for their quest to bring the reader not only the information he or she requires, but far more beyond that, they build knowledge step-by–step, then deliver it to the reader with cutting-edge, ninja-like precision to deliver exactly what knowledge is needed, when it’s needed, and where it’s needed. “ If you want to learn the Windows Runtime, then I can think of no finer book, and no finer guides to the WinRT landscape. By the end of this book, you’ll have the knowledge, the power, and a hefty dose of passion to go out into the new millennium and create some of the best WinRT apps available.” Peter “Shawty” Shaw , LinkedIn .NET User Group manager “This book is an invaluable resource for budding WinRT developers. It covers the basics to more advanced topics like MVVM. Readers will find the chapter entitled ‘Connecting to the Cloud’ especially useful in getting up to speed with Azure and creating cloud connected apps.” Daniel Vaughan , President of Outcoder, Microsoft MVP, Author of Windows Phone 8 Unleashed “There are books that provide reference for a development topic, and others that you will read from cover to end. Programming the Windows Runtime by Example by Jeremy Likness and John Garland should be your go-to guide for getting up to speed on WinRT. Jeremy and John wrote this book with the intention of being easy to follow and hard to forget, and they succeeded in both areas. I recommend this book for all developers, whether new to WinRT development, or those like me who just want to fill in the gaps on advanced topics.” Chris Woodruff , DeepFriedBytes.com, Microsoft MVP Microsoft Windows Development Series Visit informit.com/mswinseries for a complete list of available publications. The Windows Development Series grew out of the award-winning Microsoft .NET Development Series established in 2002 to provide professional developers with the most comprehensive and practical coverage of the latest Windows developer technologies. The original series has been expanded to include not just .NET, but all major Windows platform technologies and tools. It is supported and developed by the leaders and experts of Microsoft development technologies, including Microsoft architects, MVPs and RDs, and leading industry luminaries. Titles and resources in this series provide a core resource of information and understanding every developer needs to write effective applications for Windows and related Microsoft developer technologies. “ This is a great resource for developers targeting Microsoft platforms. It covers all bases, from expert perspective to reference and how-to. Books in this series are essential reading for those who want to judiciously expand their knowledge and expertise.” – JOHN MONTGOMERY, Principal Director of Program Management, Microsoft “ This series is always where I go first for the best way to get up to speed on new technologies. With its expanded charter to go beyond .NET into the entire Windows platform, this series just keeps getting better and more relevant to the modern Windows developer.” – CHRIS SELLS, Independent Consultant specializing in Windows, devices, and the cloud Make sure to connect with us! informit.com/socialconnect Programming the Windows Runtime by Example A Comprehensive Guide to WinRT with Examples in C# and XAML Jeremy Likness John Garland Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. Microsoft, Windows, Visual Basic, Visual C#, and Visual C++ are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales depart- ment at [email protected] or (800) 382-3419. For government sales inquiries, please contact [email protected] . For questions about sales outside the U.S., please contact [email protected] . Visit us on the Web: informit.com/aw Library of Congress Control Number: 2013954295 Copyright © 2014 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copy- right, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236-3290 ISBN-13: 978-0-321-92797-2 ISBN-10: 0-321-92797-4 Text printed in the United States on recycled paper at Edwards Brothers Malloy, Lillington, North Carolina First printing, June 2014 For Doreen and all her arrows, Lizzie and all her travels, and Gordon and all his paint. —Jeremy Likness To Karen, Callie, Winnie, and Dude, for the new adventure that is soon to begin. — John Garland Contents at a Glance 1 The New Windows Runtime 1 2 Windows Store Apps and WinRT Components 29 3 Layouts and Controls 81 4 Data and Content 153 5 Web Services and Syndication 199 6 Tiles and Toasts 225 7 Connecting to the Cloud 261 8 Security 323 9 Model-View-ViewModel (MVVM) 349 10 Networking 379 11 Windows Charms Integration 415 12 Additional Windows Integration 451 13 Devices 479 14 Printers and Scanners 531 15 Background Tasks 559 16 Multimedia 589 17 Accessibility 615 18 Globalization and Localization 631 19 Packaging and Deploying 649 20 Debugging and Performance Optimization 685 A Under the Covers 719 B Glossary 733 Index 749 Contents Foreword xix Preface xxii 1 The New Windows Runtime 1 Windows Runtime Specifics 1 Windows Store Apps 4 Example: Create a Windows Store App 5 .NET and WinRT 9 Fundamental Types 9 Mapped Types 10 Streams and Buffers 14 Desktop Applications 15 Example: Reference WinRT from a Desktop Application 15 Example: Examine Projections in a WinRT Component 20 Asynchronous Functions 24 Summary 27 2 Windows Store Apps and WinRT Components 29 Fundamentals of a Windows Store App 30 Windows Store App Templates 32 Understanding the App Manifest 45 Finding Your Package on Disk 52 Running Your App 54 vii viii Contents Application Lifecycle 61 The Navigation Helper and Suspension Manager 67 Managed WinRT Components 75 Creating a Managed WinRT Component 76 Calling Managed WinRT Components from Any Language 78 Summary 79 3 Layouts and Controls 81 The Visual Tree 83 Data-Binding 85 Dependency Properties 91 Attached Properties 94 Value Precedence 95 Property Change Notification 95 Animations 97 Example: Dynamically Apply Animations to a Control 97 The Visual State Manager 100 Example: Visual State Manager 101 Groups 103 States 105 Transitions 106 The Visual State Manager Workflow 107 Programmatic Access to Visual States 109 Custom Visual State Managers 109 Styles 111 Templates 112 Example: Using Templates 112 Layouts 115 Panel 115 Border 115 Canvas 116 Grid 116 StackPanel 117 VirtualizingPanel and VirtualizingStackPanel 118 Contents ix WrapGrid 119 VariableSizedWrapGrid 119 ContentControl 120 ItemsControl 121 ScrollViewer 122 ViewBox 122 GridView 123 ListBox 123 ListView 124 FlipView 124 Example: Using the Viewbox and Various Layouts 125 Controls 130 Flyouts 133 Custom Controls 135 Example: Creating a Custom Control 136 Parsing XAML 140 HTML Pages 143 Example: Working with HTML and JavaScript 144 Summary 150 4 Data and Content 153 Example: Data Manipulation with the Skrape App 154 The Clipboard 154 Application Storage 159 Roaming
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages152 Page
-
File Size-