Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
46 views

Instant Download Programming Windows Store Apps with HTML CSS and JavaScript Second Edition Kraig Brockschmidt PDF All Chapters

Apps

Uploaded by

aaroonsiegel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Instant Download Programming Windows Store Apps with HTML CSS and JavaScript Second Edition Kraig Brockschmidt PDF All Chapters

Apps

Uploaded by

aaroonsiegel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Programming Windows Store Apps with HTML CSS and


JavaScript Second Edition Kraig Brockschmidt

https://textbookfull.com/product/programming-windows-store-
apps-with-html-css-and-javascript-second-edition-kraig-
brockschmidt/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Programming Windows Store Apps with HTML CSS and


JavaScript Second Edition Kraig Brockschmidt

https://textbookfull.com/product/programming-windows-store-apps-with-
html-css-and-javascript-second-edition-kraig-brockschmidt/

textboxfull.com

Sams Teach Yourself HTML, CSS, and JavaScript All in One


Julie C. Meloni

https://textbookfull.com/product/sams-teach-yourself-html-css-and-
javascript-all-in-one-julie-c-meloni/

textboxfull.com

Web Development for beginners Learn HTML CSS Javascript


step by step with this Coding Guide Programming Guide for
beginners Website development 1st Edition Mastery
https://textbookfull.com/product/web-development-for-beginners-learn-
html-css-javascript-step-by-step-with-this-coding-guide-programming-
guide-for-beginners-website-development-1st-edition-mastery/
textboxfull.com

Sams Teach Yourself HTML CSS and JavaScript All in One 1st
Edition Meloni Julie C

https://textbookfull.com/product/sams-teach-yourself-html-css-and-
javascript-all-in-one-1st-edition-meloni-julie-c/

textboxfull.com
Web Design Playground: HTML + CSS the Interactive Way,
Second Edition Paul Mcfedries

https://textbookfull.com/product/web-design-playground-html-css-the-
interactive-way-second-edition-paul-mcfedries/

textboxfull.com

New Perspectives on HTML 5 and CSS 8th Edition Patrick M.


Carey

https://textbookfull.com/product/new-perspectives-on-html-5-and-
css-8th-edition-patrick-m-carey/

textboxfull.com

Learning PHP MySQL JavaScript With jQuery CSS HTML5 5th


Edition Robin Nixon

https://textbookfull.com/product/learning-php-mysql-javascript-with-
jquery-css-html5-5th-edition-robin-nixon/

textboxfull.com

New Perspectives on HTML 5 and CSS Comprehensive 8th


Edition Patrick M Carey

https://textbookfull.com/product/new-perspectives-on-html-5-and-css-
comprehensive-8th-edition-patrick-m-carey/

textboxfull.com

Reactive Programming with JavaScript 1st Edition Hayward


Jonathan

https://textbookfull.com/product/reactive-programming-with-
javascript-1st-edition-hayward-jonathan/

textboxfull.com
PUBLISHED BY
Microsoft Press
A Division of Microsoft Corporation
One Microsoft Way
Redmond, Washington 98052-6399

Copyright © 2014 Microsoft Corporation

All rights reserved. No part of the contents of this book may be reproduced or tr ansmitted in any form or by any means
without the written permission of the publisher.

Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to
this book, email Microsoft Press Book Support at mspinput@microsoft.com. Please tell us what you think of this
book at http://aka.ms/tellpress.

Unless otherwise noted, the companies, organizations, products, domain names, e -mail addresses, logos, people,
places, and events depicted in examples herein are fictitious. No association with any real company, organization,
product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred.

Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under
copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any
purpose, without the express written permission of Microsoft Corporation.

Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/


Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their
respective owners.

This book expresses the author’s views and opinions. The information contained in this book is provided without any
express, statutory, or implied warranties. Neither the authors, Microsoft Cor poration, nor its resellers, or distributors will
be held liable for any damages caused or alleged to be caused either directly or indirectly by this book.

Acquisitions, Developmental, and Project Editor: Devon Musgrave


Cover: Twist Creative • Seattle and Joel Panchot

1
Table of Contents
Introduction ........................................................................................................................ 21
Who This Book Is For ........................................................................................................ 23
What You'll Need (Can You Say “Samples”?) ...................................................................... 24
A Formatting Note............................................................................................................ 25
Acknowledgements .......................................................................................................... 26
Free Ebooks from Microsoft Press ..................................................................................... 28
The “Microsoft Press Guided Tours” App ........................................................................... 28
Errata & Book Support ...................................................................................................... 28
We Want to Hear from You............................................................................................... 29
Stay in Touch ................................................................................................................... 29
Chapter 1 The Life Story of a Windows Store App: Characteristics of the
Windows Platform .............................................................................................................. 30
Leaving Home: Onboarding to the Windows Store ............................................................. 32
Discovery, Acquisition, and Installation.............................................................................. 35
Playing in Your Own Room: The App Container .................................................................. 39
Different Views of Life: Views and Resolution Scaling ......................................................... 42
Those Capabilities Again: Getting to Data and Devices ........................................................ 46
Taking a Break, Getting Some Rest: Process Lifecycle Management ..................................... 49
Remembering Yourself: App State and Roaming................................................................. 51
Coming Back Home: Updates and New Opportunities ........................................................ 56
And, Oh Yes, Then There’s Design ..................................................................................... 58
Feature Roadmap and Cross-Reference ............................................................................. 59
Chapter 2 Quickstart .......................................................................................................... 65
A Really Quick Quickstart: The Blank App Template ............................................................ 65
Blank App Project Structure .......................................................................................... 68

2
QuickStart #1: Here My Am! and an Introduction to Blend for Visual Studio ........................ 72
Design Wireframes ....................................................................................................... 73
Create the Markup ....................................................................................................... 76
Styling in Blend............................................................................................................. 78
Adding the Code........................................................................................................... 83
Extra Credit: Improving the App ........................................................................................ 97
Receiving Messages from the iframe ............................................................................. 98
Improving the Placeholder Image with a Canvas Element ................................................ 99
Handling Variable Image Sizes ..................................................................................... 100
Moving the Captured Image to AppData (or the Pictures Library) .................................. 103
Using a Thumbnail Instead of the Full Image ................................................................ 105
The Other Templates: Projects and Items ........................................................................ 107
Navigation App Template............................................................................................ 107
Grid App Template ..................................................................................................... 107
Hub App Template...................................................................................................... 108
Split Template ............................................................................................................ 108
Item Templates .......................................................................................................... 108
What We’ve Just Learned ............................................................................................... 109
Chapter 3 App Anatomy and Performance Fundamentals .................................................. 111
App Activation ............................................................................................................... 112
Branding Your App 101: The Splash Screen and Other Visuals ....................................... 113
Activation Event Sequence .......................................................................................... 117
Activation Code Paths ................................................................................................. 119
WinJS.Application Events ............................................................................................ 121
Optimizing Startup Time ............................................................................................. 124
WinRT Events and removeEventListener.......................................................................... 126
App Lifecycle Transition Events and Session State ............................................................ 128
Suspend, Resume, and Terminate................................................................................ 129

3
Basic Session State in Here My Am! ............................................................................. 133
Page Controls and Navigation ......................................................................................... 136
WinJS Tools for Pages and Page Navigation .................................................................. 136
The Navigation App Template, PageControl Structure, and PageControlNavigator ......... 139
The Navigation Process and Navigation Styles .............................................................. 146
Optimizing Page Switching: Show-and-Hide ................................................................. 148
Page-Specific Styling ................................................................................................... 149
Async Operations: Be True to Your Promises .................................................................... 151
Using Promises ........................................................................................................... 151
Joining Parallel Promises ............................................................................................. 153
Sequential Promises: Nesting and Chaining .................................................................. 153
Managing the UI Thread with the WinJS Scheduler........................................................... 156
Scheduler Priorities .................................................................................................... 157
Scheduling and Managing Tasks .................................................................................. 158
Setting Priority in Promise Chains ................................................................................ 160
Long-Running Tasks .................................................................................................... 162
Debugging and Profiling.................................................................................................. 165
Debug Output and Logging.......................................................................................... 165
Error Reports and the Event Viewer............................................................................. 166
Async Debugging ........................................................................................................ 169
Performance and Memory Analysis ............................................................................. 170
The Windows App Certification Toolkit ........................................................................ 175
What We’ve Just Learned ............................................................................................... 176
Chapter 4 Web Content and Services ................................................................................ 177
Network Information and Connectivity ............................................................................ 179
Network Types in the Manifest.................................................................................... 180
Network Information (the Network Object Roster) ....................................................... 181
The ConnectionProfile Object...................................................................................... 183

4
Connectivity Events .................................................................................................... 184
Cost Awareness .......................................................................................................... 185
Running Offline .......................................................................................................... 189
Hosting Content: the WebView and iframe Elements ....................................................... 191
Local and Web Contexts (and iframe Elements) ............................................................ 192
Dynamic Content........................................................................................................ 195
App Content URIs ....................................................................................................... 197
The <x-ms-webview> Element..................................................................................... 198
HTTP Requests ............................................................................................................... 209
Using WinJS.xhr.......................................................................................................... 210
Using Windows.Web.Http.HttpClient........................................................................... 211
Suspend and Resume with Online Content................................................................... 216
Prefetching Content ................................................................................................... 218
Background Transfer ...................................................................................................... 219
Basic Downloads ........................................................................................................ 221
Basic Uploads ............................................................................................................. 225
Completion and Error Notifications ............................................................................. 226
Providing Headers and Credentials .............................................................................. 227
Setting Cost Policy ...................................................................................................... 227
Grouping Transfers ..................................................................................................... 228
Suspend, Resume, and Restart with Background Transfers ............................................ 228
Authentication, the Microsoft Account, and the User Profile ............................................ 230
The Credential Locker ................................................................................................. 231
The Web Authentication Broker .................................................................................. 233
Single Sign-On ............................................................................................................ 237
Using the Microsoft Account ....................................................................................... 238
The User Profile (and the Lock Screen Image) ............................................................... 244
What We’ve Just Learned ............................................................................................... 246

5
Chapter 5 Controls and Control Styling .............................................................................. 248
The Control Model for HTML, CSS, and JavaScript ............................................................ 249
HTML Controls ............................................................................................................... 251
Extensions to HTML Elements ..................................................................................... 254
WinJS Controls ............................................................................................................... 255
Syntax for data-win-options ........................................................................................ 259
WinJS Control Instantiation ......................................................................................... 261
Strict Processing and processAll Functions ................................................................... 262
Example: WinJS.UI.HtmlControl................................................................................... 263
Example: WinJS.UI.Rating (and Other Simple Controls) ................................................. 264
Example: WinJS.UI.Tooltip .......................................................................................... 265
Example: WinJS.UI.ItemContainer ............................................................................... 266
Working with Controls in Blend ....................................................................................... 269
Control Styling ............................................................................................................... 272
Styling Gallery: HTML Controls .................................................................................... 274
Styling Gallery: WinJS Controls .................................................................................... 276
Some Tips and Tricks .................................................................................................. 284
Custom Controls ............................................................................................................ 285
Implementing the Dispose Pattern .............................................................................. 288
Custom Control Examples ........................................................................................... 289
Custom Controls in Blend ............................................................................................ 293
What We’ve Just Learned ............................................................................................... 297
Chapter 6 Data Binding, Templates, and Collections .......................................................... 298
Data Binding .................................................................................................................. 299
Data Binding Basics..................................................................................................... 299
Data Binding in WinJS ................................................................................................. 301
Under the Covers: Binding mixins ................................................................................ 311
Programmatic Binding and WinJS.Binding.bind............................................................. 313

