Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 479 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
479
Dung lượng
32,65 MB
Nội dung
www.it-ebooks.info For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. www.it-ebooks.info iii Contents at a Glance About the Author ���������������������������������������������������������������������������������������������������������������� xv About the Technical Reviewer ������������������������������������������������������������������������������������������xvii Acknowledgments ������������������������������������������������������������������������������������������������������������� xix Introduction ����������������������������������������������������������������������������������������������������������������������� xxi Part 1: Knowing the Ecosystem ■ �������������������������������������������������������������������� 1 Chapter 1: Introduction to Windows8 ■ �������������������������������������������������������������������������������3 Chapter 2: Modern UI Design ■ �������������������������������������������������������������������������������������������11 Part 2: Getting Started ■ �������������������������������������������������������������������������������� 25 Chapter 3: The App Platform and Developer Tools ■ ����������������������������������������������������������27 Chapter 4: The Right Controls ■ ������������������������������������������������������������������������������������������39 Chapter 5: The Look and Feel ■ ������������������������������������������������������������������������������������������61 Chapter 6: Content Structuring and Navigation ■ ���������������������������������������������������������������87 Part 3: Into the Groove ■ ������������������������������������������������������������������������������ 107 Chapter 7: Orientation and View States ■ �������������������������������������������������������������������������109 Chapter 8: Handling Data ■ �����������������������������������������������������������������������������������������������129 Chapter 9: Application Life-Cycle Management ■ ������������������������������������������������������������147 Chapter 10: Contracts ■ ����������������������������������������������������������������������������������������������������173 Part 4: The Bling ■ ��������������������������������������������������������������������������������������� 223 Chapter 11: Media and Sensors ■ ������������������������������������������������������������������������������������225 Chapter 12: Tiles, Badges, and Toasts ■ ���������������������������������������������������������������������������257 www.it-ebooks.info ■ Contents at a GlanCe iv Part 5: Above and Beyond ■ ������������������������������������������������������������������������ 291 Chapter 13: Cloud Augmentation ■ �����������������������������������������������������������������������������������293 Chapter 14: Live Services Integration ■ ���������������������������������������������������������������������������369 Chapter 15: Real-World Techniques ■ ������������������������������������������������������������������������������407 Chapter 16: Deployment ■ ������������������������������������������������������������������������������������������������445 Index ���������������������������������������������������������������������������������������������������������������������������������459 www.it-ebooks.info xxi I could say a thousand things here to introduce you to Windows8 application development. But at the end of the day, everything boils down to your passion and excitement as a developer on the Microsoft technology stack. Windows8 represents a signicant opportunity for developers of both consumer-facing and enterprise apps. e whole Microsoft ecosystem is going through a huge change, based around mobile lifestyles, and our skills need to catch up if we developers want to stay on the cutting edge. So, buckle down, roll up your sleeves, and get coding with me. is is an exciting new world and the potential for you to make a name for yourself is huge. Also, as you build your Windows Store apps, let’s keep the conversation going. I am sure that you will have unique problems that you will have solved, or that you will nd faster, better ways of accomplishing the same result. I want to know about these, since we developers make up one giant community and we support each other. So reach out to me with questions, concerns, or comments through Twitter; you can nd me at @samidip. Let’s talk—and happy coding! Introduction www.it-ebooks.info Part 1 Knowing the Ecosystem Windows8 and the modern user experience represent a big change in Microsoft software and what it means for its future. Developers need to understand and truly enjoy the Microsoft ecosystem to be successful Windows8 application developers. Understanding the synergy between the PC, tablets, smartphones, the cloud, and Xbox gives us depth in knowledge that helps plan a Windows8 application correctly. We start this book by digging into the history, inspiration, and vision behind Windows8 and the Microsoft ecosystem as a whole. www.it-ebooks.info 3 Chapter 1 Introduction to Windows8 “Windows reimagined” has been a buzz phrase since Microsoft first announced Windows8 late in 2011. Marketing aside, one needs to look no further than the software coming out of Redmond, WA, to realize the message between the words. Microsoft put together a monumental 2012—just about every product division saw major software updates rolled out for industry-leading products. What began as a user interface (UI) design overhaul for smaller form factors has been renamed “Modern UI,” and it has spread its influence throughout the ecosystem of Microsoft products. At the pinnacle of this new wave of changes is Windows 8—the flagship Microsoft product and, arguably, the world’s most popular operating system. The stakes are huge, the quality of work is premium, and the excitement is palpable. This is no longer just Windows reimagined—it is truly Microsoft reimagined! Windows is an operating system (OS) used by computer users worldwide for work and at home. International Data Corporation (IDC) estimated in March 2012 that some 690 million PCs across the world used Windows 7. Add to that the PCs using Windows XP or earlier versions of Windows. It does not take a genius to figure out that Windows has a huge consumer base. And when there is an upcoming change to something so fundamental affecting many millions of people across the globe—it is a big deal. Windows8 does not feel like an incremental OS upgrade; it truly is Windows built from the ground up, as you shall see throughout this book. I’ll peel back some of the layers of thought that went into Windows 8, discuss what Windows8 means for consumers and enterprises, and most importantly to readers of this book – the developers, I’ll talk about how things boil down for developers, and how we leverage several technologies/frameworks to create Windows8 Store Apps. Rest assured, Microsoft’s enormous consumer base and the significance of Windows8 makes this one of the biggest opportunities application developers have had in a while. The State of Computing Before moving on, I’d like to provide a little perspective on the history of Windows8. It reveals the bigger picture and context of where Windows8 fits amidst the competition. It’s 2013 and computing as we know it is definitely going through a huge change. Human-computer interaction is evolving as our needs for on-the-go computing dictates tremendous innovation across computer form factors. There is no denying that Apple ushered in a whole new industry of smartphones with the 2007 launch of the iPhone. Since then, we are no longer content carrying cumbersome pagers or flip phones that just make phone calls. We want to have the Internet at our fingertips. Enter the modern smartphone: an all-in-one device that fits in our pockets and keeps us connected to work, family, and friends. Add to that real-time news, weather, maps, reviews, social media immersion, and other ways of staying connected—it’s no wonder we no longer simply make phone calls with our smartphones. The convenience of having a device that is always on, always connected, and ready to work purely with touch interaction, soon led to an App phenomenon: the need to control the various aspects of our lives and interactions through native applications built for smartphones. This brought on the explosion of the App Store model—a global but localized secure repository of Apps for our smartphones. These stores/marketplaces are mostly curated and maintained by the smartphone OS manufacturers. The submission and vetting process to get Apps from developers www.it-ebooks.info Chapter 1 ■ IntroduCtIon to WIndoWs8 4 into the store is meant to give users confidence in the quality and safety of Apps downloaded from the store. This model has proven to be tremendously beneficial for developers of Apps, providing a global audience/customer base of users and monetization through paid Apps, Apps with advertisements, or in-App purchases leveraging existing e-commerce models. November 2010: Microsoft launches Windows Phone 7. A completely new smartphone OS, written from the ground up and aimed at invigorating the Windows brand in the smartphone industry. With Apple and Google already out there for several years with their mobile OS offerings, the challenge was to do something fresh and exciting. What began with the Zune HD a couple of years back was a new kind of UI paradigm focused on content over chrome—and the user’s lifestyle at the center of it all. With Windows Phone, this UI (first called the Metro design language) was now all grown up. It offered a breath of fresh air to the user experience. Delightfully touch-oriented, Windows Phone OS excels at being fast and fluid, and offers complete personalization in putting the users’ content and lifestyle at the center of the experience. No longer are we stuck with a grid of application icons. Apps come to life through what are called live tiles —visual, live representations of Apps (even when they are not running). Live tiles are updated locally or through push notifications from the cloud. They are a big selling point of the ecosystem, always inviting users back to the applications. Windows Phone also represents the best effort thus far toward bringing all of the Microsoft ecosystem service offerings (Xbox, Office, Live Services, etc.) together in one, shiny hardware device. It might take Windows Phone a while to claw its way to the market share it deserves, but the innovation offered by the new platform is undeniable. Even better is the developer story. Because it’s based on the Silverlight runtime, developing Apps for Windows Phone is a lot of fun for .NET developers, resulting in Windows Phone being the fastest-growing App marketplace/store among its peers in quickly reaching the 100K-App milestone and growing. There is, however, a new kid on the block: the tablet form factor. As much as we love our smartphones, they are rather small devices for content consumption, multitasking, and business workflows. Users want an always-connected/ always-on experience—but on a bigger form factor, which lends to expanded computing reach. Razor-thin, lightweight, and touch-friendly—tablets quickly grabbed consumer attention, and the computing transformation was well on its way. It didn’t take the casual computer user, netizen, gamer, socialite, and movie buff long to realize that they didn’t need a bigger computer—a touch-friendly tablet would likely meet most of their needs. Enterprises also began considering their line-of-business workflows for the mobile employee base; and the consumerization of IT became a reality. With the introduction of the iPad, Apple again pioneered the space; but it did not take the competition much time to see the iPad’s shortcomings and come up with more compelling offerings. Windows 8: The Overview October 26, 2012, was the launch date for the general availability of Windows8. Amid the waves of computing change, came an OS that promised to offer no compromises on a variety of form factors. Windows8 takes everything good about Windows 7 and tries to make it better. With full backward compatibility in Windows8 Pro for applications running on Windows 7, the upgrade to Windows8 promises to be painless. In addition to the desktop goodness, Windows8 shines with its whole new UI, optimized for touch interaction. The ubiquitous Windows Start menu is no more! Instead, users get a full-screen Start touch menu—highly customizable, personal, and filled with live tiles that invites users back to their applications. The Start screen offers a brand-new Windows 8–specific user experience. It is the biggest change introduced in Windows since Windows 95. Figure 1-1 shows a sample of the Windows8 Start screen experience. www.it-ebooks.info Chapter 1 ■ IntroduCtIon to WIndoWs8 5 The Windows8 Start experience captures a lot of what Windows8 craves to be: the one OS across all device form factors. Touch is not an afterthought; it is a first-class citizen. Equally supported are mouse and keyboard interactions. The Start screen is not a list or grid of application icons, but rather each App gets its own tile, which comes in two sizes: square or wide. The tile is not just an application shortcut; it is like a live representation of the App, conveying information to the user from the Start screen itself, without having to run the App. Live tiles, which update locally or from the cloud, started in Windows Phone and are all grown up in Windows8. There are several combinations of text, pictures, and badges that make up a live tile, along with peek animations and the ability to cycle through content, leading to an energetic, inviting, and constantly alive Start screen experience. Modern UI, which also began with Zune and Windows Phone, has center stage in the Windows8 touch experience. The mantra is simple and minimalist, fast and fluid, content over chrome, rich use of bold flat colors, animations for liveliness, and putting the user first. The Windows8 Start experience is full-screen and offers discoverability and personalization. The point is to make everyone’s Start screen look different; users are free to move Apps around and arrange tiles based on what’s important to their individual style and the given PC. The Start screen content can pan left or right, but a feature called Semantic Zoom aids superbly in discoverability and navigation. To use it, you simply pinch the Start screen, or if you’re on a traditional PC, you hold down the Ctrl key while scrolling the mouse scroll wheel. You are taken (with an easing animation) to a zoomed-out view of smaller App tiles that show the whole layout grouped in sections, as if from a height above. Pinch or scroll out, and you return to the regular Start screen tiles. In addition to Semantic Zoom, another feature that aids in personal organization is grouping, which enables you to group the Start screen tiles easily into logical buckets, based on App types and position groups of tiles by preference. Grouping, combined with Semantic Zoom, is helpful with organization and way finding—simply zoom out, and then swoop back in on the App group of interest. Figure 1-2 shows my personal Start screen, with tile groupings under Semantic Zoom to give a feel for what’s doable. The goal is to personalize to your heart’s content. Windows is suddenly fun again—modern, fast, and colorful yet utilitarian! Figure 1-1. The Windows8 Start screen www.it-ebooks.info Chapter 1 ■ IntroduCtIon to WIndoWs8 6 The Form Factors It is no surprise that Apple’s iPad dominates the tablet space, with Google Android–based tablets trying to wrestle away some of its market share. Tablets have captured the consumer imagination, and innovative computing scenarios are coming forward. For kids and younger generations, touch interaction comes naturally and computing is much more personal. Entire stacks of books or movie collections can be placed on a single tablet; and the thin and light form factors ensure ultimate mobility. There is one minor problem, however, that most would agree on: as handy as today’s tablets are, they are mostly meant for consumption of content. While this works for the majority of folks, advanced users like developers might also want to do some actual work on tablets. Although there are competing products, Microsoft Office documents continue to be heavily used worldwide, but they are non-native citizens on today’s tablets. Serious development work is possible only if the developer is remotely logged in to computers that are more powerful. Arguably, part of the problem is because both Apple and Google choose to use a mobile OS on their tablets. Although this approach is definitely working in terms of simplicity and market share, does it still leave something to be desired? Can work and play be combined? Microsoft is definitely not new to tablets. There have been several experiments with the form factor, starting in the early days of Windows. The problem was that although Windows supported touch, the user experience was geared toward laptops and desktop PCs. This meant Original Equipment Manufacturers (OEMs) often tried putting their own touch-enabled skins on top of Windows, leading to somewhat clunky and inconsistent user experiences. Windows8 throws away all of that clutter from the past and embraces touch first. The whole point is an uncompromising, single OS across all PC form factors, as shown in Figure 1-3. Windows8 belongs in touch-based tablets and all-in-one PCs; but it is also perfectly comfortable with the mouse-keyboard setups of desktops and laptops. The point is that no matter your PC hardware, you get the same consistent user experience (UX) with Windows8. Figure 1-2. The Windows8 Start screen with grouped tiles under Semantic Zoom www.it-ebooks.info [...]... layer of APIs baked into Windows itself The goal is to provide easy, consistent, and quick access to device internals, and Windows core services to Windows8 Store Apps Language projection is in use to make sure that the one set of APIs feels consistent and natural in any development language used to create Windows8 Store Apps • Windows8 Apps and their execution model: Windows8 Store Apps take center... Built from the ground up, Windows8 is Windows reimagined and presents one of biggest opportunities for developers With the massive PC /Windows user base worldwide looking to upgrade to Windows 8 or purchase newer hardware, your Windows8 Store Apps have a huge audience right out of the gate The potential to make a name for yourself is definitely big, especially since the Windows8 Store is starting from... subscriptions for access to Windows8 final bits, or you can simply purchase Windows8 from Microsoft The next order of business is to get Visual Studio 2012 Visual Studio is the one-stop integrated development environment (IDE) that you need to develop Windows8 Store Apps And thankfully, all that you need is free The Visual Studio Express 2012 for Windows8 includes Windows 8 SDK, Blend for Visual Studio,... must-do for Windows8 app developers, because it immediately adds a lot to content discoverability and Windows8 character Figure 2-11a and 2-11b show a Windows8 Store app with regular or zoomed-out content; all the while, the UI is bound to the same data collection 20 www.it-ebooks.info Chapter 2 ■ Modern UI Design Figure 2-11a. The Windows8 Store app—zoomed in Figure 2-11b. The Windows8 Store app—zoomed...Chapter 1 ■ Introduction to Windows8 Figure 1-3. Windows8 across device form factors Although the Windows8 Start screen experience and all Windows8 Store Apps remain very touch-friendly, one tap of the desktop tile brings users back to the familiar desktop world the same as in Windows 7 (sans the Start button), but with a ton of improvements Some applications... edge commanding, and Windows8 apps benefit from natural user muscle memory So, use the edges to add natural functionality and branding, and to give your app some Windows8 behaviors 18 www.it-ebooks.info Chapter 2 ■ Modern UI desIgn Figure 2 -8 highlights the charms and application bars we see so commonly in Windows8 OS and third-party applications If you have access to a Windows8 tablet, hold it with... run Windows8 Pro To the end user, Windows8 should feel the same across chipsets, with the most juice coming from the more powerful processors Both Windows RT and Pro run most Windows8 Store Apps and support desktop mode, except RT versions only have compatibility with selected desktop applications, such as Office 2013 With such wide support for devices, the Windows ecosystem is set to light up Windows. .. have been written for Windows Application technologies range from NET, WPF, Silverlight within and outside browser, and games in various languages—C/C++, COM, Win32, and so forth All of these applications can move into Windows8 unchanged Intel-based Windows8 PCs run them all just fine, just as Windows 7 did • The left area represents the brave new world of touch-centric Windows8 OS and the Store Apps... easy consumption in native application development languages required extensive heavy lifting to make sure the Windows object model mapped to support for several development languages towards building Windows Store Apps This was a big undertaking and the choice of several development languages remains the biggest investment in the Windows8 App development ecosystem 28 www.it-ebooks.info Chapter 3 ■ The... projected into the development language in use Tools: Required Software Windows8 Store Apps can only be developed if you are running the development tools from within Windows8 OS First, you need to download and run Windows8 The OS can be installed on laptops, desktops, tablets, all-in-ones, or run in a virtual machine The Windows8 Enterprise 90-day free evaluation version is available for developers . factors. Windows 8 takes everything good about Windows 7 and tries to make it better. With full backward compatibility in Windows 8 Pro for applications running on Windows 7, the upgrade to Windows 8. experience (UX) with Windows 8. Figure 1-2. The Windows 8 Start screen with grouped tiles under Semantic Zoom www.it-ebooks.info Chapter 1 ■ IntroduCtIon to WIndoWs 8 7 Although the Windows 8 Start screen. battery lives. Opening Windows to ARM has major consequences on form factors running versions of Windows 8, which comes in two broad categories: Windows RT and Windows 8 Pro. The Windows RT version