【本人译作推荐】Windows 8应用开发:C#和XAML卷(原名:Building Windows 8 Apps with C# and XAML)
作者连续3年蝉联微软的MVP称号,拥有20多年的企业级应用研发经验,其中15年致力于微软平台的Web应用研发,是Wintellect公司的首席咨询师。
目 录
第1章 全新的Windows Runtime 1
1.1 回顾过去:Win32和.NET 1
1.2 展望未来:自然用户界面的兴起 7
1.3 Windows应用商店中的应用 10
1.3.1 Windows 8应用程序的设计 12
1.3.2 快速和流畅 12
1.3.3 对齐和缩放 13
1.3.4 使用正确的契约 13
1.3.5 绝妙的磁贴 14
1.3.6 连接和在线 16
1.3.7 拥抱Windows 8的设计理念 16
1.4 Windows 8开发工具 17
1.4.1 Blend for Visual Studio 18
1.4.2 HTML 5和JavaScript 18
1.4.3 C++和XAML 20
1.4.4 VB/C#和XAML 21
1.5 WinRT揭秘 22
1.6 WPF、Silverlight和桌面应用程序 23
1.7 总结 24
1.8 参考文献 24
第2章 开始编写第一个程序 25
2.1 搭建环境 25
2.1.1 Windows 8 26
2.1.2 Visual Studio 2012 30
2.1.3 Blend 31
2.2 Hello, Windows 8 31
2.2.1 创建第一个Windows 8应用程序 31
2.2.2 模板 32
2.3 ImageHelper应用程序 35
2.4 总结 51
第3章 可扩展应用程序标记语言(XAML) 53
3.1 定义用户界面 54
3.1.1 可视化树 56
3.1.2 依赖属性 58
3.1.3 附加属性 61
3.2 数据绑定 63
3.3 故事板 70
3.4 样式和资源 73
3.5 布局 76
3.5.1 Canvas 76
3.5.2 Grid 77
3.5.3 StackPanel 79
3.5.4 VirtualizingPanel和VirtualizingStackPanel 80
3.5.5 WrapGrid 81
3.5.6 VariableSizedWrapGrid 83
3.5.7 ContentControl 84
3.5.8 ItemsControl 86
3.5.9 ScrollViewer 86
3.5.10 ViewBox 87
3.5.11 GridView 89
3.5.12 ListView 93
3.5.13 FlipView 94
3.5.14 ListBox 94
3.6 公共控件 94
3.7 总结 96
第4章 Windows 8应用程序 97
4.1 布局和视图 97
4.1.1 模拟器 98
4.1.2 视觉状态管理器 101
4.1.3 语义缩放 104
4.2 处理用户输入 107
4.2.1 指针事件 108
4.2.2 操作事件 109
4.2.3 鼠标支持 111
4.2.4 键盘支持 112
4.2.5 视觉反馈 114
4.2.6 确定目标 116
4.2.7 上下文菜单 117
4.3 应用栏 118
4.4 图标和初始屏幕 124
4.5 关于页面 125
4.6 传感器 129
4.6.1 加速计 129
4.6.2 指南针 130
4.6.3 地理位置传感器 131
4.6.4 陀螺仪 132
4.6.5 倾斜仪 133
4.6.6 光传感器 133
4.6.7 方向传感器 134
4.7 总结 136
第5章 应用程序生命周期 137
5.1 进程生命周期管理 139
5.1.1 激活 140
5.1.2 挂起 141
5.1.3 终止 143
5.1.4 恢复 144
5.1.5 导航 145
5.1.6 应用程序数据API 148
5.2 连接和在线 153
5.3 自定义初始屏幕 153
5.4 总结 155
第6章 数据 157
6.1 应用程序设置 157
6.2 访问和存储数据 159
6.2.1 速度和多线程的需求 164
6.2.2 理解async和await 167
6.2.3 Lambda表达式 169
6.2.4 IO帮助类 170
6.2.5 内嵌资源 171
6.3 集合 173
6.4 网页内容 177
6.5 聚合内容 179
6.6 流、缓存和字节数组 180
6.7 数据压缩 181
6.8 数据加密和签名 183
6.9 Web服务 186
6.10 总结 191
第7章 磁贴和Toast通知 193
7.1 基本磁贴 193
7.2 动态磁贴 194
7.3 锁屏提醒 200
7.4 辅助磁贴 202
7.5 Toast通知 206
7.6 Windows通知服务 211
7.7 总结 218
第8章 超级按钮 219
8.1 搜索 221
8.2 分享 231
8.2.1 分享内容 232
8.2.2 接收分享内容 239
8.3 设置 244
8.4 总结 248
第9章 MVVM和测试 249
9.1 UI设计模式 250
9.1.1 模型 254
9.1.2 视图 255
9.1.3 视图模型 256
9.2 可移植类库 257
9.3 为什么要测试 261
9.3.1 测试能消除不合理的假设 262
9.3.2 测试能从源头上排除Bug 262
9.3.3 测试有助于代码文档化 263
9.3.4 测试易于扩展和维护应用程序 263
9.3.5 测试能改进架构和设计 264
9.3.6 测试有助于提高开发能力 264
9.3.7 结论:编写单元测试 265
9.4 单元测试 265
9.4.1 Windows应用商店单元测试框架 266
9.4.2 Mock和Stub 269
9.5 总结 272
第10章 打包和部署 273
10.1 Windows应用商店 273
10.1.1 查找应用程序 274
10.1.2 商机 277
10.1.3 商业模式 278
10.1.4 广告 283
10.1.5 应用程序发布前的准备 283
10.1.6 应用程序发布流程 285
10.1.7 应用认证工具包 286
10.1.8 等待应用程序的审核 289
10.2 侧载(Side-Loading) 290
10.3 总结 292
原版封面内容:
—From the Foreword by Jeff Prosise
Build Exceptionally Immersive and Responsive Touch-Based Windows Store Apps for Windows 8 with C# and XAML
This is the first practical guide to building breakthrough applications for Windows 8 from project templates through publication to the new Windows Store. Microsoft “MVP of the Year” Jeremy Likness helps you combine your existing developer skills with new Visual Studio 2012 tools and best practices to create apps that are intuitive and innovative. His guidance and insight will help you dive into Windows 8 development—and gain a powerful competitive advantage for years to come.
Likness illuminates the entire apps lifecycle, from planning and Model-View-View Model (MVVM) based design through coding, testing, packaging, and deployment. He covers both business and consumer apps, showing how Windows 8/WinRT development builds upon and contrasts with older WPF and Silverlight approaches.
Using carefully crafted downloadable code examples and sample projects, Likness shows how to make the most of new platform features, including integrated social networking, search, contracts, charms, and tiles. Throughout, he addresses crucial development challenges that have only been discussed on MSDN, blog posts, and Twitter feeds—and never with this depth and clarity before.
Coverage includes
• Mastering real-world Windows 8 development for all devices and form factors • Understanding the new WinRT framework and the unique characteristics of Windows 8 apps
• Designing apps that are faster, more responsive, do more with less, and maximize battery life
• Creating exceptionally fluid interfaces with VS 2012 templates, built-in animations, and XAML
• Building apps that respond consistently to multiple forms of input, including complex touch manipulations
• Using contracts and charms to expose services or enable users to do so
• Providing information to users through Live Tiles even when your app isn’t running
• Connecting your app seamlessly to multiple data sources, including social networks and cloud storage
• Syndicating rich, network-based content
• Using Model-View-ViewModel (MVVM)
• Securing Windows 8 apps through authentication and authorization
• Efficiently testing, debugging, packaging, and deploying apps
原版书评:
A Great Place to Start with Windows 8 Store App Development
The book starts by introducing WinRT. This introduction includes a really nice history of how Microsoft got to where they are now. It starts with a look back at MS-DOS, MS-DOS Executive, the Win32 API, COM, and.NET. The introduction leads us up to NUI (Natural User Interface) and the Windows Store Application Design Principles.
The first chapter ends with a look at the Windows 8 tool that are available to developers and designers. They include, Blend for Visual Studio, C++ and XAML, HTML5 and JavaScript, and VB/C# and XAML.
I have listed all the chapters below.
1. The New Windows Runtime
2. Getting Started
3. Extensible Application Markup Language (XAML)
4. Windows 8 Applications
5. Application Lifecycle
6. Data
7. Tiles and Toasts
8. Giving Your Application Charm
9. MVVM and Testing
10. Packaging and Deploying
The Getting Started chapter covers setting up your environment, which includes Windows 8, Visual Studio 2012, and expression blend for Visual Studio. It also covers the details of all the available project templates that come in the Windows Store category of Visual Studio's project templates.
The book then continues on with a nice overview of XAML. The author does a good job of covering a lot of topics as well as going in-depth enough to give you a thorough understanding of the topics that he chose to cover. XAML is a big topic, but the author did a great job of covering the essentials needed to get started.
Chapter 4, Windows 8 Applications, starts out with a nice overview of the Windows 8 simulator that comes with the development environment. The chapter continues on covering the application view states, semantic zoom, how to handle user input, mouse support, keyboard support, sensors, the application bar, and much more.
The one thing that the book really brought to light was a big flaw with the Windows Store Applications design. Not so much by explicitly pointing it, but rather by having nothing to say about it. That flaw being, a complete lack of capability for the applications to be run off-line with any sizable local data store. There really is no large data storage available to the Windows Store Applications beyond application state persistence. That raised a big red flag.
In searching the web, I found a lot of people having big issues with that. It looks like SQLite has come up with a solution they say will make it through the Windows Store approval process.
The chapter Giving Your Application Charm covers contracts and Windows 8 Extensions which allow for application information sharing handled at an operating system level. This is one of the coolest features built into Windows 8.
The book ends with a short chapter on MVVM and unit testing, and a short chapter on packaging and deploying.
The author has all the examples used in the book available for download. They're very well organized and usable. All of the examples ran without needing any modification.
Overall I found this book an enjoyable read. I thought the author's writing style made the book very easy to read from cover to cover. I will also be keeping it by on my side to use as a reference.
If you are planning on building Windows 8 Applications with C# and XAML, I recommend you start with this book. It will give you a great foundation on which to build your experience.