6
Binding Initializers ...................................................................................................... 315
Binding Templates.......................................................................................................... 319
Template Options, Properties, and Compilation ........................................................... 322
Collection Data Types ..................................................................................................... 324
Windows.Foundation.Collection Types ........................................................................ 325
WinJS Binding Lists ..................................................................................................... 331
What We’ve Just Learned ............................................................................................... 342
Chapter 7 Collection Controls ........................................................................................... 344
Collection Control Basics................................................................................................. 345
Quickstart #1: The WinJS Repeater Control with HTML controls .................................... 345
Quickstart #2: The FlipView Control Sample ................................................................. 349
Quickstart #3: The ListView Essentials Sample .............................................................. 351
Quickstart #4: The ListView Grouping Sample .............................................................. 353
ListView in the Grid App Project Template ................................................................... 357
The Semantic Zoom Control ............................................................................................ 361
How Templates Work with Collection Controls................................................................. 364
Referring to Templates ............................................................................................... 364
Template Functions (Part 1): The Basics ....................................................................... 365
Creating Templates from Data Sources in Blend ........................................................... 368
Repeater Features and Styling......................................................................................... 372
FlipView Features and Styling.......................................................................................... 377
Collection Control Data Sources ...................................................................................... 380
The Structure of Data Sources (Interfaces Aplenty!)...................................................... 381
A FlipView Using the Pictures Library ........................................................................... 384
Custom Data Sources and WinJS.UI.VirtualizedDataSource ........................................... 386
ListView Features and Styling .......................................................................................... 393
When Is ListView the Right Choice? ............................................................................. 393
Options, Selections, and Item Methods........................................................................ 395

7
Styling ....................................................................................................................... 399
Loading State Transitions ............................................................................................ 401
Drag and Drop ............................................................................................................ 402
Layouts ...................................................................................................................... 405
Template Functions (Part 2): Optimizing Item Rendering .................................................. 414
What We’ve Just Learned ............................................................................................... 419
Chapter 8 Layout and Views ............................................................................................. 421
Principles of Page Layout ................................................................................................ 423
Sizing, Scaling, and Views: The Many Faces of Your App.................................................... 426
Variable View Sizing and Orientations .......................................................................... 426
Screen Resolution, Pixel Density, and Scaling ............................................................... 437
Multiple Views ........................................................................................................... 442
Pannable Sections and Styles .......................................................................................... 446
Laying Out the Hub ..................................................................................................... 447
Laying Out the Sections .............................................................................................. 448
Panning Styles and Railing ........................................................................................... 449
Panning Snap Points and Limits ................................................................................... 451
Zooming Snap Points and Limits .................................................................................. 452
The Hub Control and Hub App Template.......................................................................... 453
Hub Control Styling..................................................................................................... 460
Using the CSS Grid .......................................................................................................... 461
Overflowing a Grid Cell ............................................................................................... 463
Centering Content Vertically ....................................................................................... 463
Scaling Font Size ......................................................................................................... 464
Item Layout ................................................................................................................... 465
CSS 2D and 3D Transforms .......................................................................................... 466
Flexbox ...................................................................................................................... 466
Nested and Inline Grids............................................................................................... 467

8
Fonts and Text Overflow ............................................................................................. 468
Multicolumn Elements and Regions ............................................................................. 470
What We’ve Just Learned ............................................................................................... 472
Chapter 9 Commanding UI ................................................................................................ 474
Where to Place Commands ............................................................................................. 475
The App Bar and Nav Bar ................................................................................................ 480
App Bar Basics and Standard Commands ..................................................................... 481
App Bar Styling ........................................................................................................... 490
Command Menus ....................................................................................................... 494
Custom App Bars ........................................................................................................ 495
Nav Bar Features ........................................................................................................ 497
Nav Bar Styling ........................................................................................................... 505
Flyouts and Menus ......................................................................................................... 507
WinJS.UI.Flyout Properties, Methods, and Events......................................................... 509
Flyout Examples ......................................................................................................... 510
Menus and Menu Commands ..................................................................................... 513
Message Dialogs ............................................................................................................ 518
Improving Error Handling in Here My Am! ....................................................................... 519
What We’ve Just Learned ............................................................................................... 525
Chapter 10 The Story of State, Part 1: App Data and Settings ............................................. 527
The Story of State........................................................................................................... 529
App Data Locations..................................................................................................... 532
App Data APIs (WinRT and WinJS) ................................................................................... 533
Settings Containers..................................................................................................... 534
State Versioning ......................................................................................................... 536
Folders, Files, and Streams.............................................................................................. 537
FileIO, PathIO, and WinJS Helpers (plus FileReader) ...................................................... 543
Encryption and Compression....................................................................................... 544

9
Q&A on Files, Streams, Buffers, and Blobs.................................................................... 544
Using App Data APIs for State Management..................................................................... 552
Transient Session State ............................................................................................... 552
Local and Temporary State.......................................................................................... 553
IndexedDB, SQLite, and Other Database Options .......................................................... 555
Roaming State ............................................................................................................ 556
Settings Pane and UI....................................................................................................... 559
Design Guidelines for Settings ..................................................................................... 561
Populating Commands ................................................................................................ 563
Implementing Commands: Links and Settings Flyouts ................................................... 566
Programmatically Invoking Settings Flyouts.................................................................. 568
Here My Am! Update ..................................................................................................... 570
What We’ve Just Learned ............................................................................................... 571
Chapter 11 The Story of State, Part 2: User Data, Files, and OneDrive ................................ 573
The Big Picture of User Data ........................................................................................... 574
Using the File Picker and Access Cache ............................................................................ 579
The File Picker UI ........................................................................................................ 580
The File Picker API ...................................................................................................... 585
Access Cache.............................................................................................................. 589
StorageFile Properties and Metadata .............................................................................. 592
Availability ................................................................................................................. 593
Thumbnails ................................................................................................................ 594
File Properties ............................................................................................................ 598
Media-Specific Properties ........................................................................................... 601
Folders and Folder Queries ............................................................................................. 607
KnownFolders and the StorageLibrary Object ............................................................... 609
Removable Storage .................................................................................................... 612
Simple Enumeration and Common Queries .................................................................. 613

10
Custom Queries.......................................................................................................... 618
Metadata Prefetching with Queries ............................................................................. 623
Creating Gallery Experiences........................................................................................... 625
File Activation and Association ........................................................................................ 627
What We’ve Just Learned ............................................................................................... 632
Chapter 12 Input and Sensors ........................................................................................... 634
Touch, Mouse, and Stylus Input ...................................................................................... 635
The Touch Language and Mouse/Keyboard Equivalents ................................................ 636
What Input Capabilities Are Present? .......................................................................... 643
Unified Pointer Events ................................................................................................ 645
Gesture Events ........................................................................................................... 649
The Gesture Recognizer .............................................................................................. 658
Keyboard Input and the Soft Keyboard ............................................................................ 659
Soft Keyboard Appearance and Configuration .............................................................. 660
Adjusting Layout for the Soft Keyboard ........................................................................ 663
Standard Keystrokes ................................................................................................... 666
Inking ............................................................................................................................ 667
Geolocation ................................................................................................................... 669
Geofencing ................................................................................................................ 673
Sensors.......................................................................................................................... 676
What We’ve Just Learned ............................................................................................... 680
Chapter 13 Media............................................................................................................. 681
Creating Media Elements ................................................................................................ 682
Graphics Elements: Img, Svg, and Canvas (and a Little CSS) ............................................... 684
Additional Characteristics of Graphics Elements ........................................................... 688
Some Tips and Tricks .................................................................................................. 689
Rendering PDFs .......................................................................................................... 694
Video Playback and Deferred Loading.............................................................................. 699

11
Disabling Screen Savers and the Lock Screen During Playback ....................................... 703
Video Element Extension APIs ..................................................................................... 703
Applying a Video Effect ............................................................................................... 705
Browsing Media Servers.............................................................................................. 706
Audio Playback and Mixing ............................................................................................. 706
Audio Element Extension APIs ..................................................................................... 708
Playback Manager and Background Audio .................................................................... 708
The Media Transport Control UI .................................................................................. 714
Playing Sequential Audio ............................................................................................. 717
Playlists ......................................................................................................................... 719
Text to Speech ............................................................................................................... 723
Loading and Manipulating Media .................................................................................... 725
Image Manipulation and Encoding............................................................................... 726
Manipulating Audio and Video .................................................................................... 732
Handling Custom Audio and Video Formats ................................................................. 735
Media Capture ............................................................................................................... 742
Flexible Capture with the MediaCapture Object ........................................................... 744
Selecting a Media Capture Device................................................................................ 748
Streaming Media and Play To .......................................................................................... 751
Streaming from a Server and Digital Rights Management.............................................. 751
Streaming from App to Network.................................................................................. 753
Play To ....................................................................................................................... 754
What We Have Learned .................................................................................................. 757
Chapter 14 Purposeful Animations.................................................................................... 759
Systemwide Enabling and Disabling of Animatio ns ........................................................... 761
The WinJS Animations Library ......................................................................................... 762
Animations in Action .................................................................................................. 765
CSS Animations and Transitions ...................................................................................... 769

12
Designing Animations in Blend for Visual Studio ........................................................... 775
The HTML Independent Animations Sample ................................................................. 777
Rolling Your Own: Tips and Tricks .................................................................................... 779
What We’ve Just Learned ............................................................................................... 785
Chapter 15 Contracts ........................................................................................................ 786
Share ............................................................................................................................. 788
Share Source Apps...................................................................................................... 793
Share Target Apps ...................................................................................................... 805
The Clipboard............................................................................................................. 816
Launching Apps with URI Scheme Associations ................................................................ 818
Search ........................................................................................................................... 823
The Search Charm UI .................................................................................................. 825
The WinJS.UI.SearchBox Control.................................................................................. 829
Providing Query Suggestions ....................................................................................... 831
Providing Result Suggestions ....................................................................................... 835
SearchBox Styling ....................................................................................................... 837
Indexing and Searching Content .................................................................................. 840
The Search Contract ................................................................................................... 849
Contacts ........................................................................................................................ 850
Contact Cards............................................................................................................. 850
Using the Contact Picker ............................................................................................. 856
Appointments ................................................................................................................ 860
What We’ve Just Learned ............................................................................................... 864
Chapter 16 Alive with Activity: Tiles, Notifications, the Lock Screen, and
Background Tasks.............................................................................................................. 865
Alive with Activity: A Visual Tour ..................................................................................... 866
The Four Sources of Updates and Notifications ................................................................ 875
Tiles, Secondary Tiles, and Badges ................................................................................... 878

