With Metro and Windows 8, Microsoft is enabling developers to build applications with unparalleled richness and interactivity: applications that are extraordinarily useful and beautiful, and can serve users no matter where they are or what kind of device they prefer to use. In Windows 8 Metro Apps with XAML and C# Unleashed, legendary Microsoft programming guru Adam Nathan shows experienced Microsoft developers exactly how to write world-class apps with Metro. As in Nathan's previous best-seller WPF 4 Unleashed, this approachable, intensely practical book teaches through realistic code examples -- all of them fully color-coded to match the way they appear in Visual Studio. Nathan examines Metro's feature areas in unparalleled depth, delving into topics that most Metro books ignore. He covers everything developers need to know now about Extensible Application Markup Language (XAML), showing how to use it to create state-of-the-art Metro user interfaces. Developers will discover how to exploit Windows 8's most important new innovations from Metro, including touch and sensor support. For sophisticated developers comfortable with the Microsoft programming stack, this book offers unparalleled value. Product Description
Windows 8 enables you to build stunning applications that integrate with each other, services, and Windows itself like never before. And you can sell them in the Windows Store for tablets such as Surface, laptops, and traditional desktop PCs! Now, world-renowned Microsoft programming guru Adam Nathan shows you exactly how to write first-class apps for this radically new version of Windows.
Clear, accessible, and intensely practical, this guide teaches through concise code examples, fully color-coded to match their appearance in Visual Studio--the same approach that made Nathan’s WPF 4 Unleashed so popular. Writing with unprecedented depth and insight, Nathan guides you through creating advanced user interfaces with XAML and exploiting key Windows 8 features such as touch, sensors, charms, and live tiles. Whether you’re already comfortable with Microsoft programming or relatively new to it, Windows 8 Apps with XAML and C# Unleashed will take you to the cutting edge of Windows 8 development.
Detailed information on how to...
Use XAML to represent state-of-the-art user interfaces
Ensure app usability on multiple devices and form factors
Handle touch, mouse, pen, and keyboard input
Manage the high-performance, low-power Windows 8 app lifecycle
Use Windows 8 controls for managing lists, rich text, images, multimedia, and more
Encode, decode, and transcode multimedia content
Leverage rich XAML vector graphics and animation
Make the most of styles and templates
Interact with built-in functionality such as the Camera app, file picker, contact picker, the lock screen, and more
Exploit the Windows 8 charms bar with contracts and extensions
Work with the rich set of available sensors: accelerometer, compass, light sensor, location, proximity, and more
Introduction 1
Who Should Read This Book? 3
Software Requirements 3
Code Examples 3
How This Book Is Organized 3
Conventions Used in This Book 5
Part I: Getting Started
Chapter 1: Anatomy of a Windows Store App 7
Launching a New App 8
The Package Manifest 9
The Main Page 19
The Application Definition 21
Summary 25
Chapter 2: Mastering XAML 27
Elements and Attributes 28
Namespaces 29
Property Elements 31
Type Converters 33
Markup Extensions 34
Children of Object Elements 36
Mixing XAML with Procedural Code 40
XAML Keywords 44
Summary 45
Part II: Building an App
Chapter 3: Sizing, Positioning, and Transforming Elements 47
Controlling Size 48
Controlling Position 52
Applying 2D Transforms 55
Applying 3D Transforms 62
Summary 64
Chapter 4: Layout 65
Discovering the Current Dimensions 66
Discovering the Current View State 67
Discovering the Current Orientation 70
Panels 71
Handling Content Overflow 87
Summary 99
Chapter 5: Interactivity 101
Dependency Properties 101
Routed Events 108
Commands 113
Summary 114
Chapter 6: Handling Input: Touch, Mouse, Pen, and Keyboard 115
Touch Input 116
Mouse Input 138
Pen Input 140
Keyboard Input 142
Summary 147
Chapter 7: App Model 149
Understanding the App Lifecycle 150
Programmatically Launching Apps 163
Interacting with the Windows Store 166
Leveraging Navigation 174
Summary 182
Part III: Understanding Controls
Chapter 8: Content Controls 185
Button 188
HyperlinkButton 189
RepeatButton 191
ToggleButton 191
CheckBox 192
RadioButton 192
ToolTip 194
AppBar 196
Summary 205
Chapter 9: Items Controls 207
Items in the Control 208
Items Panels 210
ComboBox 213
ListBox 214
ListView 216
GridView 219
FlipView 221
SemanticZoom 223
Summary 226
Chapter 10: Text 227
TextBlock 227
RichTextBlock 235
TextBox 240
RichEditBox 248
PasswordBox 251
Summary 252
Chapter 11: Images 253
The Image Element 253
Multiple Files for Multiple Environments 263
Decoding Images 267
Encoding Images 276
Summary 284
Chapter 12: Audio and Video 285
Playback 286
Capture 294
Transcoding 305
Summary 311
Chapter 13: Other Controls 313
Range Controls 313
Popup Controls 316
A Few More Controls 325
Summary 330
Part IV: Leveraging the Richness of XAML
Chapter 14: Vector Graphics 333
Shapes 334
Geometries 340
Brushes 348
Summary 363
Chapter 15: Animation 365
Theme Transitions 366
Theme Animations 376
Custom Animations 382
Custom Keyframe Animations 395
Easing Functions 400
Manual Animations 404
Summary 406
Chapter 16: Styles, Templates, and Visual States 409
Styles 410
Templates 418
Visual States 428
Summary 438
Part V: Exploiting Windows 8
Chapter 17: Data Binding 439
Introducing Binding 439
Controlling Rendering 447
Customizing the View of a Collection 455
Summary 459
Chapter 18: Data 461
App Data 461
User Data 466
Networking 469
Summary 474
Chapter 19: Charms 477
Search 477
Share 486
Devices 492
Settings 503
Summary 508
Chapter 20: Extensions 509
Account Picture Provider 509
AutoPlay Content and AutoPlay Device 512
Contact Picker 514
File Type Associations 516
Protocol 518
Background Tasks 519
Summary 527
Chapter 21: Sensors and Other Devices 529
Accelerometer 529
Gyrometer 532
Inclinometer 532
Compass 533
Light Sensor 533
Orientation 533
Location 534
Proximity 535
Summary 538
Part VI: Advanced Topics
Chapter 22: Thinking Outside the App: Live Tiles, Toast Notifications, and the Lock Screen 539
Live Tiles 539
Toast Notifications 552
The Lock Screen 556
Summary 557
Index 559
Windows 8 enables you to build stunning applications that integrate with each other, services, and Windows itself like never before. And you can sell them in the Windows Store for tablets such as Surface, laptops, and traditional desktop PCs! Now, world-renowned Microsoft programming guru Adam Nathan shows you exactly how to write first-class apps for this radically new version of Windows.
Clear, accessible, and intensely practical, this guide teaches through concise code examples, fully color-coded to match their appearance in Visual Studio--the same approach that made Nathan’s WPF 4 Unleashed so popular. Writing with unprecedented depth and insight, Nathan guides you through creating advanced user interfaces with XAML and exploiting key Windows 8 features such as touch, sensors, charms, and live tiles. Whether you’re already comfortable with Microsoft programming or relatively new to it, Windows 8 Apps with XAML and C# Unleashed will take you to the cutting edge of Windows 8 development.
Detailed information on how to...
Use XAML to represent state-of-the-art user interfaces
Ensure app usability on multiple devices and form factors
Handle touch, mouse, pen, and keyboard input
Manage the high-performance, low-power Windows 8 app lifecycle
Use Windows 8 controls for managing lists, rich text, images, multimedia, and more
Encode, decode, and transcode multimedia content
Leverage rich XAML vector graphics and animation
Make the most of styles and templates
Interact with built-in functionality such as the Camera app, file picker, contact picker, the lock screen, and more
Exploit the Windows 8 charms bar with contracts and extensions
Work with the rich set of available sensors: accelerometer, compass, light sensor, location, proximity, and more
Introduction 1
Who Should Read This Book? 3
Software Requirements 3
Code Examples 3
How This Book Is Organized 3
Conventions Used in This Book 5
Part I: Getting Started
Chapter 1: Anatomy of a Windows Store App 7
Launching a New App 8
The Package Manifest 9
The Main Page 19
The Application Definition 21
Summary 25
Chapter 2: Mastering XAML 27
Elements and Attributes 28
Namespaces 29
Property Elements 31
Type Converters 33
Markup Extensions 34
Children of Object Elements 36
Mixing XAML with Procedural Code 40
XAML Keywords 44
Summary 45
Part II: Building an App
Chapter 3: Sizing, Positioning, and Transforming Elements 47
Controlling Size 48
Controlling Position 52
Applying 2D Transforms 55
Applying 3D Transforms 62
Summary 64
Chapter 4: Layout 65
Discovering the Current Dimensions 66
Discovering the Current View State 67
Discovering the Current Orientation 70
Panels 71
Handling Content Overflow 87
Summary 99
Chapter 5: Interactivity 101
Dependency Properties 101
Routed Events 108
Commands 113
Summary 114
Chapter 6: Handling Input: Touch, Mouse, Pen, and Keyboard 115
Touch Input 116
Mouse Input 138
Pen Input 140
Keyboard Input 142
Summary 147
Chapter 7: App Model 149
Understanding the App Lifecycle 150
Programmatically Launching Apps 163
Interacting with the Windows Store 166
Leveraging Navigation 174
Summary 182
Part III: Understanding Controls
Chapter 8: Content Controls 185
Button 188
HyperlinkButton 189
RepeatButton 191
ToggleButton 191
CheckBox 192
RadioButton 192
ToolTip 194
AppBar 196
Summary 205
Chapter 9: Items Controls 207
Items in the Control 208
Items Panels 210
ComboBox 213
ListBox 214
ListView 216
GridView 219
FlipView 221
SemanticZoom 223
Summary 226
Chapter 10: Text 227
TextBlock 227
RichTextBlock 235
TextBox 240
RichEditBox 248
PasswordBox 251
Summary 252
Chapter 11: Images 253
The Image Element 253
Multiple Files for Multiple Environments 263
Decoding Images 267
Encoding Images 276
Summary 284
Chapter 12: Audio and Video 285
Playback 286
Capture 294
Transcoding 305
Summary 311
Chapter 13: Other Controls 313
Range Controls 313
Popup Controls 316
A Few More Controls 325
Summary 330
Part IV: Leveraging the Richness of XAML
Chapter 14: Vector Graphics 333
Shapes 334
Geometries 340
Brushes 348
Summary 363
Chapter 15: Animation 365
Theme Transitions 366
Theme Animations 376
Custom Animations 382
Custom Keyframe Animations 395
Easing Functions 400
Manual Animations 404
Summary 406
Chapter 16: Styles, Templates, and Visual States 409
Styles 410
Templates 418
Visual States 428
Summary 438
Part V: Exploiting Windows 8
Chapter 17: Data Binding 439
Introducing Binding 439
Controlling Rendering 447
Customizing the View of a Collection 455
Summary 459
Chapter 18: Data 461
App Data 461
User Data 466
Networking 469
Summary 474
Chapter 19: Charms 477
Search 477
Share 486
Devices 492
Settings 503
Summary 508
Chapter 20: Extensions 509
Account Picture Provider 509
AutoPlay Content and AutoPlay Device 512
Contact Picker 514
File Type Associations 516
Protocol 518
Background Tasks 519
Summary 527
Chapter 21: Sensors and Other Devices 529
Accelerometer 529
Gyrometer 532
Inclinometer 532
Compass 533
Light Sensor 533
Orientation 533
Location 534
Proximity 535
Summary 538
Part VI: Advanced Topics
Chapter 22: Thinking Outside the App: Live Tiles, Toast Notifications, and the Lock Screen 539
Live Tiles 539
Toast Notifications 552
The Lock Screen 556
Summary 557
Index 559