13
Secondary Tiles .......................................................................................................... 880
Basic Tile Updates ...................................................................................................... 887
Cycling, Scheduled, and Expiring Updates .................................................................... 900
Badge Updates ........................................................................................................... 902
Periodic Updates ............................................................................................................ 904
Creating an Update Service ......................................................................................... 907
Debugging a Service Using the Localhost...................................................................... 911
Windows Azure and Azure Mobile Services .................................................................. 912
Toast Notifications ......................................................................................................... 917
Creating Basic Toasts .................................................................................................. 919
Butter and Jam: Options for Your Toast ....................................................................... 921
Tea Time: Scheduled Toasts and Alarms....................................................................... 923
Toast Events and Activation ........................................................................................ 926
Push Notifications and the Windows Push Notification Service ......................................... 927
Requesting and Caching a Channel URI (App) ............................................................... 929
Managing Channel URIs (Service) ................................................................................ 931
Sending Updates and Notifications (Service) ................................................................ 932
Raw Notifications (Service).......................................................................................... 933
Receiving Notifications (App) ...................................................................................... 934
Debugging Tips ........................................................................................................... 935
Tools and Providers for Push Notifications ................................................................... 935
Background Tasks and Lock Screen Apps.......................................................................... 937
Background Tasks in the Manifest ............................................................................... 938
Building and Registering Background Tasks .................................................................. 939
Conditions ................................................................................................................. 941
Tasks for Maintenance Triggers ................................................................................... 942
Tasks for System Triggers (Non-Lock Screen) ................................................................ 944
Lock Screen–Dependent Tasks and Triggers ................................................................. 945

14
Debugging Background Tasks ...................................................................................... 949
What We’ve Just Learned (Whew!) ................................................................................. 950
Chapter 17 Devices and Printing ....................................................................................... 952
Declaring Device Access.................................................................................................. 956
Enumerating and Watching Devices ................................................................................ 957
Scenario API Devices ...................................................................................................... 962
Image Scanners .......................................................................................................... 962
Barcode and Magnetic Stripe Readers (Point-of-Service Devices) .................................. 967
Smartcards................................................................................................................. 970
Fingerprint (Biometric) Readers................................................................................... 971
Bluetooth Call Control ................................................................................................ 972
Printing Made Easy......................................................................................................... 973
The Printing User Experience ...................................................................................... 974
Print Document Sources ............................................................................................. 977
Providing Print Content and Configuring Options.......................................................... 979
Protocol APIs: HID, USB, Bluetooth, and Wi-Fi Direct ........................................................ 981
Human Interface Devices (HID).................................................................................... 983
Custom USB Devices ................................................................................................... 990
Bluetooth (RFCOMM) ................................................................................................. 992
Bluetooth Smart (LE/GATT) ......................................................................................... 996
Wi-Fi Direct ................................................................................................................ 999
Near Field Communication and the Proximity API............................................................1000
Finding Your Peers (No Pressure!) ..............................................................................1002
Sending One-Shot Payloads: Tap to Share ...................................................................1007
What We’ve Just Learned ..............................................................................................1009
Chapter 18 WinRT Components: An Introduction .............................................................1010
Choosing a Mixed Language Approach (and Web Workers)..............................................1012
Quickstarts: Creating and Debugging Components ..........................................................1014

15
Quickstart #1: Creating a Component in C# .................................................................1015
Simultaneously Debugging Script and Managed/Native Code .......................................1020
Quickstart #2: Creating a Component in C++ ...............................................................1021
Comparing the Results ...............................................................................................1023
Key Concepts for WinRT Components.............................................................................1026
Implementing Asynchronous Methods .......................................................................1028
Projections into JavaScript .........................................................................................1042
Scenarios for WinRT Components ..................................................................................1044
Higher Performance (Perhaps) ...................................................................................1044
Access to Additional APIs ...........................................................................................1047
Obfuscating Code and Protecting Intellectual Property ................................................1051
Concurrency..............................................................................................................1052
Library Components ..................................................................................................1053
What We’ve Just Learned ..............................................................................................1056
Chapter 19 Apps for Everyone, Part 1: Accessibility and World-Readiness .........................1058
Accessibility ..................................................................................................................1059
Screen Readers and Aria Attributes ............................................................................1063
Handling Contrast Variations ......................................................................................1068
World Readiness and Localization ..................................................................................1075
Globalization .............................................................................................................1077
Preparing for Localization ..........................................................................................1087
Creating Localized Resources: The Multilingual App Toolkit ..........................................1101
Localization Wrap-Up ................................................................................................1108
What We’ve Just Learned ..............................................................................................1109
Chapter 20 Apps for Everyone, Part 2: The Windows Store .............................................1110
Your App, Your Business ................................................................................................1111
Planning: Can the App Be a Windows Store App? ........................................................1113
Planning for Monetization (or Not) .............................................................................1114

16
Growing Your Customer Base and Other Value Exchanges ...........................................1125
Measuring and Experimenting with Revenue Performance ..........................................1126
The Windows Store APIs ................................................................................................1127
The CurrentAppSimulator Object................................................................................1130
Trial Versions and App Purchase.................................................................................1133
Listing and Purchasing In-App Products.......................................................................1137
Handling Large Catalogs .............................................................................................1145
Receipts ....................................................................................................................1146
Instrumenting Your App for Telemetry and Analytics .......................................................1148
Releasing Your App to the World....................................................................................1155
Promotional Screenshots, Store Graphics, and Text Copy.............................................1156
Testing and Pre-Certification Tools .............................................................................1158
Creating the App Package ..........................................................................................1159
Onboarding and Working through Rejection ...............................................................1163
App Updates .................................................................................................................1166
Getting Known: Marketing, Discoverability, and the Web ................................................1168
Connecting Your Website and Web-Mapped Search Results ........................................1170
Face It: You’re Running a Business! ................................................................................1171
Look for Opportunities...............................................................................................1172
Invest in Your Business ..............................................................................................1172
Fear Not the Marketing .............................................................................................1172
Support Your Customers ............................................................................................1173
Plan for the Future ....................................................................................................1173
Selling Your App When It’s Not Running......................................................................1174
You’re Not Alone .......................................................................................................1175
Final Thoughts: Qualities of a Rock Star App ...................................................................1175
What We’ve Just Learned ..............................................................................................1176
Appendix A Demystifying Promises..................................................................................1178

17
What Is a Promise, Exactly? The Promise Relationships ...................................................1178
The Promise Construct (Core Relationship) .....................................................................1181
Example #1: An Empty Promise! .................................................................................1183
Example #2: An Empty Async Promise.........................................................................1185
Example #3: Retrieving Data from a URI ......................................................................1186
Benefits of Promises ......................................................................................................1187
The Full Promise Construct ............................................................................................1188
Nesting Promises.......................................................................................................1192
Chaining Promises .....................................................................................................1195
Promises in WinJS (Thank You, Microsoft!) .....................................................................1200
The WinJS.Promise Class ............................................................................................1201
Originating Errors with WinJS.Promise.WrapError .......................................................1203
Some Interesting Promise Code .....................................................................................1204
Delivering a Value in the Future: WinJS.Promise.timeout .............................................1204
Internals of WinJS.Promise.timeout ............................................................................1205
Parallel Requests to a List of URIs ...............................................................................1205
Parallel Promises with Sequential Results ...................................................................1206
Constructing a Sequential Promise Chain from an Array...............................................1208
PageControlNavigator._navigating (Page Control Rendering) .......................................1208
Bonus: Deconstructing the ListView Batching Renderer ...................................................1210
Appendix B WinJS Extras .................................................................................................1214
Exploring WinJS.Class Patterns .......................................................................................1214
WinJS.Class.define .....................................................................................................1214
WinJS.Class.derive .....................................................................................................1217
Mixins.......................................................................................................................1218
Obscure WinJS Features ................................................................................................1219
Wrappers for Common DOM Operations ....................................................................1219
WinJS.Utilities.data, convertToPixels, and Other Positional Methods ............................1221

18
WinJS.Utilities.empty, eventWithinElement, and getMember ......................................1222
WinJS.UI.scopedSelect and getItemsFromRanges ........................................................1222
Extended Splash Screens ...............................................................................................1223
Adjustments for View Sizes ........................................................................................1229
Custom Layouts for the ListView Control ........................................................................1231
Minimal Vertical Layout .............................................................................................1233
Minimal Horizontal Layout .........................................................................................1235
Two-Dimensional and Nonlinear Layouts ....................................................................1239
Virtualization ............................................................................................................1241
Grouping...................................................................................................................1243
The Other Stuff .........................................................................................................1244
Appendix C Additional Networking Topics........................................................................1249
XMLHttpRequest and WinJS.xhr .....................................................................................1249
Tips and Tricks for WinJS.xhr ......................................................................................1250
Breaking Up Large Files (Background Transfer API) ..........................................................1251
Multipart Uploads (Background Transfer API) .................................................................1252
Notes on Encryption, Decryption, Data Protection, and Certificates .................................1255
Syndication: RSS, AtomPub, and XML APIs in WinRT ........................................................1255
Reading RSS Feeds .....................................................................................................1256
Using AtomPub .........................................................................................................1259
Sockets .........................................................................................................................1260
Datagram Sockets......................................................................................................1261
Stream Sockets..........................................................................................................1265
Web Sockets: MessageWebSocket and StreamWebSocket...........................................1268
The ControlChannelTrigger Background Task ..............................................................1273
The Credential Picker UI ................................................................................................1273
Other Networking SDK Samples .....................................................................................1277
Appendix D Provider-Side Contracts ................................................................................1279

19
File Picker Providers ......................................................................................................1279
Manifest Declarations................................................................................................1280
Activation of a File Picker Provider..............................................................................1281
Cached File Updater ......................................................................................................1288
Updating a Local File: UI.............................................................................................1291
Updating a Remote File: UI ........................................................................................1292
Update Events ...........................................................................................................1294
Contact Cards Action Providers ......................................................................................1297
Contact Picker Providers ................................................................................................1300
Appointment Providers..................................................................................................1303
About the Author .............................................................................................................1309

20
Introduction
Welcome, my friends, to Windows 8.1! On behalf of the thousands of designers, program managers,
developers, test engineers, and writers who have brought the product to life, I'm del ighted to welcome
you into a world of Windows Reimagined.

This theme is no mere sentimental marketing ploy, intended to bestow an aura of newness to
something that is essentially unchanged, like those household products that make a big splash on the
idea of "New and Improved Packaging!" No, starting with version 8, Microsoft Windows truly has been
reborn—after more than a quarter-century, something genuinely new has emerged.

I suspect—indeed expect—that you're already somewhat familiar with the reimagined user
experience of Windows 8 and Windows 8.1. You're probably reading this book, in fact, because you
know that the ability of Windows to reach across desktop, laptop, and tablet devices, along with the
global reach of the Windows Store, will provide you with many business opportunities, whether you're
in business, as I like to say, for fame, fortune, fun, or philanthropy.

We'll certainly see many facets of this new user experience throughout the course of this book. Our
primary focus, however, will be on the reimagined developer experience.

I don't say this lightly. When I first began giving presentations within Microsoft about building
Windows Store apps, I liked to show a slide of what the world was like in the year 1985. It was the time
of Ronald Reagan, Margaret Thatcher, and Cold War tensions. It was the time of VCRs and the
discovery of AIDS. It was when Back to the Future was first released, Michael Jackson topped the charts
with Thriller, and Steve Jobs was kicked out of Apple. And it was when software developers got their
first taste of the original Windows API and the programming model for desktop applications.

The longevity of that programming model has been impressive. It's been in place for nearly three
decades now and has grown to become the heart of the largest business ecosystem on the planet. The
API itself, known today as Win32, has also grown to become the largest on the planet! What started
out on the order of about 300 callable methods has expanded three orders of magnitude, well beyond
the point that any one individual could even hope to understand a fraction of it. I'd certainly given up
such futile efforts myself.

So when I bumped into my old friend Kyle Marsh in the fall of 2009, just after Windows 7 had been
released, and heard from him that Microsoft was planning to reinvigorate native app development for
Windows 8, my ears were keen to listen. In the months that followed I learned that Microsoft was
introducing a completely new API called the Windows Runtime (or WinRT). This wasn't mea nt to
replace Win32, mind you; desktop applications would still be supported. No, this was a programming
model built from the ground up for a new breed of touch-centric, immersive apps that could compete
with those emerging on various mobile platforms. It would be designed from the app developer's point
of view, rather than the system's, so that key features would take only a few lines of code to implement

21
rather than hundreds or thousands. It would also enable direct native app development in multiple
programming languages. This meant that new operating system capabilities would surface to those
developers without having to wait for an update to some intermediate framework. It also meant that
developers who had experience in any one of those language choices would find a natural home when
writing apps for Windows 8 and Windows 8.1.

This was very exciting news to me because the last time that Microsoft did anything significant to
the Windows programming model was in the early 1990s with a technology called the Component
Object Model (COM), which is exactly what allowed the Win32 API to explode as it did. Ironically, it was
my role at that time to introduce COM to the developer community, which I did through two editions
of Inside OLE (Microsoft Press, 1993 and 1995) and seemingly endless travel to speak at conferences
and visit partner companies. History, indeed, does tend to repeat itself, for here I am again, with
another second edition!

In December 2010, I was part of the small team who set out to write the very first Windows Store
apps using what parts of the new WinRT API had become available. Notepad was the text editor of
choice, we built and ran apps on the command line by using abstruse Powershell scripts that required
us to manually type out ungodly hash strings, we had no documentation other than oft-incomplete
functional specifications, and we basically had no debugger to speak of other than the tried and true
window.alert and document.writeln. Indeed, we generally worked out as much HTML, CSS, and
JavaScript as we could inside a browser with F12 debugging tools, adding WinRT-specific code only at
the end because browsers couldn't resolve those APIs. You can imagine how we celebrated when we
got anything to work at all!

Fortunately, it wasn't long before tools like Visual Studio Express and Blend for Visual Studio became
available. By the spring of 2011, when I was giving many training sessions to people inside Microsoft on
building apps for Windows 8, the process was becoming far more enjoyable and exc eedingly more
productive. Indeed, while it took us four to six weeks in late 2010 to get even Hello World to show up
on the screen, by the fall of 2011 we were working with partner companies who pulled together
complete Store-ready apps in roughly the same amount of time.

As we've seen—thankfully fulfilling our expectations—it's possible to build a great app in a matter
of weeks. I'm hoping that this ebook, along with the extensive resources on http://dev.windows.com,
will help you to accomplish exactly that and to reimagine your own designs.

Work on this second edition began almost as soon as the first edition was released. (I’d make a quip
about the ink not being dry, but that analogy doesn’t work for an ebook!) When Windows 8 became
generally available in the fall of 2012, work on Windows 8.1 was already well underway: the
engineering team had a long list of improvements they wanted to make along with features that they
weren’t able to complete for Windows 8. And in the very short span of one year, Windows 8.1 was itself
ready to ship.

At first I thought writing this second edition would be primarily a matter of making small updates to
each chapter and perhaps adding some pages here and there on a handful of new features. But as I got
deeper into the updated platform, I was amazed at just how much the API surface area had expanded!
22
Windows 8.1 introduces a number of additional controls, an HTML webview element, a stronger HTTP
API, content indexing, deeper OneDrive support, better media capabilities, more tiles sizes (small and
large), more flexible secondary tile, access to many kinds of peripheral devices, and more options for
working with the Windows Store, like consumable in-app purchases. And clearly, this is a very short list
of distinct Windows 8.1 features that doesn’t include the many smaller changes to the API. (A fuller list
can be found on Windows 8.1: New APIs and features for developers).

Furthermore, even as I was wrapping up the first edition of this book, I already had a long list of
topics I wanted to explore in more depth. I wrote a number of those pieces for my blog, with the
intention of including them in this second edition. A prime example is Appendix A, “Demystifying
Promises.”

All in all, then, what was already a very comprehensive book in the first edition has become even
more so in the second! Fortunately, with this being an ebook, neither you nor I need feel guilty about
matters of deforestation. We can simply enjoy the process of learning about and writing Windows
Store Apps with HTML, CSS, and JavaScript.

And what about Windows Phone 8.1? I’m glad you asked, because much of this book is completely
applicable to that platform. Yes, that’s right: Windows Phone 8.1 supports writing apps in HTML, CSS,
and JavaScript, just like Windows 8.1, meaning that you have the same flexibility of implementation
languages on both. However, the decision to support JavaScript apps on Windows Phone 8.1 came very
late in the production of this book, so I’m only able to make a few notes here and there for Phone -
specific concerns. I encourage you to follow the Building Apps for Windows blog, where we’ll be
posting more about the increasingly unified experience of Windows and Windows Phone.

Who This Book Is For

This book is about writing Windows Store apps using HTML, CSS, and JavaScript. Our primary focus will
be on applying these web technologies within the Windows platform, where there are unique
considerations, and not on exploring the details of those web technologies themselves. For the most
part, I'm assuming that you're already at least somewhat conversant with these standards. We will cover
some of the more salient areas like the CSS grid, which is central to app layout, but otherwise I trust
that you're capable of finding appropriate references for most everything else. For Java Script
specifically, I can recommend Rey Bango’s Required JavaScript Reading list, though I hope you’ll spend
more time reading this book than others!

I'm also assuming that your interest in Windows has at least two basic motivations. One, you
probably want to come up to speed as quickly as you can, perhaps to carve out a foothold in the
Windows Store sooner rather than later. Toward that end, Chapter 2, “Quickstart,” gives you an
immediate experience with the tools, APIs, and some core aspects of app development and the
platform. On the other hand, you probably also want to make the best app you can, one that performs
really well and that takes advantage of the full extent of the platform. Toward this end, I've also

23
endeavored to make this book comprehensive, helping you at least be aware of what's possible and
where optimizations can be made.

Let me make it clear, though, that my focus in this book is the Windows pla tform. I won’t talk much
about third-party libraries, architectural considerations for app design, and development strategies and
best practices. Some of these will come up from time to time, but mostly in passing.

Nevertheless, many insights have come from working directly with real-world developers on their
real-world apps. As part of the Windows Ecosystem team, myself and my teammates have been on the
front lines bringing those first apps to the Windows Store. This has involved writing bits of code for
those apps and investigating bugs, along with conducting design, code, and performance reviews with
members of the Windows engineering team. As such, one of my goals with this book is to make that
deep understanding available to many more developers, including you!

What You'll Need (Can You Say “Samples”?)

To work through this book, you should have Windows 8.1 (or a later update) installed on your
development machine, along with the Windows SDK and tools. All the tools, along with a number of
other resources, are listed on Developer Downloads for Windows Store Apps. You’ll specifically need
Microsoft Visual Studio Express 2013 for Windows. (Note that for all the screenshots in this book, I
switched Visual Studio from its default “dark” color theme to the “light” theme, as the latter works
better against a white page.)

We’ll also acquire other tools along the way as we need them in this ebook, specifically to run some
of the examples in the companion content. Here’s the short list:

 Live SDK (for Chapter 4)

 Bing Maps SDK for Windows Store Apps (for Chapters 10 and beyond)

 Visual Studio Express 2013 for Web (for Chapter 16)

 Multilingual App Toolkit (for Chapter 19)

Also be sure to visit the Windows 8.1 Samples Pack page and download at least the JavaScript
samples. We'll be drawing from many—if not most—of these samples in the chapters ahead, pulling in
bits of their source code to illustrate how many different tasks are accomplished.

One of my secondary goals in this book, in fact, is to help you understand where and when to use
the tremendous resources in what is clearly the best set of samples I’ve ever seen for any release of
Windows. You’ll often be able to find a piece of code in one of the samples that does exactly what you
need in your app or that is easily modified to suit your purpose. For this reason I’ve made it a point to
personally look through every one of the JavaScript samples, understand what they demonstrate, and
then refer to them in their proper context. This, I hope, will save you the trouble of having to do that
level of research yourself and thus make you more productive in your development efforts.

24
In some cases I’ve taken one of the SDK samples and made certain modifications, typically to
demonstrate an additional feature but sometimes to fix certain bugs or demonstrate a better
understanding that came about after the sample had to be finalized. I’ve included these modifications
in the companion content for this book, which you can download at

http://aka.ms/BrockschmidtBook2/CompContent

The companion content also contains a few additional examples of my own, which I always refer to
as “examples” to make it clear that they aren’t official SDK content. (I’ve also rebranded the modified
samples to make it clear that they’re part of this book.) I’ve written these examples to fill gaps that the
SDK samples don’t address or to provide a simpler demonstration of a feature that a related sample
shows in a more complex manner. You’ll also find many revisions of an app called “Here My Am!” that
we’ll start building in Chapter 2 and we’ll refine throughout the course of this book. This includes
localizing it into a number of different languages by the time we reach the end.

There are also a number of videos that I’ve made for this book, which more readily show dynamic
effects like animations and user interaction. You can find all of them at

http://aka.ms/BrockschmidtBook2/Videos

Beyond all this, you’ll find that the Windows Store app samples gallery as well as the Visual Studio
sample gallery let you search and browse projects that have been contributed by other developers —
perhaps also you! (On the Visual Studio site, by the way, be sure to filter on Windows Store apps
because the gallery covers all Microsoft platforms.) And of course, there will be many more developers
who share projects on their own.

In this book I occasionally refer to posts on a number of blogs. First are a few older blogs, namely
the Windows 8 App Developer blog, the Windows Store for Developers blog, and—for the Windows 8
backstory of how Microsoft approached this whole process of reimagining the operating system —the
Building Windows 8 blog. As of the release of this book, the two developer blogs have merged into the
Building Apps for Windows blog that I mentioned earlier.

A Formatting Note

Throughout this book, identifiers that appear in code, such as variable names, property names, and API
functions and namespaces, are formatted with a color and a fixed-point font. Here’s an example:
Windows.Storage.ApplicationData.current . At times, certain fully qualified names—those that that
include the entire namespace—can become quite long, so it’s necessary to occasionally hyphenate
them across line breaks, as in Windows.Security.Cryptography.CryptographicBuffer.-
convertStringToBinary. Generally speaking, I’ve tried to hyphenate after a dot or between whole
words but not within a word. In any case, these hyphens are never part of the identifier except in CSS
where hyphens are allowed (as in -ms-high-contrast-adjust) and with HTML attributes like aria-
label or data-win-options.

25
Occasionally, you’ll also see identifiers that have a different color, as in datarequested. These
specifically point out events that originate from Windows Runtime objects, for which there are a few
special considerations for adding and removing event listeners in JavaScript, as discussed toward the
end of Chapter 3. I make a few reminders about this point throughout the chapters, but the purpose of
this special color is to give you a quick reminder that doesn’t break the flow of the discussion
otherwise.

Acknowledgements

In many ways, this isn't my book—that is, it's not an account of my own experiences and opinions
about writing apps for Windows. I'm serving more as a storyteller, where the story itself has been
written by the thousands of people in the Windows team whose passion and dedication have been a
constant source of inspiration. Writing a book like this wouldn't be possible without all the work that's
gone into customer research; writing specs; implementing, testing, and documenting all the details;
managing daily builds and public releases; and writing again the best set of samples I've ever seen for a
platform. Indeed, the words in some sections come directly from conversations I've had with the people
who designed and developed a particular feature. I'm grateful for their time, and I’m delighted to give
them a voice through which they can share their passion for excellence with you.

A number of individuals deserve special mention for their long-standing support of this project. To
Mahesh Prakriya, Ian LeGrow, Anantha Kancherla, Keith Boyd and their respective teams, with whom
I've worked closely, and to Kathy Carper, Roger Gulrajani, Keith Rowe, Dennis Flanagan, and Adam
Denning, under whom I've had the pleasure of serving.

Thanks also to Devon Musgrave at Microsoft Press, who put in many long hours editing my many
long chapters, many times over. My teammates, Kyle Marsh, Todd Landstad, Shai Hinitz, Patrick
Dengler, Lora Heiny, Leon Braginski, and Joseph Ngari have also been invaluable in sharing what
they've learned in working with real-world partners. A special thanks goes to Kenichiro Tanaka of
Microsoft Japan, for always being the first one to return a reviewed chapter to me and for joyfully
researching different areas of the platform whenever I asked. Many bows to you, my friend! Nods also
to others in our international Windows Ecosystem teams who helped with localizing the Here My Am!
app for Chapter 19: Gilles Peingné, Sam Chang, Celia Pipó Garcia, Juergen Schwertl, Maarten van de
Bospoort, Li-Qun Jia, and Shai Hinitz.

The following individuals all contributed to this book as well, with chapter reviews, answers to my
questions, deep discussions of the details, and much more. I’m grateful to all of you for your time and
support:

Shakil Ahmed Ryan Demopoulos Jakub Kotynia Jason Olson Adam Stritzel

Arvind Aiyar Scott Dickens Jared Krinke Elliot H Omiya Shijun Sun

Jessica Alspaugh Tyler Donahue Victoria Kruse Lisa Ong Ellick Sung

Gaurav Anand Brendan Elliott Nathan Kuchta Larry Osterman Sou Suzuki

26
Chris Anderson Matt Esquivel Elmar Langholz Rohit Pagariya Simon Tao

Erik Anderson David Fields Bonny Lau Ankur Patel Henry Tappen

Axel Andrejs Sean Flynn Wonhee Lee Harry Pierson Chris Tavares

Tarek Ayna Erik Fortune Travis Leithead Steve Proteau David Tepper

Art Baker Jim Galasyn Dale Lemieux Hari Pulapaka Lillian Tseng

Adam Barrus Gavin Gear Chantal Leonard Arun Rabinar Sara Thomas

Megan Bates Derek Gephard Cameron Lerum* Matt Rakow Ryan Thompson

Tyler Beam Marcelo Garcia Gonzalez Brian LeVee Ramu Ramanathan Bill Ticehurst

Matthew Beaver Sean Gilmour Jianfeng Lin Sangeeta Ranjit Peter Torr

Kyle Beck Sunil Gottumukkala Tian Luo Ravi Rao Stephen Toub

Ben Betz Scott Graham Sean Lyndersay Brent Rector Tonu Vanatalu

Johnny Bregar Ben Grover David Machaj Ruben Rios Jeremy Viegas

John Brezak Paul Gusmorino Mike Mastrangelo Dale Rogerson Alwin Vyhmeister

John Bronskill Chris Guzak Jordan Matthiesen Nick Rotondo Nick Waggoner

Jed Brown Zainab Hakim Ian McBurnie David Rousset David Washington

Kathy Carper Rylan Hawkins Sarah McDevitt George Roussos Sarah Waskom

Vincent Celie John Hazen Isaac McGarvey Jake Sabulsky Marc Wautier

Raymond Chen Jerome Holman Jesse McGatha Gus Salloum Josh Williams

Rian Chung Scott Hoogerwerf Matt Merry Michael Sciacqua Lucian Wischik

Arik Cohen Stephen Hufnagel Markus Mielke Perumaal Shanmugam Dave Wood

Justin Cooperman Sean Hume Pavel Minaev Edgar Ruiz Silva Kevin Michael Woley

Michael Crider Mathias Jourdain John Morrow Poorva Singal Charing Wong

Monica Czarny Damian Kedzierski Feras Moussa Karanbir Singh Bernardo Zamora

Nigel D’Souza Suhail Khalid John Mullaly Peter Smith Michael Ziller

Priya Dandawate Deen King-Smith Jan Nelson* Sam Spencer

Darren Davis Daniel Kitchener Marius Niculescu Edward Sproull

Jack Davis Kishore Kotteri Daniel Oliver Ben Srour

* For Jan and Cameron, a special acknowledgement for riding down from Redmond, Washington, to visit me in
Portland, Oregon (where I was living at the time), and sharing an appropriately international Thai lunch while we
discussed localization and multilingual apps.

Let me add that during the production of this second edition, I did manage to lose the extra weight
that I’d gained during the first edition. All things must balance out, I suppose!

Finally, special hugs to my wife Kristi and our son Liam (now seven and a half), who have lovingly

27
been there the whole time and who don't mind my traipsing through the house to my office either late
at night or early in the morning.

Free Ebooks from Microsoft Press

From technical overviews to drilldowns on special topics, these free ebooks are available in PDF, EPUB,
and/or Mobi for Kindle formats, ready for you to download:

http://aka.ms/mspressfree

The “Microsoft Press Guided Tours” App

Check the Windows Store soon for the Microsoft Press Guided Tours app, which provides insightful
tours of new and evolving technologies created by Microsoft. While you’re exploring each tour’s
original content, the app lets you manipulate and mark that content in ways to make it more useful to
you. You can, of course, do the usual things—such as highlight, add notes, mark as favorite, and mark
to read later—but you can also

 view all links to external documentation and samples in one place via a Resources view;
 sort the Resources view by Favorites, Read Later, and Noted;
 view a list of all your notes and highlights via the app bar;
 share text, code, or links to resources with friends via email; and
 create your own list of resources, as you navigate online resources, beyond those pointed to in the
Guided Tour.

Our first Guided Tour is based on this ebook. Kraig acts as a guide in two senses: he leads
experienced web developers through the processes and best practices for building Windows Store
apps, and he guides you through Microsoft’s extensive developer documentation, pointing you to the
appropriate resources at each step in your app development process so that you can build your apps as
effectively as possible.

Enjoy the app, and we look forward to providing more Guided Tours soon!

Errata & Book Support

We’ve made every effort to ensure the accuracy of this ebook and its companion content. Any errors
that are reported after the book’s publication will be listed on http://aka.ms/BrockschmidtBook2/Errata.
If you find an error that is not already listed, you can report it to us through the comments area of the
same page.

28
Another Random Scribd Document
with Unrelated Content
sieltä kukkui ja mahtui puulaatikkoon puittenkin päälle ja melkeinpä
seinän rakoon.

— Äiti, olisi paljon hauskempi, jos olisit poika ja yhtä vanha kuin
minä. Silloin leikittäisiin kaiket päivät yhdessä.

— Mutta kuka silloin olisi äitinä?

Niin. Se oli totta. Ei sekään käynyt päinsä.

— Mutta jos löytäisit pienen tytön? Etsi se minulle, että minulla


olisi edes pieni sisar. Ei sentään sellainen aivan pieni, jolla ei mitään
tee. Ei sellainen kuin on Väinöllä!

Se oli ollut pettymys! He olivat eräänä päivänä vesitynnyrissä


pihalla antaneet laivansa purjehtia, olivat Viipurissa lastanneet ne
sorajyvillä ja Pietarissa sahajauhoilla, pitäen huolta Suomen ja
Venäjän kauppasuhteista, kun tultiin ilmoittamaan, että Väinölle oli
tullut pieni sisar. Se kapsahti alas kuin taivaasta. Kerrottiin, että
Väinön äiti oli saapunut kotiin Pietarista ja oli tuonut sen tullessaan.
Siis löydetty! Väinölle oli se jo löydetty! Molemmilla pojilla oli silmät
kuin napit päässä, ja sanaakaan sanomatta he jättivät laivansa
haaksirikkoutumaan, pinkaisten juoksujalassa heti paikalla
katsomaan tuota uutta tulokasta.

Mutta hetkisen kuluttua he taas puuhasivat vesitynnyrinsä ääressä


näpeillään napsahuttaen laivansa liikkeelle ja terävästi viheltäen
lähdön tai tulon merkiksi, aivan kuin ei mitään olisi tapahtunutkaan.

— No, ettekö ole nähneet Väinön pientä sisarta?

— Kyllä, mutta se on niin joutavan pieni. Ei pitäisi niin pieniä lapsia


ollakaan.
Väinön sisarjuttu oli siis täydelleen epäonnistunut. Eikä siitä
kannattanut sen enempää puhuakaan pitkiin aikoihin. Se siellä vain
vasussaan vikisi ja suutaan väänteli ja pillahti väliin kohti kurkkua
parkumaan. Kun kerran lähtivät, niin olisivat paremmin pitäneet
silmänsä auki.

Nyt ei ollut toivoa muusta kuin Yrjön äidistä. Mitä hän mahdollisesti
saisi aikaan.

Illalla maatapannessa Yrjö jutteli siitä äidilleen:

— Parasta olisi, kun lähtisit hakemaan meille pienen tytön,


tuollaisen vähän suuremman, joka jo juoksee ja osaa puhua, niin
että sen kanssa voi leikkiä. Mutta älä sinä mene Pietariin, vaan
jonnekin muuanne!

— Pitäisihän minun tässä koettaa — tuumaili äiti hymähtäen —


mutta ei sitä noin vaan kädenkäänteessä valmista saa sellaisissa
asioissa.

— Löysithän sinä minutkin. Ja ottaisit tuollaisen noin suuren — tai


ainakin noin — jolla ei ole isää eikä äitiä, eikä Maijaakaan.

Jaa-a. Sellaista ei voinut jättää ottamatta. Pojan ääni kävi ihan


kimakaksi myötätunnosta niin tuiki turvatonta olentoa ajatellessaan.
Mutta sitten hänen kasvonsa kirkastuivat hänen kuvitellessaan miten
erinomaisesti kaikki järjestyisi:

— Ja sinä tulisit hänen äidikseen ja isä hänen isäkseen ja Maija


hänen
Maijakseen!
Niin, pitihän sitä ajatella. Ja päätettiin sanoa Maijallekin, että hän
torilla ja puodissa käydessään pitäisi varansa, jos hyvinkin sattuisi
tiellä vastaan tulemaan.

Mutta vaikkei äiti virunutkaan pitkällään lattialla eikä ryöminyt


vuoteitten alle eikä, sen pahempi, edes ampunut maaliin jousella tai
lätkäyttänyt kärpäsiä kuoliaaksi eureka-pyssyllä, oli hän sentään
hänen kaikkein paras ystävänsä. Entä isä? Isä tietysti myöskin.
Kaikkein paras. Isä kun joskus otti häntä kädestä ja vei hänet
Valleille, josta näkyi se konepaja ja satama lastaustavaraa täynnä ja
ulapalla upeita laivoja! Isä oli ystävä. Ei Väinö lähimainkaan ollut niin
hyvä ystävä, vaikka olikin melkein paras, eikä liioin Erik, eikä
Ainokaan, eikä Että eikä kukaan muu hänen tuttavistaan.

Poikia oli ja tyttöjä oli — oli somaa, että piti olla molempia lajia.
Herroja oli ja rouvia oli, mutta Maija ei ollut herra eikä rouva, hän oli
suuri tyttö. Ennen Yrjö oli luullut, ettei herrojen ja rouvien välillä ollut
muuta eroa kuin että herroilla oli sekä sääret että jalat, mutta rouvilla
vain jalat. Ei se tainnut niinkään olla. — Herroilla oli viikset ja rouvilla
ei. — Eroa siinä oli. Mutta ei siitä oikein viisastunut. Eikä Väinökään
siitä sen enempää tiennyt.

Yrjö oli kuitenkin huomannut, että tytöt olivat yhtä ja pojat toista.
Eivät he aina tahtoneet leikkiä samoja leikkejäkään. Mikä siinä lie
ollut.

— Onko sinusta hauska olla tyttö? — kysyi hän äidiltä.

— On kyllä — vastasi äiti.

— Mutta minusta on paljon hauskempi olla poika.


— Tietysti — sanoi äiti. — Jokainen on mieluimmin sitä mikä hän
on, sillä hän sopii siihen parhaiten.

9.

Joulut! — Millaiset olivat ennen joulut! Silloin oli joulupukkikin vielä


elossa ja häneen uskottiin. Eikä ollut rikkiviisaita vanhempia
sisaruksiakaan, jotka olisivat tätä uskoa häirinneet. Ei. Joulupukki
saapui turkiksissa ja poronnahka-saappaissa ja suuri kelkka
perässään kuten piti. Hänellä oli valkopartaiset, ystävälliset kasvot ja
aina hän puhui samalla äänellä, joka vähän muistutti Lasse enoa.
Yrjö seisoi hänen edessään kuin kiinninaulattuna, kuin puusta
pudonneena, silmät selällään. Sitten hän näytti ukolle
hammasharjaansa, koska tämä sitä kysyi. — Oli — oli hän sitä
käyttänytkin — ei, ei aivan joka aamu — ja oli hän pitänyt hyllynsä
järjestyksessä, kuten isä vaati. Joka ilta hän sitä siivosi. — Hän otti
ukkoa kädestä ja vei sen, jännitetty ilme silmissään, omaan
huoneeseensa, jossa hän osoitti sille leikkikaluhyllynsä siinä
turvallisessa tietoisuudessa, että hän äidin kanssa yhdessä oli tänä
aamuna sen järjestänyt. Mutta eihän sitä silti tiennyt, hyväksyisikö
ukko sen aivan täydelleen. — Kaiken aikaa hän tuijotti ukon
kasvoihin. Ja jälestäpäin sateli kysymyksiä.

— Äiti, miksi hänen silmänsä olivat niin kummalliset? — Ja isä,


miksi eivät hänen huulensa liikkuneet, kun hän puhui?

Niin, tietysti oli niin — eihän joulu-ukko voinut olla kuin muut
ihmiset. Ei. Ei.
Silloin oli myöskin joulukuusi sellainen kuin olla piti,
piparkakkuineen ja omenineen ja moninaisine koristuksineen, joita
oli valmistettu äidin kanssa pitkät ajat. Siinä kun kynttelit paloivat,
niin tiesi, että oli riemun päivä.

Sellaisten joulujen jälkeen pääsi satujen kertominen vauhtiinsa. Oli


tullut paljon uusia kirjoja jouluksi ja niistä riitti juttuamista. Ja kun
kerran alkuun oli päästy, niin ei tarinoista loppua tullut, sillä niitähän
alati syntyi uusia. Päivä niitä eloon herätteli ja yö samoin. Jokaisella
ihmisellä oli oma satunsa, jokaisella lapsellakin, jokaisella
linnunpojalla ja perhosella oli omansa, kun vain pääsi siitä selville. Ja
oma satu se sittenkin oli kaikista hauskin.

— Silloin on minullakin satuni, äiti!

— Tietysti, ja sinulla se vasta onkin!

Yrjö kipristi tapansa mukaan nenäänsä ihastuksesta ja heittäytyi


kaulaani:

— Kerrothan heti sen minulle, äiti, kerrothan!

Sitten hän istuutui polvelleni ja katsoi kasvoihini:

— No, äiti!

Mutta minä en voinut. Kuinka olisinkaan voinut noin suoraa päätä


sanoa hänelle sellaista, joka syöpyisi hänen tietoisuuteensa
ainiaaksi! Minun täytyi saada lykkäystä. Minun täytyi saada punnita,
mitä hänelle tahtoisin kertoa.

Meillä oli viheriä sohva isän huoneessa ja se on vieläkin meillä. Se


tuo mieleeni aina Yrjön, sillä siinä istuessamme aina ajelimme
satumaillemme.

Ja nyt lupasin hänelle, että ensi kerralla kun hän pyytäisi omaa
satuansa, kertoisin sen hänelle. Kuitenkin sillä ehdolla, että isäkin
silloin olisi kotona. Sillä emmehän hennoneet ilman häntä pitää niin
hauskaa.

Nyt oli lupaus annettu. Ja mieleni oli sen jälkeen sangen raskas.
Miten vaikea olikaan saada se hänelle sanotuksi! Miltä kannalta hän
sen ottaisi? Miten se häneen vaikuttaisi? Mutta oli miten oli. Sen
täytyi tapahtua. Poika oli nyt kuuden vuoden vanha ja aloittaisi pian
koulunsa. Milloin tahansa voisi joku hänen koulutovereistaan tai
muuten joku vieras lausua hänelle varomattoman tai pahansuovan
sanan, joka kaivautuisi hänen sieluunsa ja joka jäisi ainiaaksi häntä
haavoittamaan. Sitä paitsi hän ehkä vastakin tutkistelisi asiaa muilta
eikä isältään ja äidiltään. Ei, kyllä minä sen hänelle sanon. Ja
kukapa sitä paitsi tietää, vaikka tästä sukeutuisi uusi yhdysside
välillemme.

Näin koettaessani itseäni rohkaista pelkäsin kuitenkin lähenevää


hetkeä.

Ja se tuli pian.

— Nyt äiti — nyt on isäkin kotona —!

Ja hän hyppäsi tasajalkaa ilosta.

Niinpä hän sitten istui kuin istuikin polvellani, ja hetki oli tullut.
Isä istui vastapäätä odottaen hänkin ja nosti kehoittavasti päätään.
Mutta minä vaikenin ja tuijotin himmenevään tuleen.

— No, äiti?
Isä iski silmää minulle. Tässä ei ollut enää valitsemisen varaa.

Silloin otin pojan käden omaani ja aloin:

— Oli kerran mies ja vaimo, joilla ei ollut yhtään lasta, ei poikaa


eikä tyttöä.

— Niin te! — sanoi Yrjö.

Ja vaimo välistä kuunteli, käsi korvan takana: Mikä siinä piipitti?


Se kuului vain niin kaukaa. Mutta mies sanoi: Eihän täällä ole
mitään. Varpunen kai istui hetkisen katolla. Mutta ei hän sinua
kutsunut.

Ja taas oli hiljaista.

Mutta vaimo sanoi jonkun ajan kuluttua:

— En jaksa enää kuunnella tätä äänettömyyttä. Tahdon matkustaa


kauas pois siihen suuntaan, josta piipitys kuuluu.

Ja he kokosivat tavaransa ja lähtivät vieraille maille.

Heidän sitten seisoessaan laivankannella ja tähystäessään merta


— kas! siinä hohtivat suuret, koreat, moniväriset täplät vedessä. Ne
laajenivat ja supistuivat lakkaamatta, Ja aina suuretessaan ne
kävivät värikkäämmäksi, ne helottivat aivan kuin sateenkaari olisi
suistunut alas kappaleiksi ja palat kääriytyneet kimmoisiksi palloiksi
ja pudonneet mereen. Ne liikkuivat alituiseen, avautuivat,
sulkeutuivat kuin suuret meren kukkaset, jotka hengittävät
auringonpaisteessa.

Silloin ilostui vaimo ja sanoi miehelleen:


— Meri tervehtii meitä merkiksi siitä, että meillä tulee olemaan
onnekas retki.

Yrjö nyökkäsi päätään.

Heidän astuttuaan maihin illan tullen, syttyi taivaalla toinen valo


toisensa jälkeen ja mies sanoi:

— Luulenpa, että tähdet täällä ovat vieläkin suuremmat ja


kirkkaammat kuin kotona. Nekin tahtovat näyttää meille tien.

— Niin, minun luokseni! — sanoi poika, osoittaen sormella


itseänsä.

Heidän aamulla noustessaan paistoi aurinko yli valoisan maan,


joka oli kuin suuri puutarha, laajat pellot istutuksien keskellä. Siellä
oli hyvä jaloitella valkoisia teitä pitkin ja levähdellä metsiköissä. Ja he
puhelivat keskenään:

— Olemmeko kuulleet väärin? Eihän se piipitys voinut kuulua


täältä päin?

Koska he eivät heti voineet päästä siitä asiasta selville, lähtivät he


kiertämään maata nauttiakseen sen nähtävyyksistä.

Silloin saapuivat he toisen meren laitaan lännessä, jossa suuret


laineet vaahdoten ja jylisten vyöryivät hiekkarantaa kohti. Vuoksen
aikana ne lähestyivät semmoisella vauhdilla, että sai voimansa takaa
juosta niitä pakoon, jos keskipäivällä oli unohtunut liian kauas
näkinkenkiä poimimaan. Aaltojen taasen paetessa poispäin
illemmällä oli ranta vielä entistään rikkaampi näkinkengistä ja muista
meren jätteistä. He poimivat niitä kourallisen ja panivat ne pieneen
rasiaan. Sen he aikoivat viedä pienelle pojallensa. — Ja sinulla, Yrjö,
on ne samat näkinkengät siinä samassa rasiassa vieläkin
leikkikaluhyllylläsi, vaikket koskaan ole tiennyt mistä ne ovat kotoisin.

Poika katsoi suurin silmin vuorotellen meihin molempiin, mutta


minä olin jo päässyt niin kertomisen vauhtiin, etten enää
muistanutkaan pelkoani enkä malttanut siihen kohtaan sen
kauemmaksi pysähtyä.

— Sitten he matkustivat pienen, vanhan kaupungin ohi, jonka


ulkopuolella oli laaja suo. Se oli täynnään haikaroita, jotka nostivat
hitaasti koipiansa hakien sammakoita savesta. Se maa on
haikaroitten maa! Siellä seisoi iso haikara yhdellä jalallaan, koskei se
enää viitsinyt etsiä sammakoita, vaan piti parempana hautoa
mielessään maailman tapahtumia ja koettaa ohjata asiat niin, että
kävisi kaikille hyvin.

— Ei täälläpäin! Ei täälläpäin! huusi hän.

Ja kaikki haikarat nostivat samassa toisen jalkansa allensa ja


huusivat yhteen ääneen:

— Ei täälläpäin! Ei täälläpäin!

— Tomppelit — sanoi isä — sen tiesimme ilmankin.

Ja kuinka olikaan, tulivat he takaisin samaan kaupunkiin, josta


olivat länsimerelle lähteneet.

Siellä risteilivät raitiovaunut sikin sokin, kellot soivat, ajoneuvot


kolisivat ja ihmiset juoksivat mikä sinne ja mikä tänne. Siellä oli
sellainen melske, että tuskin kuuli toinen toisensa ääntä.
Siellä he eräänä kauniina päivänä näkivät ikkunassa pienen pojan,
joka oli aivan yksin koko avarassa maailmassa.

— Aivan kuin sorsanpoika kesällä — keskeytti Yrjö — muistatko


äiti? Istuimme juuri rannalla — niin pam! — ja sorsa kuoli — ja sinne
jäi poikanen aivan yksin kaislikkoon. Se oli sitten niin hiljaa, ettei sitä
näkynytkään, kun se pelkäsi niin kauheasti. Mutta ajattele, äiti, jos
siinä tulikin toinen sorsa!

— Tietysti siinä tuli toinen sorsa ja otti sen pienen poikasen


hoitoonsa, niin ettei sen tarvinnut lainkaan enää pelätä. Ja he mennä
pyristivät yhdessä sitten tiehensä kaislikkoon ja olivat iloissaan.

— Niinkuin sinä ja minä!

— Aivan kuin sinä ja minä! Kas kun sinä osaat hyvin arvata!

Ja Yrjö nauroi, ja me puristimme nauraen toisiamme kaulasta.

Isä istui siinä tuolissaan ja loisti. Hänkin oli jo kokonaan


vapautunut.

— Ja mitenkä sitten kävi, äiti?

— Niin, entä sitten? — Kävi niin, että he pysähtyivät sen valkoisen


talon edustalle, jonka ikkunassa he olivat nähneet sen pienen pojan,
ja soittivat porraskäytävän ovikelloa. Eräässä huoneessa he sitten
löysivät hänet pöydän ääressä katselemassa kuvakirjaa. Kun hän
heidät näki, unohti hän kaiken muun ja he unohtivat myös kaiken
muun hänen tähtensä. Hän tuli heidän lapsekseen, ja he lähtivät
hänen kanssaan toiseen maahan. Ja heidän matkallansa paistoi
aurinko heille päivällä ja tähdet yöllä, ja meren kauniit värikkäät
kukkaset avautuivat heille toivottaen heille onnea.
Ja kun he sitten saapuivat omaan maahansa, liputtivat kaikki laivat
satamassa ja kaikki ihmiset nauroivat. Ja kaikki toivottivat sen pojan
tervetulleeksi ja he toivoivat, että hän saisi prinsessan ja puolet
valtakunnasta, kuten käy saduissa.

Sellainen oli sinun satusi, Yrjö — ja se olikin hyvä, eikö ollut?

Oli. Yrjö oli täysin tyytyväinen, niin päivänselvä asia, ettei hänen
tarvinnut sitä ilmaistakaan. Hän luisui alas polveltani ja käyskenteli
tyytyväisenä ympäri, selkä suorana. Nähtävästi hän oli omissa
silmissään arvoltaan noussut. Ei voinutkaan jokainen kehua sellaisia
matkoja tehneensä. Eikä ollut jokaiselle niin ihmeellistä tapahtunut.
Hän lähestyi keinutuolia, pani sen kädellään käyntiin tarkkaavasti
seuraten sen liikuntoa ikäänkuin sitä tutkien, kapusi sitten siihen
istumaan, katsoi isään ja äitiin suurella, riemukkaalla katseella ja
sanoi:

Niin, mutta kyllä teillä olisi ikävä ellei minua olisi!

— Niinkö luulet? — huudahti isä vallattomasti! ilakoiden ja nosti


pojan olkapäilleen. Poika sätki ihastuksesta, ja kiljuen ja huutaen he
sitten juoksivat huoneitten läpi edestakaisin, kunnes kuulin pojan
putoavan kuin säkin viereisen huoneen sohvalle. Siinä he vielä
jatkoivat telmimistään. Mutta minä kohensin hiiliä takassa ja ajattelin,
että jos kävisi yhtä onnellisesti vastakin, kun tarvitsee niihin asioihin
kajota, niin ei ollut mitään hätää.

Vielä hän ei ymmärtänyt täydelleen mitä oli saanut tietää, mutta


aivan kylliksi sillä kertaa. Vähitellen hän saisi tietää enemmän.
Salakareja tulisi kyllä olemaan, siitä olin selvillä, mutta Jumalan kiitos
ei meidän tarvinnut selviytyä kuin päivästä kerrallaan. Pääasia oli,
että lapsuus- ja nuoruusmuistot pysyisivät puhtaina ja valoisina.
Ja miksi ne eivät sellaisina pysyisi?

Kun sinä iltana autoin poikaa makuulle, piti hänen välttämättä tuiki
tarkoin saada tietää, minkälaiset olivat hänen mekkonsa ja
esiliinansa olleet tuona merkillisenä päivänä, mitä kuvia hänellä oli
ollut kuvakirjassaan ja millä leikkikaluilla hän oli leikkinyt. Entisyys oli
kuin ruusunhohteessa ja ihmeellisempää kuin kaikki muu. Vihdoin
hän kiersi käsivartensa niskani ympäri ja likisti minua lujasti
rintaansa. Silloin päätimme keskenämme kuiskaten, että pitäisimme
oman satumme yhteisenä salaisuutenamme, vain meidän kolmen
salaisuutena. Kertokoot muut äidit lapsilleen — kertokoon Ainon ja
Erikin ja Etan äiti heille, minkälaista silloin oli ollut, kun he olivat
heidät löytäneet. Meidän satumme ei kuulunut heille, ei muille kuin
yksin meille.

— Mistähän Ainon ja Erikin äiti oli heidät löytänyt?

Niin. Se olisi heidän salaisuutensa, kuten meillä oli omamme.


Mutta mitä ikinä Yrjö vain tahtoo tietää itsestään, sen hän kysyköön
isältä tai äidiltä. Koetamme niin tarkkaan kuin suinkin muistaa kaikki,
silloin riittää puhumista vuosikausia. Niin kummallinen se asia oli.

Mutta vielä kuukausia, miltei vuosiakin senjälkeen kuiskasit illoin


joskus korvaani:

— Muistatko satuamme, äiti?

Vähitellen se kuitenkin näytti vaipuvan unhoon, ja kului monta


vuotta, ennenkuin kerran taas otit sen puheeksi.
10.

Istuin lattialla Yrjön vuoteen ääressä ja nojasin päätäni hänen


pielukseensa. Vierelläni paloi spriilamppu, joka loi punertavan
hohteen matolle. Muuten oli huoneessa pimeä.

Hän nukkui, mutta puhui joskus kuumehoureissaan,

— Kiviä ja santaa — sanoi hän — pikkukiviä! Karistaisit pois


sannan, äiti! Miks' tässä on santaa? — Kiviä ja santaa. — Karista ne
pois, äiti!

Kavahdin pystyyn puolihorroksistani. Jo toista viikkoa oli hän


kuumeen noustessa puhunut sannasta ja pikkukivistä, mutta en
voinut siihen tottua. Sillä sehän oli kuin ennustus.

Mutta se ei saanut mitään merkitä, hänen täytyi tulla terveeksi.


Hoitaisin häntä yötä päivää enkä luopuisi hänestä mistään hinnasta.

En. En. En mistään hinnasta.

Nousin ja vedin lakanan hänen allansa suoraksi, niin ettei siihen


jäänyt pienintäkään poimua. Nostin sitten spriilampulla seisovan
kattilan kantta ja panin uuden kääreen hänen kaulalleen.
Puolinukuksissa hän vain hiukan räpäytteli silmiään.

Istuuduin taas vuoteen viereen, oikaisin jalkani ja nojasin pääni


pielukseen. Lamppu lauloi yksitoikkoista nuottiansa, pojan hengitys
kävi tasaisemmaksi, ja minä vaivuin vähitellen takaisin siihen
puolihorrokseen, jossa jo olin harhaillut monet yöt, unen ja
hereilläolon välimaille, pitäen huolta kääreitten muuttamisesta aina
puolen tunnin kuluttua. Isän oli tartunnan ja toimensa takia täytynyt
muuttaa kotoa pois, ja minä olin jäänyt palvelijain kanssa sairaan
luo. Mutta yksin hoidin häntä yötä ja päivää. Kestäisinkö ajan
pitkään? Kestäisin varmaan. En tahtonut hänen luokseen ketään
vierasta, itse halusin kamppailla tuon pitkän kamppailun
tulirokkokuumetta vastaan, joka oli niin tuimasti iskenyt kyntensä
häneen, mutta jonka olisi pakko väistyä.

Ja hän, miten kokonaan hän oli antautunut minulle! Miten


täynnänsä hän oli luottamusta ja miten iloinen heti kun tauti hellitti!
Tunsin samaa riemua saadessani häntä palvella kuin muinoin
ihmisvilinässä suuren kaupungin kaduilla. Tämä se kuitenkin oli
todellista ottelua ja todellista voimainponnistusta — josta vasta
kannattikin iloita.

Keittiön ovea raoitettiin ja Liisa, Maijan seuraaja, pisti päänsä


näkyviin. Hän tulla tassutti lattian yli paljain jaloin ja yönuttu
napitettuna rinnan yli ainoastaan yhdellä napilla.

— Ajattelin, että rouva tarvitsisi hiukan levähtää — sanoi hän


ystävällisesti.

— Kiitos, Liisa — mutta täytyy olla niin säntillinen kääreitä


muuttaessa. Ensi yönä niitä ehkei enää tarvitakaan, ja silloin saan
kyllä nukkua.

Mutta Liisa halusi nähtävästi tehdä valvomisajan rattoisammaksi


rouvalleen pitämällä seuraa ja istuutui toiselle puolen lampun.
Tuijotimme molemmat sen liekkiin.

Liisakin oli ennättänyt kotiutua talossa sen jälkeen kun Maija


vihdoin oli suostunut antamaan myönteisen vastauksen
kärsivällisesti odottavalle sulhaselleen, nautittuaan omasta
puolestaan — kuten hänen oli tapana sanoa — nuoruusvuotensa
rauhassa. Hän kuului niihin onnellisiin, joiden nuoruus kestää
neljäänkymmeneen tai kauemminkin, eikä hän huolinut sitä ennen
kultaista vapauttaan uhrata. Ei mar, sanoi Maija, sillä hän oli
länsisuomalainen. Hänellä oli ihailija nuoruuden vuosilta, joka palasi
jälleen tultuaan leskeksi, ja tällä oli nelivuotinen poikanenkin —
onneksi Maijan mielestä — ei siis tarvinnut silläkään vaivautua.
Kaikki oli valmista ja Maijasta tuli talonemäntä.

Mutta hänestä ei mielellään erottu. Häntä hyvästellessään Yrjö


riippui hänen kaulassaan, äiti pyyhki silmiään ja isä lahjoitti
täydellisen pöytäkaluston Arabian porsliinia.

Siinä istui nyt Liisa punamustassa alushameessaan. Hän tulisi


epäilemättä nauttimaan nuoruutensa päiviä vieläkin kauemmin kuin
Maija, sillä tuskin ilmestyisi kosijaa, joka häntä odottelisi. Hänellä oli
pääkappale huononpuoleinen, mutta sydän paikallaan. Ja koska me
tässä talossa panimme pääpainon viimeiseen, oli meidän välillemme
sukeutunut uusi ystävyys.

Hän vahti taukoamatta spriilampun liekkiä ikäänkuin olisi hänen


ollut hoidettava tulta hellan uunissa ja sanoi:

— Mitenkä tuo poika ihailee rouvaa!

— Mistä Liisa sen tietää?

— No se kun tulee tavantakaa keittiöön ihan vartavasten


kehuakseen rouvaa. Silloin se istuutuu pöydälle ikkunan eteen ja se
kun sitten panee omiaan! Väliin minun täytyy sille nauraa ihan
haletakseni päiväkausia perästäpäin, niin viisaasti se lapsi puhuu.
— Mitä se sitten minusta sanoo?

— Tiedätkös Liisa — sanoo hän minulle — äiti on niin viisas että


hän tietää kaikki.

— Vai niin hän arvelee — virkoin hyvilläni.

Liisa oli lausunut sen niinkuin se ei olisi hänestäkään mahdotonta,


sillä hän kuului itse noihin sydämestään nöyriin.

— Niin hän sanoo — jatkoi Liisa. — Ja hän on niin toimelias, että


paljon toimeliaampi kuin muut rouvat. Mikään muu rouva ei ole kuin
hän.

Liisa oikein kehuu ylpeillen pojan puolesta.

— Niin sanovat kaikki lapset äidistään — puutuin välttäen


puheeseen, mutta ihastuneena poikani kiitoksista.

— Ja niin kaunis tukkakin hänellä on! — yltyy Liisa vielä


ylistämään — ei tuollainen kuin sinulla, Liisa — tuolla tavalla aina
pitkin poskia ja silmiä riippumassa.

Hän nauraa, nauraa sydämensä pohjasta siksi, että tuo viisas


lapsi hoksaa kaiken — hänenkin suorat ja pitkät hiustupsunsa, jotka
aina leyhyvät korvilla.

— Kyllä se näkee, millainen mikin on, — vahvistaa hän.

Eikä Liisan mieleen juolahdakaan, että hän voisi olla toisen


näköinen.

Hän jatkaa:
— Ja näkisit hänen piironginlaatikkonsa — sanoo hän — siinä
hänellä on paidat tuossa ja sukat tuossa ja nenäliinat tuossa — eikä
kaikki sikin sokin niinkuin sinulla on, Liisa.

Häntä huvittavat nämä pojan puheet niin suuresti, että minun


täytyy häntä hillitä, jottei hän herättäisi nukkuvaa. Ja hän juttelee
edelleen:

— Mistä sinä minun laatikkoni tiedät? — kysyn minä. — Silloin hän


hyppää alas ja juoksee kamariin ja nykäisee jonkun laatikoistani auki
ja seisoo ja osoittaa sormellaan: — Tuossa on!

— Ja mitä sinä siihen arvelet, Liisa?

— Mitäs minä mitään — nauran vaan!

Ja hänen täytyy kumartua ja peittää kasvonsa käsiinsä, jottei


nauraisi ääneen.

Liisa punottaa hiusmartoa myöten antaen vihdoin kätensä vaipua


helmaansa ja katsahtaen tuohon älykkääseen lapseen, joka aina
kaikkea keksii. Minä annan hänelle kiitollisen silmäyksen hänen siinä
istuessaan turkkilaiseen tapaan lattialla, jalat ristissä ja paidan yli
vedetty yönuttu auenneena. Kiitollisena — hänen ihailunsa vuoksi —
sekä siitä, että hän aina niin uskollisesti kertoi minulle kaiken, minkä
Yrjö hänelle uskoi.

Mutta aika on kulunut, ja nostan kattilan kannen, niin että höyry


tupruaa ilmoille sen alta. Varovasti irroitan huivin pojan päästä,
asetan kuivaa pumpulia hänen poskelleen ja muutan kääreen. Hän
aukaisee silmänsä täysin heräämättä, kääntyy toiselle kyljellensä ja
nukahtaa uudestaan.
— Lähdehän nyt Liisa nukkumaan! Saat valvoa hänen luonaan
ensi yön, jos haluat.

Hän sanoo hyvää yötä ja tassuttelee taas pois.

Mutta istun kauan hereilläni ajatellen, että se ihailu, josta hän oli
puhunut, oli saanut ensimmäisen iskunsa. Pojan usko
erehtymättömyyteeni oli saanut kolahduksen. Mutta täytyihän senkin
ajan kerran tulla, eikä se hituistakaan ollut häirinnyt hyvää
suhdettamme.

Olimme eräänä iltapuhteena isän huoneessa talvipäivän auringon


juuri laskiessa. Silmäimme edessä siinsi meren lahti ja sen toisella
puolella näkyi saha, ja sahan ikkunat hehkuivat laskevan auringon
valossa, niin että ne kaukaa hohtivat kuin tulitäplät. Ja miten olikaan,
niin alkoi väripilkku toisensa jälkeen tanssia seinällämme, ja Yrjö
katsahti ulos ja katsahti sisään ja ihastui ja ihmetteli.

— Äiti, mistä nuo koreat pilkut tulevat seinälle?

— Katsohan — aurinko paistaa saharakennuksen ikkunoihin, ja


me näemme heijastuksen seinällämme.

— Heijast —?

— Niin, heijastuksen — se ei ole mitään tavallista paistetta, vaan


ainoastaan kajastus — sahan ikkunoiden aikaansaama kajastus.

— Jaa mutta — sinun täytyy selittää se paremmin — tahdon tietää


oikein tarkkaan, miten se on.

— Tiedätkö — on niin pitkä aika siitä kun luin sellaisista — ja


sitäpaitsi olen käynyt niin hirvittävän vanhanaikaista koulua, ettei
siellä opetettukaan paljon mitään siitä, mitä usein näkee — niin että
sinun taitaa olla parempi kysyä sitä isältä, kun hän tulee kotiin. Hän
voi varmaan tarkemmin kuin minä selittää sinulle tuon kaiken.

Vastasin aivan huolettomasti, kuin olisi ollut kysymyksessä mitä


selvin asia, ja ihmettelin sanojeni aikaansaamaa vaikutusta. Poika
katsoi minua pitkään, pitempään kuin koskaan ennen. Hän mittaili
minua silmillänsä — ja sitten tuli miltei puolustelevalla äänensävyllä:

— No niin — eihän se kumma olekaan, ettet tiedä aivan yhtä


paljon kuin isä. — Olethan sinä paljon nuorempi.

Minun kävi häntä melkein sääli ja samalla itseäni. Olinko todellakin


ollut niin suuri hänen silmissänsä ja nyt romahtanut alas jalustaltani?

Mutta luontaisella ylevämielisyydellään, joka ei koskaan pettänyt,


ryhtyi hän minua lohduttelemaan selittämällä, että tietysti mummo,
joka oli isää paljon vanhempi, myöskin tiesi eniten, ja jos olisi
semmoisia, jotka olisivat vielä mummoakin vanhempia, niin niiden
viisaudella ei olisi rajojakaan.

— Mutta sinä, äiti — kuinka voisitkaan tietää niin paljon kuin


vanhat?

Ei, sehän oli mahdotonta, ja niin tyydyimme molemmat


kohtaloomme. Heitin menemään viimeisenkin repaleen entisestä
kaikkitietäväisyyteni komeudesta ehdottamalla, että ruvetaan me
kaksi oppimaan isältä ja mummolta ja tullaan siten koulutovereiksi ja
entistäänkin vielä paremmiksi ystäviksi.

Mutta siitä lähtien tiesi Yrjö, missä oli heikoin kohtani.


Ainoastaan muutamia päiviä myöhemmin istuimme
ruokapöydässämme, isä ja minä innokkaasti jostakin keskustellen, ja
Yrjö itsekseen jotakin hautoen. — Olin kääntynyt isän puoleen ja olin
juuri jotakin hänelle esittämässä, kun poika minut keskeytti:

— Äiti, miksi pidetään valokuvauslevyjä vedessä?

— Enpä tiedä niin tarkalleen.

— Miksi niin sanot, äiti?

— Miten minun sitten olisi pitänyt sanoa?

— Miksi sanot, ettet tiedä sitä niin tarkalleen, kun et tiedä sitä
ollenkaan?

Olin pyörähtänyt ympäri ja purskahtanut nauruun:

— Ja mistä sinä niin varmaan päätät, etten tiedä sitä ollenkaan?

— Olisit sinä sen heti sanonut, jos olisit tiennyt.

Oliko hän ollut nenäkäs? Pois se, ei ensinkään — ääni ei sellaista


hipaissutkaan — hänhän oli vain lausunut ilmeisen totuuden.
Sanokoon vain vastakin yhtä peittelemättä ja yhtä hyväntuulisesti
mitä hän minusta ajattelee. Silloin ei ainakaan keskinäistä
luottamusta puuttuisi, ja se olisi tärkeintä.

Mutta havahdin näistä muistelmistani kuin unesta ja näin


spriilampun, vadin sen vieressä hauteineen, pojan vuoteen ja itseni
lattialla istumassa. Aamu jo sarasti, päivä pilkisti sisään uudinten
raosta ja ruokahuoneen kello löi kuusi.

Siis oli tämäkin yö kulunut loppuun.


Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like