<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Windows 8 Tips and Tricks &#187; Style</title>
	<atom:link href="http://www.windows8tricks.net/tag/style/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.windows8tricks.net</link>
	<description>Check out latest news, tips and tricks of Windows 8 including many windows 8 tweaks and optimization tools. We also reviewWindows 8 applications in the App Store such as games, utilities and general applications.</description>
	<lastBuildDate>Thu, 23 May 2013 04:22:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Building your own Windows Runtime components to deliver great Metro style apps</title>
		<link>http://www.windows8tricks.net/2012/08/building-your-own-windows-runtime-components-to-deliver-great-metro-style-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-your-own-windows-runtime-components-to-deliver-great-metro-style-apps</link>
		<comments>http://www.windows8tricks.net/2012/08/building-your-own-windows-runtime-components-to-deliver-great-metro-style-apps/#comments</comments>
		<pubDate>Tue, 07 Aug 2012 01:24:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[Building]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[deliver]]></category>
		<category><![CDATA[great]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[runtime]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/08/building-your-own-windows-runtime-components-to-deliver-great-metro-style-apps/</guid>
		<description><![CDATA[For Windows 8, we completely reimagined the platform, allowing you to choose the programming language and technologies you already know to build apps tailored to the device and form factor. With the Windows Runtime, you can even easily use multiple languages within a single app. You can build a great Metro style app with HTML]]></description>
			<content:encoded><![CDATA[<p>For Windows 8, we completely reimagined the platform, allowing you to choose the programming language and technologies you already know to build apps tailored to the device and form factor. With the Windows Runtime, you can even easily use multiple languages within a single app. You can build a great Metro style app with HTML and JavaScript that can interact with the Xbox 360 controller through building your own Windows Runtime component in C++. You can build reusable XAML controls exposed via Windows Runtime components that are instantly consumable by Metro style apps written in both C++ and C#. Essentially, we have let you build apps on the Windows 8 platform using the languages of your choice with no comprises.</p>
<p>In this blog post, we talk about what you need to know to build your own Windows Runtime components.</p>
<h2>The basics</h2>
<p>The Windows Runtime is at the heart of empowering language choice. It exposes so that you can call them from JavaScript, C++, C# and Visual Basic in a way that’s natural and familiar. This same foundation is available to you when building your own APIs too.</p>
<p>A Windows Runtime component that you build and package in your app is typically referred to as a 3<sup>rd</sup> party Windows Runtime component. This differs from 1<sup>st</sup> party components that are already part of the Windows 8 platform. You can write these 3<sup>rd</sup> party Windows Runtime components in C++, C# or Visual Basic. You can call into the APIs they expose from anywhere, including other Windows Runtime components packaged into your app. You can also call into the APIs exposed via Windows Runtime components from any language.</p>
<p>The Windows Runtime components that you write for your app can use Windows Runtime APIs, Win32, COM, .NET APIs or 3<sup>rd</sup> party libraries as long as they are <a href="http://msdn.microsoft.com/library/windows/apps/br211369" target="_blank">supported for Metro style app development</a>. Note that the Windows Runtime components that you build are different from what you traditionally know as C++ DLLs or .NET assemblies that expose APIs. Creating a class library in .Net or a standalone DLL in C++ is not the same as building a Windows Runtime component. Windows Runtime components are declared in .wnmd files that expose Windows Runtime metadata and enable languages such as JavaScript to naturally consume Windows Runtime APIs (for example, pascalCasedNames support for APIs exposed to JavaScript). The Windows Runtime metadata also enables Visual Studio to provide great tooling capabilities such as IntelliSense support.</p>
<h2>Why build your own Windows Runtime components</h2>
<p>Creating Windows Runtime components can help you architect for reusability and language interoperability. Let’s take a look at some app scenarios that showcase how you can use 3<sup>rd</sup> party Windows Runtime components to build better experiences.</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5148.xbox_5F00_controller_5F00_0A8E7868.jpg" rel="lightbox[1469]" title="Xbox 360 Controller"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Xbox 360 Controller" border="0" alt="You can integrate your Metro style app with the Xbox 360 Controller for Windows" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4666.xbox_5F00_controller_5F00_thumb_5F00_62E7FC3D.jpg" width="300" height="234" /></a>    <br /><em>Figure1: Xbox 360 Controller</em></p>
<h3>Using Win32 and COM APIs in your Metro style app</h3>
<p>The platform provided by Internet Explorer 10 enables you to create great Metro style app experiences using HTML, CSS and JavaScript. But what if you have built a game using HTML5 canvas and want to integrate with the Xbox 360 controller for Windows? The <a href="http://msdn.microsoft.com/en-us/library/windows/apps/Ee417001" target="_blank">XInput</a> API, which allows apps to receive input from the controller, exposes Win32 APIs that are not available directly to JavaScript.</p>
<p>This is a great example of where creating a Windows Runtime component can solve this problem and give you the ability to use the XInput APIs in your HTML based Metro style app. The <a href="http://code.msdn.microsoft.com/windowsapps/XInput-and-JavaScript-c72fe535" target="_blank">XInput and JavaScript controller sketch sample</a> showcases exactly that. The sample app contains a game controller Windows Runtime component written in C++ which wraps the functionality exposed by the XInput APIs. The controller sketch HTML-based app uses the game controller C++ Windows Runtime component to enable the interaction with the Xbox 360 controller.</p>
<p>This scenario, impossible to accomplish using HTML and JavaScript alone, is a perfect example of where creating a 3<sup>rd</sup> party Windows Runtime component allows you to complete a complex scenario that you otherwise wouldn’t be able to.</p>
<h3>Computationally Intensive Operations</h3>
<p>Apps created for fields like science, engineering, and maps/geography often have computationally intensive operations. These intensive operations typically require powerful parallel processing and are well suited for C++ to achieve optimal performance. In <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh699893(v=vs.110).aspx" target="_blank">Developing Bing Maps Trip Optimizer, a Metro style app in JavaScript and C++</a> , we see another scenario where creating a Windows Runtime component in C++ allows us to create the best experience in our app.</p>
<p>You wonder why anyone would want to calculate a trip route on local data at all when we could run this computationally intensive task in the cloud on Bing servers. Bing Maps exposes JavaScript APIs to do this, but sometimes an app must run offline. And we also want the user to drag and change the route in real time with touch. If we can run these intense operations locally, we create an even better experience.</p>
<p>By writing our compute-intensive operation in C++ using the parallel task library, we can harness the power of the client to create a great experience for users. Windows Runtime is a great fit for this scenario, allowing us to create our rich client User Interface (UI) in HTML and JavaScript with the Bing Maps AJAX control while running all of our intensive route operations using C++ code that calculates quickly using parallelization.<i> </i></p>
<h3>Libraries</h3>
<p>The community is filled with great libraries that developers put together and shared for everyone to use. In the past, you may have found it challenging to reuse some of these libraries if they didn’t match the programming language your app was implemented in. For example, you built a great .NET app, but couldn’t use a library written in C++ without going through painful interop hoops like PInvoke.</p>
<p>Windows Runtime bridges the language gap in Windows 8, making it possible for a single Windows Runtime component library with a single code base to reach a broader set of developers irrespective of the component’s language or your app’s primary programming language.</p>
<p>You can now create a single Windows Runtime-exposed XAML library of custom controls that both C++ and C# app developers can consume. And you can use various data storage Windows Runtime libraries shared out by developers in your XAML or HTML based Metro style apps. All of these scenarios are possible without the burden of writing any interop code.</p>
<p>We think Windows Runtime will be a boon to the libraries that developers create and share broadly for the community of Metro style app developers. Let’s now take a look at two concrete examples showing the basics of building a 3<sup>rd</sup> party Windows Runtime component in <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh699871(v=vs.110).aspx" target="_blank">C++/CX</a> and C#.</p>
<h2>Scenario 1: Enhancing your app with native audio</h2>
<p>Say we are building a software synthesizer app using XAML backed by app logic written in C#. To add filter support to our music app, we would like to use <a href="http://msdn.microsoft.com/en-us/library/windows/apps/microsoft.directx_sdk.ixaudio2.ixaudio2.aspx" target="_blank">XAudio</a> to have direct control of audio buffers.</p>
<h3>Adding the Windows Runtime component to our solution</h3>
<p>Using Visual Studio, we add a new C++ Windows Runtime component project to our existing solution. This Windows Runtime component wraps the music processing functionality:</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/7128.new_5F00_xaudiowrapper_5F00_57BE71F3.jpg" rel="lightbox[1469]" title="Adding a new C++ Windows Runtime Component "><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Adding a new C++ Windows Runtime Component " border="0" alt="Using Visual Studio to add a new C++ Windows Runtime Component to our music app" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/8688.new_5F00_xaudiowrapper_5F00_thumb_5F00_22B1E2C3.jpg" width="600" height="382" /></a>    <br /><em>Figure 2: Adding a new C++ Windows Runtime Component</em></p>
<p>Visual Studio created a C++ project for us to expose APIs for which the implementation will be packaged in a DLL and the Windows Runtime metadata in a winmd file. Both are made available to our C# project.</p>
<h3>Defining the class exposed to our XAML C# project</h3>
<p>We use <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh699871(v=vs.110).aspx" target="_blank">C++/CX</a> to build the APIs that will be exposed to our C# project, but you also can use the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh438466(v=vs.110).aspx" target="_blank">Windows Runtime C++ Template Library</a> (WRL). We start by defining a fairly basic class to encapsulate the XAudio functionality:</p>
<p><strong>XAudioWrapper.h</strong></p>
<blockquote><div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(204, 102, 51);">#pragma</span> <span style="color: rgb(204, 102, 51);">once</span><br /><br /><span style="color: rgb(204, 102, 51);">#include</span> <span style="color: rgb(0, 96, 128);">&quot;mmreg.h&quot;</span><br /><span style="color: rgb(204, 102, 51);">#include</span> &lt;vector&gt;<br /><span style="color: rgb(204, 102, 51);">#include</span> &lt;memory&gt;<br /><br /><span style="color: rgb(0, 0, 255);">namespace</span> XAudioWrapper<br />{<br />    <span style="color: rgb(0, 0, 255);">public</span> ref <span style="color: rgb(0, 0, 255);">class</span> XAudio2SoundPlayer sealed<br />    {<br />    <span style="color: rgb(0, 0, 255);">public</span>:<br />        XAudio2SoundPlayer(uint32 sampleRate);<br />        <span style="color: rgb(0, 0, 255);">virtual</span> ~XAudio2SoundPlayer();<br /><br />        <span style="color: rgb(0, 0, 255);">void</span> Initialize();<br /><br />        <span style="color: rgb(0, 0, 255);">bool</span>   PlaySound(size_t index);<br />        <span style="color: rgb(0, 0, 255);">bool</span>   StopSound(size_t index);<br />        <span style="color: rgb(0, 0, 255);">bool</span>   IsSoundPlaying(size_t index);<br />        size_t GetSoundCount();<br /><br />        <span style="color: rgb(0, 0, 255);">void</span> Suspend();<br />        <span style="color: rgb(0, 0, 255);">void</span> Resume();<br /><br />    <span style="color: rgb(0, 0, 255);">private</span>:<br />        interface IXAudio2*                     m_audioEngine;<br />        interface IXAudio2MasteringVoice*       m_masteringVoice;<br />        std::vector&lt;std::shared_ptr&lt;ImplData&gt;&gt;  m_soundList;<br />    };<br />}<br /></pre>
</p></div>
</blockquote>
<p>You will first notice the usage of the <b>public</b>, <b>ref</b> and <b>sealed</b> keywords in the class declaration. For a class to be instantiated from another language such as JavaScript or C# in a Metro style app, the class must be declared as public ref class sealed.</p>
<p>The public functionality (methods, properties …) of the class are limited to C++ built-in types or Windows Runtime types. Those are the only types allowed for crossing the language boundary in Windows Runtime components. That being said, you can use the regular C++ library (i.e.: Standard Template Library collections) for the private data members of your class as shown in this code snippet. Those private data members don’t have to follow the rules associated with crossing the language boundary. The Visual Studio compiler emits error messages and provides guidance if you use unsupported constructs.</p>
<h3>Implementing the class exposed in our Windows Runtime component</h3>
<p>Now that we have defined the basic interface for our class, let’s take a look at some of the implemented methods:</p>
<p><b>XAudioWrapper.cpp</b></p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">XAudio2SoundPlayer::XAudio2SoundPlayer(uint32 sampleRate) :<br />    m_soundList()<br />{<br />    <span style="color: rgb(0, 128, 0);">// Create the XAudio2 engine</span><br />    UINT32 flags = 0;<br /><br />    XAudio2Create(&amp;m_audioEngine, flags);<br /><br />    <span style="color: rgb(0, 128, 0);">// Create the mastering voice</span><br />    m_audioEngine-&gt;CreateMasteringVoice(<br />        &amp;m_masteringVoice,<br />        XAUDIO2_DEFAULT_CHANNELS,<br />        sampleRate<br />        );<br />}<br /><br /><span style="color: rgb(0, 0, 255);">void</span> XAudio2SoundPlayer::Resume()<br />{<br />    m_audioEngine-&gt;StartEngine();<br />}<br /><br /><span style="color: rgb(0, 0, 255);">bool</span> XAudio2SoundPlayer::PlaySound(size_t index)<br />{<br />    <span style="color: rgb(0, 128, 0);">//</span><br />    <span style="color: rgb(0, 128, 0);">// Setup buffer</span><br />    <span style="color: rgb(0, 128, 0);">//</span><br />    XAUDIO2_BUFFER playBuffer = { 0 };<br />    std::shared_ptr&lt;ImplData&gt; soundData = m_soundList[index];<br />    playBuffer.AudioBytes = soundData-&gt;playData-&gt;Length;<br />    playBuffer.pAudioData = soundData-&gt;playData-&gt;Data;<br />    playBuffer.Flags = XAUDIO2_END_OF_STREAM;<br /><br />    HRESULT hr = soundData-&gt;sourceVoice-&gt;Stop();<br />    <span style="color: rgb(0, 0, 255);">if</span> (SUCCEEDED(hr))<br />    {<br />        hr = soundData-&gt;sourceVoice-&gt;FlushSourceBuffers();<br />    }<br /><br />    <span style="color: rgb(0, 128, 0);">//</span><br />    <span style="color: rgb(0, 128, 0);">// Submit the sound buffer and (re)start (ignore any 'stop' failures)</span><br />    <span style="color: rgb(0, 128, 0);">//</span><br />    hr = soundData-&gt;sourceVoice-&gt;SubmitSourceBuffer(&amp;playBuffer);<br />    <span style="color: rgb(0, 0, 255);">if</span> (SUCCEEDED(hr))<br />    {<br />        hr = soundData-&gt;sourceVoice-&gt;Start(0, XAUDIO2_COMMIT_NOW);<br />    }<br /><br />    <span style="color: rgb(0, 0, 255);">return</span> SUCCEEDED(hr);<br />}<br /></pre>
</p></div>
</blockquote>
<p>In this code snippet, we are just using the XAudio2 COM APIs available for <a href="http://msdn.microsoft.com/library/windows/apps/br211369" target="_blank">Metro style app development</a> to wire up our audio engine, play sound and resume the engine. Additionally, we can use C++ constructs and types beyond just the Windows Runtime types to implement the necessary functionality.</p>
<h3>Adding and consuming the Windows Runtime component</h3>
<p>After we define and implement our basic class, we use Visual Studio to add the XAudioWrapper Windows Runtime component to our C++ project from our C# project:</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2821.add_5F00_xaudiowrapper_5F00_308428BE.jpg" rel="lightbox[1469]" title="Adding the XAudioWrapper Windows Runtime Component to our music app "><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Adding the XAudioWrapper Windows Runtime Component to our music app " border="0" alt="Using Visual Studio to add a reference to the XAudioWrapper Windows Runtime Component in our music app" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/3482.add_5F00_xaudiowrapper_5F00_thumb_5F00_10691C01.jpg" width="600" height="412" /></a></p>
<p align="center"><em>Figure 3: Adding the XAudioWrapper Windows Runtime Component to our music app</em></p>
<p>As a result, the class that we expose from our C++ project becomes available to our C# project:</p>
<p><b>MainPage.cs</b></p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">using</span> XAudioWrapper;<br /><br /><span style="color: rgb(0, 0, 255);">namespace</span> BasicSoundApp<br />{    <br />    <span style="color: rgb(0, 0, 255);">public</span> sealed partial <span style="color: rgb(0, 0, 255);">class</span> MainPage : Page<br />    {<br />        XAudio2SoundPlayer _audioPlayer = <span style="color: rgb(0, 0, 255);">new</span> XAudio2SoundPlayer(48000);<br />        <span style="color: rgb(0, 0, 255);">public</span> MainPage()<br />        {<br />            <span style="color: rgb(0, 0, 255);">this</span>.InitializeComponent();<br />        }<br /><br />        <span style="color: rgb(0, 0, 255);">protected</span> override <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />        {<br />            _audioPlayer.Initialize();<br />        }<br /><br />        <span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">void</span> Button_Click_1(object sender, RoutedEventArgs e)<br />        {<br />            _audioPlayer.PlaySound(0);<br />        }<br />    }<br />}<br /></pre>
</p></div>
</blockquote>
<p>As shown in the code snippet, we can interact with our XAudio wrapper from C# just as if it were a regular .NET component. We reference its namespace, instantiate the component and start invoking the various methods it exposes. All of this without requiring any DllImports to call into the native code!</p>
<h2>Scenario 2: Using built-in APIs to open a zip file from your app</h2>
<p>Say we are also building a file viewer app using HTML and want to add functionality to allow users of this app to pick zip files. We want to use the APIs already built-into Windows and exposed in the .NET platform for <a href="http://msdn.microsoft.com/en-us/library/windows/apps/system.io.compression.ziparchive(v=vs.110).aspx" target="_blank">handling zip files</a>.</p>
<h3>Adding the Windows Runtime component to our solution</h3>
<p>This is the same step as we have described for our music app, but we now pick the C# Windows Runtime component to wrap the zip processing functionality:</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4062.new_5F00_ziputil_5F00_704E0F43.jpg" rel="lightbox[1469]" title="Adding a new C# Windows Runtime Component "><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Adding a new C# Windows Runtime Component " border="0" alt="Using Visual Studio to add a new C# Windows Runtime Component to our file viewer app" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4075.new_5F00_ziputil_5F00_thumb_5F00_692ED2CB.jpg" width="600" height="382" /></a></p>
<p><em>Figure 4: Adding a new C# Windows Runtime Component</em>&#160; </p>
<p>Visual Studio has created a C# project for us to expose the APIs for which both the implementation and Windows Runtime metadata are packaged in a .winmd file and made available to our web project.</p>
<h3>Implementing the class exposed in our Windows Runtime component</h3>
<p>We use C# to build the APIs that will be exposed to our web project, but you can also use Visual Basic. We start by defining a simple C# class to encapsulate the zip functionality:</p>
<p><b>ZipWrapper.cs</b></p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">using</span> System;<br /><span style="color: rgb(0, 0, 255);">using</span> System.Collections.Generic;<br /><span style="color: rgb(0, 0, 255);">using</span> System.IO;<br /><span style="color: rgb(0, 0, 255);">using</span> System.IO.Compression;<br /><span style="color: rgb(0, 0, 255);">using</span> System.Runtime.InteropServices.WindowsRuntime;<br /><span style="color: rgb(0, 0, 255);">using</span> System.Threading.Tasks;<br /><span style="color: rgb(0, 0, 255);">using</span> Windows.Foundation;<br /><span style="color: rgb(0, 0, 255);">using</span> Windows.Storage;<br /><br /><span style="color: rgb(0, 0, 255);">public</span> sealed <span style="color: rgb(0, 0, 255);">class</span> ZipWrapper<br />{<br /><span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">static</span> IAsyncOperationWithProgress&lt;IList&lt;string&gt;, <span style="color: rgb(0, 0, 255);">double</span>&gt; EnumerateZipFileAsync(StorageFile file)<br />        {<br />            <span style="color: rgb(0, 0, 255);">return</span> AsyncInfo.Run(async delegate(<br />                System.Threading.CancellationToken cancellationToken, IProgress&lt;<span style="color: rgb(0, 0, 255);">double</span>&gt; progress)<br />            {<br />                IList&lt;string&gt; fileList = <span style="color: rgb(0, 0, 255);">new</span> List&lt;string&gt;();<br />                progress.Report(0);<br /><br />                <span style="color: rgb(0, 0, 255);">using</span> (var stream = await file.OpenStreamForReadAsync())<br />                {<br />                    <span style="color: rgb(0, 0, 255);">using</span> (var archive = <span style="color: rgb(0, 0, 255);">new</span> ZipArchive(stream))<br />                    {<br />                        <span style="color: rgb(0, 0, 255);">for</span> (<span style="color: rgb(0, 0, 255);">int</span> i = 0; i &lt; archive.Entries.Count; i++)<br />                        {<br />                            <span style="color: rgb(0, 128, 0);">// add code for processing/analysis on the file </span><br /> <span style="color: rgb(0, 128, 0);">// content here</span><br /><br />                            <span style="color: rgb(0, 128, 0);">// add to our list and report progress</span><br />                            fileList.Add(archive.Entries[i].FullName);<br />                            <span style="color: rgb(0, 0, 255);">double</span> progressUpdate = ((i + 1) / ((<span style="color: rgb(0, 0, 255);">double</span>)archive.Entries.Count)) * 100; <span style="color: rgb(0, 128, 0);">// percentage</span><br />                            progress.Report(progressUpdate);<br />                        }<br />                    }<br />                }<br /><br />                progress.Report(100.0);<br />                <span style="color: rgb(0, 0, 255);">return</span> fileList;<br />            });<br />        }<br />}<br /></pre>
</p></div>
</blockquote>
<p>This class is public and sealed. Similarly to building C++ Windows Runtime components, this is necessary for other languages to instantiate the class. The static method exposed in the class uses a mixture of Windows Runtime types (such as StorageFile) and as .NET types (such as IList) in the method signature. The rule of thumb is to use Windows Runtime types for defining the public fields, parameters and return types that will be exposed to the other languages. That being said, you can use certain .NET fundamental types (i.e.: DateTimeOffset and Uri) and primitives (i.e.: IList) as is.</p>
<p>You will also notice that the method above leverages the <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/03/20/keeping-apps-fast-and-fluid-with-asynchrony-in-the-windows-runtime.aspx" target="_blank">Windows Runtime infrastructure for async and progress support</a> that you can (and should) use when defining your Windows Runtime components. As far as the implementation for the Windows Runtime component or any private functionality in the class, you are not limited to only using Windows Runtime types and APIs; you are free to use any of the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br230232(v=vs.110).aspx" target="_blank">.NET API surface exposed for Metro app development</a> as shown in the code snippet ZipArchive APIs.</p>
<h3>Adding and consuming the Windows Runtime component</h3>
<p>Now that we have implemented our zip tool wrapper, we use Visual Studio to add a reference to our C# project from our JavaScript project:</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1832.add_5F00_ziputil_5F00_770118C6.jpg" rel="lightbox[1469]" title="Adding the ZipUtil Windows Runtime component to our file viewer app "><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Adding the ZipUtil Windows Runtime component to our file viewer app " border="0" alt="Using Visual Studio to add a reference to the ZipUtil Windows Runtime component in our file viewer app" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/8787.add_5F00_ziputil_5F00_thumb_5F00_56E60C09.jpg" width="600" height="412" /></a></p>
<p><em>Figure 5: Adding the ZipUtil Windows Runtime component to our file viewer app</em></p>
<p></p>
<p>As a result, the class that we have exposed from our C# project becomes available to our web project:</p>
<p><b>program.js</b></p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(204, 102, 51);">function</span> pickSinglePhoto() {<br /><br />    <span style="color: rgb(0, 128, 0);">// Create the picker object for picking zip files</span><br />    var openPicker = <span style="color: rgb(0, 0, 255);">new</span> Windows.Storage.Pickers.FileOpenPicker();<br />    openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;<br />    openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;<br />    openPicker.fileTypeFilter.replaceAll([<span style="color: rgb(0, 96, 128);">&quot;.zip&quot;</span>]);<br /><br />    <span style="color: rgb(0, 128, 0);">// Open the picker for the user to pick a file </span><br />    openPicker.pickSingleFileAsync().then(function (file) {<br />        <span style="color: rgb(0, 0, 255);">if</span> (file) {<br />            ZipUtil.ZipWrapper.enumerateZipFileAsync(file).then(<br />        <span style="color: rgb(204, 102, 51);">function</span> (fileList) {<br />            <span style="color: rgb(0, 0, 255);">for</span> (var i = 0; i &lt; fileList.length; i++)<br />                document.getElementById(<span style="color: rgb(0, 96, 128);">'output'</span>).innerHTML += <span style="color: rgb(0, 96, 128);">&quot; &quot;</span> + fileList[i];<br />        },<br />        <span style="color: rgb(204, 102, 51);">function</span> (prog) {<br />            document.getElementById(<span style="color: rgb(0, 96, 128);">'zipProgress'</span>).value = prog;<br />        }<br />    );<br />        } <span style="color: rgb(0, 0, 255);">else</span> {<br />            document.getElementById(<span style="color: rgb(0, 96, 128);">'output'</span>).innerHTML = <span style="color: rgb(0, 96, 128);">&quot;an error occurred&quot;</span>;<br />        }<br />    });<br />};<br /></pre>
</p></div>
</blockquote>
<p>As you can see, we can interact with our zip tool wrapper from JavaScript just as if it were a regular JavaScript object. We can call into the static method exposed in our Windows Runtime component, and we can do so using JavaScript’s async language constructs such as .then(). </p>
<h2>General guidance</h2>
<p>Not every API you write for your Metro style app should be exposed as a 3<sup>rd</sup> party Windows Runtime component. In general, use Windows Runtime types when you are communicating between programming languages and use types and constructs that are built into the language that you are using for functionality that is not publicly exposed via a Windows Runtime component. Additionally, there are various language-specific features and rules around crossing the language boundary that you need to take into consideration when building your Windows Runtime component. This includes delegates and events, asynchronous operations, method overloading, handling specific data types such as collections, exception handling and debugging tips. You can dive into those topics further by visiting the section on <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh441572(v=vs.110).aspx" target="_blank">building Windows Runtime components</a> for your development language.</p>
<h2>In closing</h2>
<p>With Windows Runtime components, you can now mix programming languages and API technologies to build the apps you envision. Windows 8 is about no compromises. There are even no compromises during development, allowing you to mix and match the programming languages that best fit your scenario. We hope this allows you to spend more time thinking about innovation and less time being forced to learn a completely new programming language.</p>
<p>Happy app building!</p>
<p>&#8211; Ines Khelifi, Program Manager, Windows</p>
<h2>References</h2>
<p>In this post, we have merely scratched the surface of what’s possible with building Windows Runtime components. Here are additional resources to help you dive into this further for your app development:</p>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3" width="317" align="center">
<tbody>
<tr>
<td valign="top" width="201">
<p><b>Link</b></p>
</td>
<td valign="top" width="114">
<p><b>Types</b></p>
</td>
</tr>
<tr>
<td valign="top" width="201">
<p align="left"><b><a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh441572(v=vs.110).aspx">Creating Windows Runtime Components</a></b></p>
</td>
<td valign="top" width="114">
<p>Doc</p>
</td>
</tr>
<tr>
<td valign="top" width="201">
<p align="left"><b><a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh441569(v=vs.110).aspx">Creating Windows Runtime Components in C++</a></b></p>
</td>
<td valign="top" width="114">
<p>Doc</p>
</td>
</tr>
<tr>
<td valign="top" width="201">
<p align="left"><b><a href="http://msdn.microsoft.com/en-us/library/windows/apps/br230301(v=vs.110).aspx">Creating Windows Runtime Components in C# and Visual Basic</a></b></p>
</td>
<td valign="top" width="114">
<p>Doc</p>
</td>
</tr>
<tr>
<td valign="top" width="201">
<p align="left"><a href="http://code.msdn.microsoft.com/windowsapps/Basic-Audio-Sample-9a5bb0b7">XAudio2 audio file playback sample</a></p>
</td>
<td valign="top" width="114">
<p>Sample</p>
</td>
</tr>
<tr>
<td valign="top" width="201">
<p align="left"><b><a href="http://code.msdn.microsoft.com/windowsapps/XInput-and-JavaScript-c72fe535">XInput and JavaScript controller sketch sample</a></b></p>
</td>
<td valign="top" width="114">
<p>Sample</p>
</td>
</tr>
<tr>
<td valign="top" width="201">
<p align="left"><b><a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh699893(v=vs.110).aspx">Developing Bing Maps Trip Optimizer, a Metro style app in JavaScript and C++</a></b></p>
</td>
<td valign="top" width="114">
<p>Conceptual documentation</p>
</td>
</tr>
</tbody>
</table>
<hr align="left" size="1" width="33%" /></div>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10337272" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/windowsappdev/archive/2012/08/06/building-your-own-windows-runtime-components-to-deliver-great-metro-style-apps.aspx">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/08/building-your-own-windows-runtime-components-to-deliver-great-metro-style-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using HTML controls to create great Metro style apps</title>
		<link>http://www.windows8tricks.net/2012/07/using-html-controls-to-create-great-metro-style-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-html-controls-to-create-great-metro-style-apps</link>
		<comments>http://www.windows8tricks.net/2012/07/using-html-controls-to-create-great-metro-style-apps/#comments</comments>
		<pubDate>Fri, 27 Jul 2012 22:23:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[Create]]></category>
		<category><![CDATA[great]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Using]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/07/using-html-controls-to-create-great-metro-style-apps/</guid>
		<description><![CDATA[With Windows 8, you can use HTML to build Metro style apps. What you might not realize is that by using HTML controls directly, you automatically get the new Windows 8 experience. We have done work in HTML so that you can build industrial strength apps that have touch capability while still maintaining the great]]></description>
			<content:encoded><![CDATA[<p>With Windows 8, you can use HTML to build Metro style apps. What you might not realize is that by using HTML controls directly, you automatically get the new Windows 8 experience. We have done work in HTML so that you can build industrial strength apps that have touch capability while still maintaining the great flexibility of using HTML. We want you to quickly and efficiently build apps that shine. </p>
<p>In particular, we want you to continue to take advantage of common HTML controls like &lt;button&gt; so that you can create great Windows 8 experiences with your existing expertise. Windows 8 enables this with new implementations of the standard HTML controls that have Windows 8 experiences built into them. By default, all these standard controls have the new look and feel of Windows 8, a great touch experience, and strong localization and globalization support. By using these standard HTML controls, you can build great Metro style apps your customers will love, while still maintaining the flexibility you want from HTML.</p>
<p>The Windows 8 team wants to make it as easy as possible for you to create great apps that your users will love to use. As a case study, we take one of the simplest controls, &lt;button&gt; , and walk you through how the new &lt;button&gt; in Windows 8 improves your productivity. With the tips and tricks discussed here, we’ll help you to get the most out of the HTML for Windows 8 to create a great Metro style app.</p>
<h2>The Windows 8 button</h2>
<p>If you’ve seen some of our talks and design guidelines, you already know some of the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465424.aspx" target="_blank">design guidelines</a> of a great Metro style app:</p>
<ol>
<li>Apply Metro style look and feel</li>
<li>Design for touch</li>
<li>Code with fundamentals (for example, globalization and accessibility) in mind</li>
<li>Be fast and fluid</li>
</ol>
<p>The updated HTML controls in Windows 8 help you follow these design guideline in a friction-free manner because we want you to fall into the <em>pit of success</em>:</p>
<blockquote><p><em><b>The pit of success</b>: In stark contrast to a summit, a peak, or a journey across a desert to find victory through many trials and surprises, we want our customers to simply fall into winning practices by using our platform and frameworks. To the extent that we make it easy to get into trouble we fail.</em></p>
</blockquote>
<blockquote><p><em>-Rico Mariani, Partner Architect in Internet Explorer</em></p>
</blockquote>
<p>So, let’s examine how using &lt;button&gt; enables your apps to fall into the pit of success and naturally achieve the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464920.aspx" target="_blank">traits</a> of a great Metro style app.</p>
<h2>Apply Metro style look and feel</h2>
<p>We wanted to make it easy for you to create a user interface using the Metro style design, while providing you the flexibility and power to customize that look to your app’s own unique brand and needs. If you tried creating a Windows 8 app with JavaScript and HTML using the VS templates, you noticed that all the standard HTML controls like &lt;button&gt; come with the Metro style design by default, as seen here:</p>
<blockquote><div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">button</span><span style="color: rgb(0, 0, 255);">&gt;</span>Windows 8 Rocks!<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">button</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
</p></div>
</blockquote>
<p>&#160;</p>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3" align="center">
<tbody>
<tr>
<td valign="top" width="200"><a href="http://windows/windows8/DevX/Developer Blog/Blogs/#_msocom_1" name="_msoanchor_1"><img style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Button by default in Internet Explorer 10" border="0" alt="Button by default in Internet Explorer 10" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/7041.win8rocks_5F00_button_5F00_5E677D4E.jpg" width="200" height="56" /></a></p>
<p>Figure 1: Button by default in Internet Explorer 10</td>
<td valign="top" width="200"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/7026.win8rocks_5F00_button2_5F00_28EEBB29.jpg" rel="lightbox[1410]" title="Button in Windows 8 Metro style apps"><img style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Button in Windows 8 Metro style apps" border="0" alt="Button in Windows 8 Metro style apps" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/3324.win8rocks_5F00_button2_5F00_thumb_5F00_36C10124.jpg" width="200" height="55" /></a></p>
<p align="center">Figure 2: Button in Windows Metro style apps</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>How does this work behind the scenes? Windows 8 has made two improvements here: First, we enhanced the styling capabilities provided for the HTML controls like &lt;button&gt; to give you more flexibility than ever before via CSS to provide visuals for the different parts and visual states that you see in controls. Second, we provided default Metro style visuals for all the HTML controls via two out-of-the-box default style sheets that are part of the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465493.aspx#what_is_the_windows_library" target="_blank">Windows Library for JavaScript</a> (WinJS) and included by default in all the VS Templates.</p>
<h3>New HTML controls infrastructure</h3>
<p>We have reworked how controls are built from the core to give you more flexibility for styling the controls. In fact, we use the same improvements to styling to define the default look and feel for all HTML controls in Windows 8. </p>
<p>Most browsers today render controls using previously generated images. Whenever you apply a style to a control, the browser discards the hardcoded image, re-renders the control in a simple baseline look, and then applies the style you want on top of this. </p>
<p>For the &lt;button&gt;, you can see that even though you have only applied a background color, the second button now has a border with a 3-D bevel look. This 3-D border is part of the baseline look:</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">button</span><span style="color: rgb(0, 0, 255);">&gt;</span>Normal<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">button</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">button</span> <span style="color: rgb(255, 0, 0);">style</span><span style="color: rgb(0, 0, 255);">=&quot;background-color: red;&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span>Styled<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">button</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /></pre>
</p></div>
</blockquote>
<p align="center"><em><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1185.Button_2D00_Styling_5F00_44A4D8E3.png" rel="lightbox[1410]" title="Button Styling"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="Button Styling" border="0" alt="Button Styling" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2678.Button_2D00_Styling_5F00_thumb_5F00_3E7D8C48.png" width="400" height="107" /></a></em></p>
<p align="center"><em>Figure 1: Normal and styled buttons in Internet Explorer</em></p>
<p align="left">The default look via hardcoded image has limitations in terms of styling. You can’t simply style directly onto of the new styles and it’s not immediately obvious what will happen to styling when you apply a style to a previously generated bitmap. Therefore, Windows 8 no longer provides the original look of HTML controls via a hardcoded image. We have rebuilt all HTML controls from the ground up to be rendered using vector based primitives, CSS, to allow you to directly style on top of the control. </p>
<p>We’ve added the ability for you to access the inner parts of the controls. For a control like the checkbox, you can select the inner check mark using the -ms-check pseudo-elements and style this inner element separately from the box.</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">input[type=checkbox]::-ms-check<br />{<br />background-image: url(&quot;myCheckMark.svg&quot;);<br />}<br /></pre>
</p></div>
</blockquote>
<p>For a full list of parts we’ve added to the HTML controls see <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465498.aspx" target="_blank">Quickstart: styling controls (Metro style apps using JavaScript and HTML)</a>.</p>
<p>If you play with the CSS styling a little more, you can now get some pretty interesting styles out of the controls that weren’t possible before. </p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1273.Checkbox_5F00_4287DA1A.png" rel="lightbox[1410]" title="Checkbox"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="Checkbox" border="0" alt="Checkbox" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1106.Checkbox_5F00_thumb_5F00_226CCD5D.png" width="400" height="202" /></a></p>
<p><em>Figure 2: Styled checkbox examples</em></p>
<p>Take a look at the Common HTMS controls <a href="http://code.msdn.microsoft.com/windowsapps/Common-HTML-controls-and-09a72a24" target="_blank">sample</a> and check out <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465498.aspx" target="_blank">Quick Start: styling controls</a> for more info.</p>
<p>Another advantage to building all our controls out of CSS primitives is that we get great scaling. This is particularly important because Windows 8 supports a rich ecosystem of devices and it is imperative for the controls to <a href="http://blogs.msdn.com/b/b8/archive/2012/03/21/scaling-to-different-screens.aspx" target="_blank">scale for all screen resolutions and DPIs</a>.</p>
<p>Using CSS primitives allows all our controls to automatically scale well and display more crisply for all screen resolutions and DPIs. </p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1830.OK_5F00_button_5F00_761EB4B4.jpg" rel="lightbox[1410]" title="Small, medium, and large vector buttons"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Small, medium, and large vector buttons" border="0" alt="Small, medium, and large vector buttons" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/6840.OK_5F00_button_5F00_thumb_5F00_3D07D7B2.jpg" width="500" height="92" /></a></p>
<p align="center"><em>Figure 3: CSS drawn images remain crisp in every resolution</em></p>
<p>So, if you do choose to customize your controls, make sure you continue to use vector-based technology like CSS primitives or SVG. Using raster images will leave the controls looking pixelated when scaled and your app won’t look polished in all Windows 8 devices.</p>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3" align="center">
<tbody>
<tr>
<td valign="top" width="200"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/0172.tiny_5F00_ok_5F00_6EFF783C.jpg" rel="lightbox[1410]" title="Blurry, small raster button"><img style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Blurry, small raster button" border="0" alt="Blurry, small raster button" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5852.tiny_5F00_ok_5F00_thumb_5F00_35E89B3A.jpg" width="104" height="48" /></a><em>Figure 4: Image looks blurry when minimized</em></p>
<p></td>
<td valign="top" width="200"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Large, pixelated raster button" border="0" alt="Large, pixelated raster button" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4466.large_5F00_ok_5F00_thumb_5F00_67E03BC4.jpg" width="186" height="72" /></p>
<p><em>Figure 5: Image looks pixelated when enlarged</em></p>
</td>
</tr>
</tbody>
</table>
</div>
<p>For more info on how to handle scaling, take a look at the <a href="http://code.msdn.microsoft.com/windowsapps/Scaling-sample-cf072f4f" target="_blank">Scaling SDK sample</a>.</p>
<p>Internet Explorer 10 and HTML for Windows 8 shares the same HTML platform. This means all HTML controls for Internet Explorer 10 are also built using CSS and webpages, so they can also scale crisply across different screen resolutions and DPIs in Windows 8!</p>
<h3>Metro style look by default</h3>
<p>We provide the new Metro style look of all controls via a CSS style sheet. We want to transparently show how the new Windows 8 Metro style design is implemented and enable you to integrate your own brand into it, such as swapping out colors on the controls to use your own app’s branded color scheme. Take advantage of that flexibility! Here’s a link to <a href="http://code.msdn.microsoft.com/windowsapps/Theme-roller-sample-64b679f2" target="_blank">Theme roller SDK sample</a> that makes it easy to colorize the controls.</p>
<p>Now, to get the default look, you only need to pick one of the two default style sheets; the only difference between them is the color schemes they are based on. ui-dark.css contains control colors best suited for a dark background and ui-light.css contains control colors best suited for a light background. For apps that mostly display images or video, we recommend using the dark style sheet, and for apps that contain a lot of text, we recommend using the light style sheet. (If you&#8217;re using a custom color scheme, use the style sheet that looks best with your app&#8217;s look and feel.) You choose an app color scheme to start with by simply referencing one of these style sheets to your project using this HTML:</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br /><span style="color: rgb(0, 128, 0);">&lt;!-- Dark Style Sheet reference --&gt;</span><br /><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">link</span> <span style="color: rgb(255, 0, 0);">href</span><span style="color: rgb(0, 0, 255);">=&quot;//Microsoft.WinJS.1.0/css/ui-dark.css&quot;</span> <span style="color: rgb(255, 0, 0);">rel</span><span style="color: rgb(0, 0, 255);">=&quot;stylesheet&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br /><span style="color: rgb(0, 128, 0);">&lt;!-- or Light Style Sheet reference --&gt;</span><br /><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">link</span> <span style="color: rgb(255, 0, 0);">href</span><span style="color: rgb(0, 0, 255);">=&quot;//Microsoft.WinJS.1.0/css/ui-light.css&quot;</span> <span style="color: rgb(255, 0, 0);">rel</span><span style="color: rgb(0, 0, 255);">=&quot;stylesheet&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br /><span style="color: rgb(0, 0, 255);">&lt;!</span>—Other header content --<span style="color: rgb(0, 0, 255);">&gt;</span><br /><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /></pre>
</p></div>
</blockquote>
<p>The easiest way to learn how to apply and build on top of the default style is to actually open the CSS default style sheet and look at the CSS styles in it.</p>
<p>If we go back to the original button example, when you have the same line of code as we saw earlier in a Metro style app, this is now what you get:</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/0601.ButtonCSS_5F00_5E2C6610.png" rel="lightbox[1410]" title="ButtonCSS"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="ButtonCSS" border="0" alt="ButtonCSS" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/6557.ButtonCSS_5F00_thumb_5F00_1024069B.png" width="400" height="82" /></a></p>
<p align="center"><em>Figure 6: Normal and styled buttons</em></p>
<p>In Metro style apps, <i>only</i> the styles you applied are now overwritten. You can now easily brand your app while maintaining the new Metro style look and feel.</p>
<p>As you can see, you can now better style your controls and they will automatically scale crisply across multiple screen resolutions and DPI. We want to make it easier for you to get the look and feel you want in your app while maintaining the Metro style look and feel. </p>
<h2>Design for touch</h2>
<p>To help you create great apps, we wanted to make it simple to create a user interface that works for touch, mouse, and keyboard, and provides your users with the familiar set of interactions they can count on working consistently across the system.</p>
<p>Today, HTML controls already have great keyboard and mouse support. Because <a href="http://blogs.msdn.com/b/b8/archive/2012/03/28/touch-hardware-and-windows-8.aspx" target="_blank">touch</a> is a new interaction mode, we needed to enable better touch support across all the HTML controls. To code better for touch, you must first understand touch input’s unique challenges. </p>
<h3>Finger is not precise</h3>
<p><a></a>A finger is a less precise input mechanism compared to the pixel-precise mouse pointer. </p>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3" align="center">
<tbody>
<tr>
<td valign="top" width="250">
<p align="left"><em>Figure 7: The image shows the width of the average adult finger is about 11 millimeters (mm) wide, while a baby&#8217;s is 8 mm, and some basketball players have fingers wider than 19 mm!</em></p>
</td>
<td valign="top" width="81"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5050.finger_5F00_size_5F00_40A5F28F.jpg" rel="lightbox[1410]" title="finger_size"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="finger_size" border="0" alt="finger_size" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1731.finger_5F00_size_5F00_thumb_5F00_208AE5D2.jpg" width="74" height="240" /></a></td>
</tr>
</tbody>
</table>
</div>
<p>To improve the precision of a users’ tap, Windows 8 HTML platform added these features:</p>
<ul>
<li><b>Controls are sized for touch</b></li>
</ul>
<blockquote>
<p>By default, Metro style HTML controls are sized to best fit the average fingers. This enables users to confidently target the controls. 7&#215;7 mm is a good minimum size if touching the wrong target can be corrected in one or two gestures or within five seconds. In our default style sheet, all button controls have a minimum height and minimum width that gives you a minimum area of 7x7mm. Here is an example with the values from the default style sheet.</p>
</blockquote>
<blockquote>
<div>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">button, input[type=button], input[type=reset], input[type=submit] <br />{<br />    min-height: 32px; <br />    min-width: 90px;<br />}<br /></pre>
</p></div>
</blockquote>
<ul>
<li><b>Touch retargeting</b></li>
</ul>
<blockquote>
<p>The Windows 8 touch targeting helps users by making the system find the closest control within the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465326.aspx">contact geometry</a> and retargeting the touch point towards it. </p>
</blockquote>
<ul>
<li><b>Touch disambiguition</b></li>
</ul>
<blockquote>
<p>The touch disambiguation engine added smarts in the system to help better determine where the users targets when the finger covers more than one control. </p>
</blockquote>
<h3>No aim feedback</h3>
<p>When using a mouse, users can first aim the cursor, ensure that the 1pixel size point is accurately on what they want to activate and then click. But with touch, you have to hover over the screen with no feedback to indicate whether what you have hovered on is accurate. When you make contact with the screen, you immediately activate the UI. This means, with a mouse you get to ready, aim, then fire. Whereas with touch, you simply fire. Because you don’t get to aim, the margin of error for touch is much larger.</p>
<p>To allow users to use touch with confidence, Windows 8 has defined a set of interactive visual states for controls that indicates when the users are about to invoke a control. For example, the user will see the same visuals to let them know what was activated and again when they successfully cancel the activation if they change their mind. Windows 8 has baked these visuals directly into the controls via the default style sheet. Windows 8 has done this by mapping CSS states to the touch interaction states.Here’s an example of the CSS mapping for &lt;button&gt;:</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/6038.CSS_5F00_mapping_5F00_677408CF.jpg" rel="lightbox[1410]" title="CSS mapping of touch interaction states"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="CSS mapping of touch interaction states" border="0" alt="CSS mapping of touch interaction states" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/0257.CSS_5F00_mapping_5F00_thumb_5F00_75464ECA.jpg" width="400" height="222" /></a><em>Figure 8: CSS mapping of touch interaction states</em></p>
<p>Let’s take a closer look at the set of interaction states and how we baked the visuals into the controls.</p>
<h4>Pressed state</h4>
<p>Controls now give strong visual feedback when pressed, so that the user has confidence in which button the system has targeted.</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5556.pressed_5F00_state_5F00_4039BF9A.jpg" rel="lightbox[1410]" title="Button touch state"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Button touch state" border="0" alt="Button touch state" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/3312.pressed_5F00_state_5F00_thumb_5F00_201EB2DD.jpg" width="350" height="194" /></a></p>
<p align="center"><em>Figure 9: Button touch state</em></p>
<p>When a user presses the button, we apply both :hover and :active CSS pseudo-states to the button, and provide visual feedback by styling background color and font color in CSS:</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">button:hover:active {<br />    background-color: rgb(0, 0, 0);<br />    color: rgb(255, 255, 255);<br />}<br /></pre>
</p></div>
</blockquote>
<p>We mapped both :hover and :active for touch down, and not simply :active state, so we can use a programming model that is similar to mouse. This way, you can easily use the same code for both input types. When you use mouse to click on a button, the mouse is usually already on top of the button and is already in the :hover state. When you click a button with the mouse, an additional :active is added. </p>
<h4>Cancelling</h4>
<p>If the user sees that they have touched the wrong button, they can drag their finger off and lift outside to cancel. As long as the finger is off the button, it goes back to its normal state to indicate that the interaction will be cancelled.</p>
<p>To achieve the deactivated visual, we keep :active applied to the button and invalidate :hover state, when the user dragged off the button. Because there’s no style for :active state itself, the control falls back to the normal style, which looks like the button has return to its resting state. This gives the user a visual indication that the button action was cancelled. This is really the existing behavior with mouse. In IE9 this was achieved by a private theme bitmap switching. In IE10 we expose the change through public CSS states so that you could achieve the same effect when you stylize the control. </p>
<p>When styling controls, make sure you don’t just style the :active state for your pressed style, as that state represents the cancel behavior and therefore must be the same style as the normal state. The correct state to use for activate is :hover:active state. </p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5531.button_5F00_cancel_5F00_2DF0F8D8.jpg" rel="lightbox[1410]" title="Button cancel state"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Button cancel state" border="0" alt="Button cancel state" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1830.button_5F00_cancel_5F00_thumb_5F00_0DD5EC1B.jpg" width="350" height="238" /></a><em></em></p>
<p align="center"><em>Figure 10: Button cancel state</em></p>
<p>You don’t want users to worry about where they lift off their finger to avoid accidentally activating a different control. For example, if the OK and CANCEL buttons are close to each other, and the user touched the OK button by mistake and wanted to drag off, they shouldn’t worry about accidentally triggering the CANCEL button. The CANCEL button must not light up with its active style in this case. </p>
<p>This works by default in the HTML platform because because &lt;button&gt; captures touch input. Therefore, as long as the touch down is on the button, the user can comfortably drag off without worrying about triggering something else by accident.</p>
<h3>More than a click</h3>
<p>Touch enables users to have more than one pointer on the screen at any time; this is known as multi-touch, and the direction and speed of touch input, known as gestures, have specific meaning. For example, a finger touching one side of the screen and moving horizontally across the screen is known as a <em>swipe</em>. </p>
<p>With multi-touch in the Windows 8 HTML platform, we now allow more than one control to have the :active state and click events at same time, so when a user touches the screen they can activate more than one control at the same time. A simple control like the &lt;button&gt; can be used for scenarios like keys on a keyboard app or controls for a game! </p>
<p>Additionally, the gesture detection allows us to recognize the different gestures and assign meaning to them for HTML controls. For example, a swipe on top of a button is quickly translated to panning of the page. And a swipe on top of the slider, &lt;input type=”range”&gt;, is interpreted as input for the control. This work will help apps to fluidly react to touch gestures regardless of what controls you happen to land on.</p>
<p>By making all our HTML controls default to a great touch experience via good visual indicators, built in touch targeting enhancements, support of multi-touch and fluidly reaction to touch gesture, your HTML Metro style app will automatically be touch enabled if you use the controls and follow the tips and tricks discussed here! </p>
<h2>Fundamentals: globalization and accessibility</h2>
<p>A great app should reach as many people as possible. This means the app needs be globalized and made accessible. To help you reach this goal, we have build these fundamental pieces into all HTML controls. </p>
<h3>Font support</h3>
<p>We built the right font support into the HTML controls. Even if you don’t plan on localizing your app, your app will still be able to display localized text in any of the languages Windows 8 supports. This is particularly useful whenever your app has to display text based on users’ input, for example, in a text box control. Your app will be able to correctly display the text because we’ve done the work to ensure that the control uses the font that supports those characters. We also provide the the preferred Metro style font that matches correctly to the localized version of Windows. Windows selects the preferred Metro style font for all languages. In short, we take the guesswork out of font support.</p>
<p>If you’d like to know how we did it, you can simply crack open the default style sheet again to see that, for many languages, we automatically set a list of fallback fonts. In the next example, for Japanese, the first font selected is Meiryo UI. But if your app has any Unicode characters that the Meiryo UI font doesn’t cover, then the next fall back font is Segoe UI, and if that is not sufficient, we use Ebrima, and so on. Therefore for most scenarios, your characters will be covered by the Windows Metro style preferred fonts. Even if we don’t have a default font for a particular language, we default to the fall back font in the web platform. Therefore, your users will never see placeholder characters in your controls!</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><p>body:lang(ja), .win-type-xx-large:lang(ja), .win-type-x-large:lang(ja), .win-type-large:lang(ja), .win-type-medium:lang(ja), .win-type-small:lang(ja), </p><p>.win-type-x-small:lang(ja), .win-type-xx-small:lang(ja), input:lang(ja),textarea:lang(ja), </p><p>.win-textarea:lang(ja), button:lang(ja), select:lang(ja), option:lang(ja) <br />{<br />    font-family: &quot;Meiryo UI&quot;, &quot;Segoe UI&quot;, &quot;Ebrima&quot;, &quot;Nirmala UI&quot;, &quot;Gadugi&quot;, &quot;Segoe UI Symbol&quot;, &quot;Khmer UI&quot;, /* etc.*/<br />}</p></pre>
</p></div>
</blockquote>
<p>Also, as you can see from the previous example, we didn’t only add this to the &lt;body&gt; element or just the HTML controls. We are also providing a list of typography styles that you can apply to your app content so that you can get this smart font selection automatically. For more info, see <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh770582" target="_blank">WinJS CSS classes for typography</a>.</p>
<h3>Picking the right resources</h3>
<p>We have created a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465228.aspx" target="_blank">resource loader</a> that makes it easier for you to localize your apps. Use it to load the right set of localized strings for your app as works great for all the HTML controls. The resource loader provides fallback mechanism so that you don’t have to worry about the matrix of languages you need to support. You can now declaratively reference your resources in your HTML and resource loader automatically picks the right resource for you. </p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">button</span> <span style="color: rgb(255, 0, 0);">data-win-res</span><span style="color: rgb(0, 0, 255);">=&quot;{textContent: ‘string2’}&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span>OK<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">button</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
</p></div>
</blockquote>
<h3>Built-in accessibility </h3>
<p>To help your app reach a broad set of audience, all HTML controls have accessibility infrastructure built in. </p>
<p>First, because all HTML controls have semantic meaning, we built in narrator and screen reader support. The goal of a screen is to identify and interpret onscreen visuals for visually impaired users. For a &lt;button&gt;, a screen reader can let the end user know that the app expects an action. and a similar looking button built using a &lt;div&gt; doesn’t. So in order for screen readers and narrator to work properly with a &lt;div&gt;, you need to add your own <a href="http://dev.w3.org/html5/markup/aria/aria.html" target="_blank">ARIA attributes</a>. </p>
<p>Secondly, we ensure all HTML controls continue to support high contrast. High contrast is designed for people who have vision impairment. High contrast color schemes can make the screen easier to view for some users by increasing screen contrast with alternative color combinations. </p>
<p>We have built these colors into the default style sheet and the controls automatically switch to high contrast colors when Windows is set to appear in <a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh700340.aspx" target="_blank">high contrast themes</a>, enabling your app to be high contrast-compliant by default. So even if you have styled and updated the colors of the default intrinsic controls, as long as the selectors you use are the same specificity, Windows ensures that the right high contrast colors shows up. You can learn more about this from our BUILD talk <a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/APP-212T" target="_blank">Stand out in styling for your HTML app</a>.</p>
<p>We achieve high contrast switching by simply adding a media query for high contrast mode and defining all the necessary colors for each of the intrinsic controls in the default style sheet. If you are curious what these colors are, simply open the default style sheet and take a look.</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">@media (-ms-high-contrast) <br />{<br />/* high contrast definition */  <br />}<br /></pre>
</p></div>
</blockquote>
<p>By including great font support, a resource loader to help pick the right localized resources, and building in accessibility we make it as easy as possible for your apps to reach the broad set of Windows users.</p>
<h3>Make your app fast and fluid</h3>
<p>To ensure your HTML app will perform great across all Windows 8 devices (including ARM), we want to make sure the building blocks of your apps, the controls, perform great. </p>
<p>Windows 8 includes an HTML engine that powers both browsing experiences (the Metro style one and desktop one) and Metro style apps that use HTML5 and JavaScript. The common HTML engine provides consistently fast, safe, and powerful support for Web standards and the Web programming model, for both browser experiences and for Metro style apps. This means HTML Metro style apps have all the <a href="http://blogs.msdn.com/b/ie/archive/2011/11/29/html5-for-applications-the-fourth-ie10-platform-preview.aspx" target="_blank">performance benefits</a> of IE10. Here are some highlights that affect HTML controls:</p>
<ul>
<li>Direct2D hardware acceleration</li>
</ul>
<blockquote>
<p>Because the controls are native to the HTML platform, we are able to take advantage of the HTML platform’s Direct2D <a href="http://blogs.msdn.com/b/ie/archive/2010/04/07/a-closer-look-at-internet-explorer-9-hardware-acceleration-through-flying-images.aspx" target="_blank">hardware acceleration</a>. We can now use the GPU for all graphics and text in your Windows 8 HTML app. The GPU can use specialized hardware to efficiently update the screen. By using the GPU for visual rendering, we free up the CPU to perform other operations like JIT(Just-in-time) compiling of your JavaScript code that can further improve the performance of your app.</p>
</blockquote>
<ul>
<li>Independent touch</li>
</ul>
<blockquote>
<p>One of the areas we enhanced the performance of the web platform is panning and zooming. We’ve done a lot of work to make sure the controls work seamlessly with the optimizations we made for panning and zooming. For example, if you use a standard button control on a panning region and the user starts to pan, the system will process the touch action on the panning region and the button in parallel. Therefore, end users will get no slow down because we have extra controls to process and panning actually begin the pan just as quickly as it would have if there weren’t a button there. We worked to ensure using the controls don’t cause any speed bumps unlike what might have happened with some simpler implementations of controls.</p>
</blockquote>
<ul>
<li>Touch robustness for controls</li>
</ul>
<blockquote>
<p>To ensure great performance for touch, we made adjustments to the system so it is more robust. One example is that in &lt;button&gt; we introduced a delay in bubbling up the press state to allow other touch-related gesture like tap or swipe on the &lt;button&gt; to be processed first. This way, we don’t have to immediately do the complicated and CPU intensive parent layout calculations for every interaction. The result is that if the users intend to only tap the button, then the button will move in and out of the press state quickly and back to normal without needing the parent containers to update its layout. Small adjustments like this help the overall robustness of your HTML apps.</p>
</blockquote>
<h2>Integrated tooling</h2>
<p>In addition to all the great platform features we have outlined here, we also provide first class tooling for the HTML controls. </p>
<p>Here are highlights of some of the tooling enhancement in our tools Visual Studio and Blend:</p>
<ul>
<li>In both Visual Studio and Blend, you have first class intellisense for HTML, CSS and JavaScript. For example, in Visual Studio when you indicate you want to set a background color, instead of just text-based intellisense, we now have a color picker.</li>
</ul>
<blockquote>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2620.inline_5F00_color_5F00_1BA83216.jpg" rel="lightbox[1410]" title="Inline color selector in Blend"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Inline color selector in Blend" border="0" alt="Inline color selector in Blend" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/3301.inline_5F00_color_5F00_thumb_5F00_1488F59E.jpg" width="400" height="217" /></a><em>Figure 11: Inline color selector in Blend</em></p>
</blockquote>
<ul>
<li>In Blend, you can now drag and drop all the controls from the toolbox directly onto the design surface. Additionally, you can now lay out and resize the controls directly on the design surface. This way you can visually lay out the controls in your app.</li>
</ul>
<blockquote>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/6433.button_5F00_inBlend_5F00_5F7C666D.jpg" rel="lightbox[1410]" title="Button in Blend design surface"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Button in Blend design surface" border="0" alt="Button in Blend design surface" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/7103.button_5F00_inBlend_5F00_thumb_5F00_5452DC23.jpg" width="300" height="198" /></a><em>Figure 12: Button in Blend design surface</em></p>
</blockquote>
<ul>
<li>In Blend, you can style the controls using the styling panel. </li>
</ul>
<blockquote>
<p>For example, you can use the built in color picker to set background and foreground color. </p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4113.styling_5F00_panel_5F00_5D8B3CB1.jpg" rel="lightbox[1410]" title="styling_panel"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="styling_panel" border="0" alt="styling_panel" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/8308.styling_5F00_panel_5F00_thumb_5F00_643E4634.jpg" width="500" height="196" /></a></p>
<p align="center"><em>Figure 13: Styling panel with color picker in blend</em></p>
</blockquote>
<blockquote>
<p>Or you can do more complicated actions like setting transitions on the control.</p>
</blockquote>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/7181.transitions_5F00_panel_5F00_0CFD8631.jpg" rel="lightbox[1410]" title="Transition properties panel in Blend"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Transition properties panel in Blend" border="0" alt="Transition properties panel in Blend" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5047.transitions_5F00_panel_5F00_thumb_5F00_6CE27973.jpg" width="400" height="343" /></a><em>Figure 14: Transition properties panel in Blend</em></p>
<p>For more info about what is provided in the tools, see <a href="http://blogs.msdn.com/b/somasegar/archive/2011/09/13/expression-blend-for-html.aspx" target="_blank">Soma’s blog</a>.</p>
<h2>Summary</h2>
<p>In this post, I talked a lot about the &lt;button&gt; control, but all the great functionality that applies to &lt;button&gt; applies to all the other native HTML controls too. </p>
<p>We made lots of investments to fine tune HTML controls for you to build Metro style apps. These controls now work great on a wide variety of form factors, can bring users a better experience, and increase the reach of your app. Some of the major apps available on the Release Preview mainly use HTML controls, such as the Windows 8 App Store and the Mail, Calendar, and Photo apps. By using these controls your app can get the Metro style look and feel for free and you can focus on the core value of your app.</p>
<p>For more info, see:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465393" target="_blank">Adding controls and content</a></p>
<p><a href="http://msdn.microsoft.com/library/windows/apps/hh465424" target="_blank">Control UX guidelines for Metro style apps</a></p>
<p>SDK samples: </p>
<p><a href="http://code.msdn.microsoft.com/windowsapps/App-Branding-sample-9f87b7a2" target="_blank">CSS styling: branding your app sample</a></p>
<p><a href="http://code.msdn.microsoft.com/windowsapps/Common-HTML-controls-and-09a72a24" target="_blank">HTML control sample</a></p>
<p>And //BUILD/ talks on <a href="http://channel9.msdn.com/events/BUILD/BUILD2011/APP-211T" target="_blank">control</a> and <a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/APP-212T" target="_blank">styling</a>.</p>
<p>&#8211; Kathy Kam, Senior Program Manager, Windows</p>
<hr align="left" size="1" width="33%" />
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10333827" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/windowsappdev/archive/2012/07/26/using-html-controls-to-create-great-metro-style-apps.aspx">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/07/using-html-controls-to-create-great-metro-style-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Metro style apps in Windows 8</title>
		<link>http://www.windows8tricks.net/2012/07/testing-metro-style-apps-in-windows-8/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=testing-metro-style-apps-in-windows-8</link>
		<comments>http://www.windows8tricks.net/2012/07/testing-metro-style-apps-in-windows-8/#comments</comments>
		<pubDate>Fri, 13 Jul 2012 07:24:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/07/testing-metro-style-apps-in-windows-8/</guid>
		<description><![CDATA[In the world of Metro style apps, your apps are the focus of the whole experience. For this experience to be delightful to your users, you want to ensure that your apps are well tested and represent a high level of quality. Producing a Metro style app involves four main stages: design, development, testing and]]></description>
			<content:encoded><![CDATA[<p>In the world of Metro style apps, your apps are the focus of the whole experience. For this experience to be delightful to your users, you want to ensure that your apps are well tested and represent a high level of quality. Producing a Metro style app involves four main stages: design, development, testing and finally distribution.</p>
<p>A number of previous blog posts focus on the design and development aspects of Metro style apps. In this post, we cover a few high level verification areas related to testing your apps.</p>
<p>The term <i>testing</i> is overloaded, meaning different things to different people, especially in the context of the software development lifecycle. It also involves a diverse set of activities that can be executed at different stages of software development. These activities include unit testing, functional testing, usability testing, scenario testing, and a few others. Any one of these activities represents only one piece of the testing puzzle and doesn’t cover all the necessary verification that you need to put an app through to make sure it is of high quality. In this post, we don’t distinguish between the specific types of verification. Instead, we provide a broad set of high-level verification areas and exercises that will help you ensure that your app represents a high level of quality. In addition to these verification areas, you can also verify the functionality of your app during development using <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441477(v=vs.110).aspx" target="_blank">Visual Studio for debugging and testing</a>, and the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441482(v=vs.110).aspx" target="_blank">Visual Studio Unit Test Tools</a>. In the coming weeks, we plan to do more blog posts that will dive deeper into specifics of testing Metro style apps.</p>
<p>As we saw in the “<a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/10/managing-app-lifecycle-so-your-apps-feel-quot-always-alive-quot.aspx" target="_blank">managing app lifecycle</a>” blog post, a Metro style app can transition between various runtime states. Based on this app lifecycle, we like to think of these key areas of verification:</p>
<ul>
<li><b>Activated</b>: verify the app through several activation paths</li>
<li><b>Running</b>: verify the app at runtime</li>
<li><b>Suspended</b>: verify the app suspends correctly</li>
<li><b>Resumed</b>: verify the app resumes correctly</li>
<li><b>Terminated</b>: verify the app terminates </li>
<li><b>Not</b> <b>running</b>: verify behavior when your app is not running</li>
</ul>
<p>Let’s dive deeper into the key verification areas during each of these areas. </p>
<h3>Verify activation behavior of the app</h3>
<p>To test activation we need to go through the various contexts in which users can launch your app. It is important to verify each activation scenario your app supports. Here are the common contexts in which users can activate your app:</p>
<ul>
<li><b>Tile:</b><b> </b>The launch of your app through the tile is very likely the first interaction that users have with your app. Verify that your app follows the appropriate <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/05/21/creating-a-fast-and-fluid-app-launch-experience.aspx" target="_blank">app launch design pattern</a>. </li>
<li><b>Toast notifications:</b> If your app supports <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh779727.aspx" target="_blank">toast notifications</a>, verify that your app activates functions as expected when you click an incoming notification that your app is meant to handle.</li>
<li><b>Search:</b><b> </b>If your app supports <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464906.aspx#search_contract" target="_blank">Search</a>, verify that your app activates and that you can complete a search in your app. If your app supports displaying search suggestions, verify that it functions as expected.</li>
<li><b>Share target:</b><b> </b>If your app supports being a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464906.aspx#share_contract" target="_blank">Share</a> target, verify that your app activates and posts the content shared from another app for the supported types of content.<b></b></li>
<li><b>Protocol:</b><b> </b>If your app registers for a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh452686.aspx" target="_blank">protocol</a>, verify that you can activate your app by launching various types of URLs corresponding to this protocol. </li>
<li><b>File association:</b><b> </b>If your app registers to handle a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh452684.aspx" target="_blank">file type</a>, verify that you can activate your app by launching files of the corresponding file type. </li>
<li><b>File pickers/contact picker:</b> If your app is registered as a file open/save <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465174.aspx" target="_blank">picker</a> or as a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464906.aspx#contact_picker" target="_blank">contact picker</a>, verify that you can activate your app in those contexts. </li>
</ul>
<h3>Verify runtime behavior of the app</h3>
<p>Verifying the functionality of a Metro style app is a combination of verifying the common characteristics that apply to all apps, and verifying the app specific functionality. In addition to the key verification scenarios we talk about in a moment, you must also verify the app-specific functionality. This involves understanding the key scenarios targeted by your app and verifying that these scenarios work as expected.</p>
<h4>Tiles</h4>
<p>The app <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh779723.aspx" target="_blank">tile</a> is a core part of your app, and possibly the most frequently seen part of your app. The following aspects of your tile behavior are important to verify: </p>
<ul>
<li>If your app supports live tiles, verify its behavior while your app is running. Verify that the tile updates are consistent with the state displayed within your app. For example, a photo app’s tile could show photos from the most recently added album.</li>
<li>If your app supports <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465372.aspx" target="_blank">secondary tiles</a>, verify that they display the expected info. For example, a weather app can support pinning specific cities as secondary tiles. You need to also verify that clicking the secondary tile results in the app launching and taking you to the expected context within the app.</li>
<li>If your app supports <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh779719.aspx" target="_blank">notification badges</a> in the tiles, verify that any badge update shows as expected, and that it is consistent with the corresponding state displayed within your app. For example, a badge related to the count of unread mail in a mail app must get cleared when the app runs to let the user know that they no longer have any unread mail.</li>
</ul>
<h4>Toast notifications</h4>
<p>If your app supports <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh779727.aspx" target="_blank">toast notifications</a>, verify that the toasts trigger and display correctly. Also verify that clicking the toast notification results in the app launching and taking you to the expected context within the app.</p>
<h4>Contracts and extensions</h4>
<p>We looked at a few contracts earlier as part of verifying the activation behavior of your app. Let’s look at a few additional areas related to verifying <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/03/23/activating-windows-8-contracts-in-your-app.aspx" target="_blank">contracts</a> at runtime: </p>
<ul>
<li><b>Share source</b>: If your app supports being a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh758314.aspx" target="_blank">sharing</a> source, verify that you can use the Share charm to share content from your app (for the supported types of content) to other target apps on the machine.</li>
<li><b>Play to</b>: If your app supports the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464906#play_to_contract" target="_blank">Play To contract</a>, verify that you can use the Devices charm to play media from your app on a remote device.</li>
<li><b>Settings:</b> If your app supports the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464906#settings_contract" target="_blank">Settings contract</a>, verify that you can view and modify your app specific settings. Also, verify that the app persists the modified settings across termination/re-launch.</li>
</ul>
<h4>Windows App Certification Kit</h4>
<p>The <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh694081.aspx" target="_blank">Windows App Certification Kit</a> allows you to verify that your app meets the Windows Store submission criteria. This kit includes automated tests to verify the usage of supported APIs, testing for crashes/hangs, verification of the application manifest, and launch/suspension time performance. We recommend that you run this kit early and often. We’ve experienced a number of situations where the app didn’t make it to the Store by the deadline because the app owner waited till the last minute to run the certification kit against the app. If you run the kit early and often you can discover and fix any app issues quickly and submit your app to the Store. The <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh694081.aspx" target="_blank">Windows App Certification Kit documentation</a> has details on the types of tests the kit does and additional tips on the configurations under which to run the kit.</p>
<h4>Snapped and fill views</h4>
<p>Users can run your Metro style app under various view states. In addition to the full screen view, users can use your app in the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465386.aspx#View_State" target="_blank">snapped and fill views</a>. It is important to verify that your app handles these view state transitions correctly.</p>
<ul>
<li>Verify that your app supports the snapped and fill views. Verify that your app maintains the context when it gets snapped or unsnapped.</li>
<li>Verify that snapping and unsnapping doesn’t destroy the user&#8217;s work or state.</li>
<li>Verify that the user can interact with your app while it is snapped.</li>
</ul>
<h4>Rotation</h4>
<p>Users can rotate and flip their tablets and monitors. If your app supports the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465386.aspx#Screen_orientation" target="_blank">portrait orientation</a> in addition to the landscape orientation, verify that your app can handle the orientation changes. You can use the <a href="http://msdn.microsoft.com/library/windows/apps/hh441475.aspx" target="_blank">Visual Studio simulator for Metro style apps</a> to test your app in both modes. So, you don’t necessarily need a tablet device to test this scenario.</p>
<h4>Touch</h4>
<p>Windows 8 enables apps to have a number of new touch experiences. You can use the <a href="http://msdn.microsoft.com/library/windows/apps/hh441475.aspx" target="_blank">Visual Studio simulator for Metro style apps</a> to test the touch interactions that your app supports. So, you don’t necessarily need dedicated touch hardware to verify these interactions.</p>
<ul>
<li>Verify that all the controls used in the app are standard basic controls that are touch-friendly. Depending on your programming language, use either the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465328.aspx" target="_blank">XAML controls</a> or the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465393.aspx" target="_blank">JavaScript controls</a>.</li>
<li>Verify that your Metro style app follows the standard <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465415.aspx" target="_blank">Touch interaction design</a>.</li>
<li>Verify that your app provides visual feedback for the user actions.</li>
<li>Verify that your app avoids dragging actions from the edges of the screen to avoid conflicting with the Windows OS gestures.</li>
<li>If the app supports any text input controls, verify that the soft keyboard works as expected. Verify that the area with the keyboard focus shifts up into view when the soft keyboard is displayed.</li>
</ul>
<h4>Playing audio</h4>
<p>Windows 8 supports a model for Metro style apps to play audio, including playing in the background. Here’s what we recommend for testing audio:</p>
<ul>
<li>If your app plays audio, verify that it handles the sound level notifications appropriately when a user switches between your app and other types of audio apps. For example, if your app is a game, you might want to pause the game when it receives a “Muted” notification. For details, see <a href="http://msdn.microsoft.com/en-us/library/windows/hardware/hh770517" target="_blank">Audio playback in a Metro style app</a>.</li>
<li>If your app supports playing audio in the background, verify that your app continues playing <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/05/16/being-productive-when-your-app-is-offscreen.aspx" target="_blank">audio in the background</a> without getting suspended. Verify that your app continues to play audio when the user locks the machine.</li>
<li>If your app registers for the transport controls to control playback of music, verify that it works as expected.</li>
</ul>
<h4>Different screen sizes</h4>
<p>Windows 8 runs on a variety of <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh780612.aspx#screen_size" target="_blank">screen sizes</a>, from a small screen on a tablet, to a medium laptop screen all the way up to a large desktop screen. Therefore it is important to test your app on different screen sizes. You can use the <a href="http://msdn.microsoft.com/library/windows/apps/hh441475.aspx" target="_blank">Visual Studio simulator for Metro style apps</a> to test your app on a variety of screen sizes and pixel densities.</p>
<ul>
<li>On resolutions between 1024&#215;768 and 2560&#215;1440, verify that your app’s layouts are not truncated and that content appears where expected.</li>
<li>Verify that images are crisp when scaled to pixel density.</li>
</ul>
<h4>Data roaming </h4>
<p>Windows 8 enables roaming settings across multiple PCs, including the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465094.aspx" target="_blank">roaming state</a> persisted by your Metro style apps. To test this:</p>
<ul>
<li>Verify that the app context roams as expected across multiple PCs. For example, this could be the last completed level in a game, the most recently read page in a book, or the last watched position of a video in your app. Verify that the context the app set on one PC is reflected when you use the app on another PC.</li>
<li>Verify that the applicable user preferences for your app roam as expected across multiple PCs. For example, this could be the user’s unit preference for the temperature in a Weather app. In this example, verify that the user’s unit preference set on one PC is reflected when you use the app on another PC.</li>
</ul>
<h4>Devices and sensors</h4>
<p>If your Metro style app supports devices or sensors, you need to verify these areas.</p>
<ul>
<li>If your app supports tailoring the view based on the geolocation, verify that it works as expected. You can use the <a href="http://msdn.microsoft.com/library/windows/apps/hh441475.aspx" target="_blank">Visual Studio simulator for Metro style apps</a> to test this as it supports an option to set the current location.</li>
<li>If your app supports responding to user-initiated device connections like a camera or USB drive, verify that your app correctly performs the action corresponding to that event. For example, this could be verifying that users can use your app to copy all the images from a camera. Also, verify that your app handles device disconnects gracefully. For example, this involves verifying how your app behaves if the user disconnects the camera while your app is copying images from the camera.</li>
<li>Users can dock certain types of machines or devices to a docking station. Verify that your app behaves as expected both when the machine is docked and undocked.</li>
</ul>
<h4>Performance </h4>
<p>Users expect apps to respond immediately to inputs. So it is critical to verify the performance characteristics of your app. As Windows 8 can run on a variety of hardware, consider installing your app on a low end machine to measure its performance characteristics. The post <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/03/how-to-improve-performance-in-your-metro-style-app.aspx" target="_blank">How to improve performance in your Metro style app</a> has details on how to prepare a machine for measurements.</p>
<h5>Responsiveness</h5>
<ul>
<li>For the key scenarios supported by your app, understand the expected <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/03/how-to-improve-performance-in-your-metro-style-app.aspx" target="_blank">interaction classes</a><i> </i>and verify that the app meets the goals for that particular interaction class.</li>
<li>Verify that your app remains responsive to the user.</li>
<li>Verify that your app provides feedback to the user during any long-running activities, such as an asynchronous network call.</li>
</ul>
<h5>Being a good citizen in the app ecosystem</h5>
<p>As the post <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/03/how-to-improve-performance-in-your-metro-style-app.aspx" target="_blank">How to improve performance in your Metro style app</a> explains, it is important to verify that your app is a good citizen in the app ecosystem. This involves contributing positively to the user’s overall experience (whether your app is in the foreground or not). In addition to verifying the areas that post lists, here are a few additional areas to verify: </p>
<ul>
<li>When in idle state, if you expect your app to not be using CPU, verify that the app doesn’t consume any CPU.</li>
<li>Users could be on various types of networks including metered networks. If your app connects to the Internet, verify that it <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465399.aspx#adapt" target="_blank">adapts its behavior</a> for metered networks when sending and receiving data.</li>
</ul>
<h4>Error handling</h4>
<p>As the saying goes, anything that can go wrong, will <img src='http://www.windows8tricks.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Seriously, when a condition your app depends on changes, it can impact your app’s behavior. For example, your app needs to handle network connectivity not being available and decide on how to behave in this situation. </p>
<ul>
<li>Verify that your app handles error conditions appropriately. As in our example, network and/or device connectivity is a great way to trigger error paths in your app. Verify that your app follows the guidelines for <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh700376.aspx" target="_blank">managing connection state changes</a>.</li>
<li>Verify that the error handling is not intrusive and that your app displays only the critical errors to the user.</li>
<li>Verify that your app provides actionable error messages to the user. See the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465304.aspx#errors" target="_blank">guidelines for actionable error messages</a>.</li>
</ul>
<h4>Reliability</h4>
<p>Users expect apps to work reliably and consistently. It is important to verify that your app is highly reliable.</p>
<ul>
<li>Verify that your app runs reliably across varied conditions and that it doesn’t crash because of unhandled exceptions.</li>
<li>Verify that your app doesn’t leak memory or any other resources. To detect memory leaks in a Metro style app, you can use the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd744766(v=vs.85).aspx" target="_blank">same methods</a> that you normally use with other Windows applications. </li>
</ul>
<p>After you publish your app to the Windows Store, you can use the Windows Store developer portal to review your app’s usage and <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh967782.aspx" target="_blank">quality data</a>.&#160; For example, you can view the data about exceptions, crashes, and unresponsiveness issues that your users encountered.&#160; Consider using this data to fix the top crashes and hangs in your app.</p>
<h4>Accessibility </h4>
<p>Windows 8 is designed for a broad spectrum of people and is accessible to everyone regardless of their abilities. If your Metro style app meets a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh452702.aspx" target="_blank">baseline of accessibility</a>, it can contribute tremendously to improving the accessibility ecosystem. If your app supports accessibility, verify that it meets the criteria described in <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh452726.aspx" target="_blank">Testing your app for accessibility</a>.</p>
<h4>Globalization and localization</h4>
<p>If your Metro style app is designed to be global, it can be localized for a variety of regions and markets. Metro style apps can use the configured language and display formats (date, time, currency, and numbers) to tailor their content. For example, if a user configures Japanese as the primary language on an English installation of Windows, and then launches a Metro style Stocks app, the app can display all the related news articles in Japanese and additionally show info about the stocks trading in the selected region (e.g. Tokyo Stock Exchange).</p>
<p>If your app is localized, verify that it works for different locales and display languages.</p>
<ul>
<li>For the languages your app supports, use the Language settings in the Control Panel to add each of the specific languages as a primary language, and verify that your app tailors the content appropriate for that language.</li>
<li>Verify that changing the language when your app is running or suspended works as expected.</li>
<li>For the languages your app supports, verify that the user interface strings appear as expected and don’t get truncated.</li>
<li>Verify that any text shown in the app’s images is in the selected display language.</li>
</ul>
<h4>Processor architectures </h4>
<p>A Metro style app can be architecture-neutral or it could target a specific architecture.</p>
<p>If your app is architecture neutral, it can be tested on any chosen architecture.</p>
<p>If it is architecture specific, it needs to be tested on all the supported architectures.</p>
<ul>
<li>If your app is targeted specifically for Windows RT (ARM), verify its functionality on a Windows RT PC. You can find additional info on developing and testing on ARM in the blog post <a href="http://blogs.msdn.com/b/jasonz/archive/2012/06/12/what-you-need-to-know-about-developing-for-windows-on-arm-woa.aspx" target="_blank">What you need to know about developing for Windows on ARM (WOA)</a>. </li>
<li>If your app targets x86 and doesn’t separately provide a x64 package, verify that your app functions correctly on both x86 and x64 systems. This is because x86 apps can run on x86 (32-bit Windows) or x64 (64-bit Windows) systems. Windows allows apps targeted for x86 to run on x64 systems.</li>
</ul>
<h3>Verify suspension behavior of the app</h3>
<p>Windows suspends your app when it is not in the foreground. In this way, Windows gives the foreground app better use of system resources and ensures that apps in the background can’t drain the user’s battery. For example, during suspension, a Stocks app can persist info about the last stock that the user was viewing and the time range for a stock chart.</p>
<ul>
<li>Verify that your app reduces memory usage while it is in a suspended state. To view the suspension status in Task Manager, click More details in Task Manager to see all available options, and then click View &gt; Status values &gt; Show suspended status.</li>
<li>If your app supports uploading or downloading of <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.backgroundtransfer.aspx" target="_blank">data in the background</a>, verify that data continues to be transferred even when the app is suspended.</li>
</ul>
<p>You can use Visual Studio to <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh974425(v=vs.110).aspx" target="_blank">simulate the suspension/resumption of an app</a>. To do this, select View &gt; Toolbars &gt; Debug Location.</p>
<h3>Verify resumption behavior of the app</h3>
<p>When your app comes back to the foreground, Windows resumes your app, and it continues from the state that it was in when Windows suspended it. It is important to verify that your app resumes gracefully.</p>
<ul>
<li>Your app could be resuming after being suspended for a long time. During this time, the displayed content and any network connections could have become stale. Verify that your app resumes and that it provides a visual indication about the state of its content. </li>
<li>After your app resumes, verify that it can refresh its content and can reconnect to any network resources, as required. For example, after a Stocks app resumes, it can provide a visual indication of the time the data was last updated, and then go on to update the cached stock data so that the user sees the latest stock prices.</li>
</ul>
<h3>Verify termination behavior of the app</h3>
<p>Windows can terminate a suspended app when the system is running low on resources. Additionally, your app can also get terminated when the user manually closes it, or signs out of Windows. Depending on how the app gets terminated, it is important to verify that your app restores the right app data when it is launched after a termination.</p>
<ul>
<li>When launching an app after Windows terminated it, verify that your app restores the context and state as it was before getting suspended and/or terminated.&#160; For example, this could be the last viewed stock info and the selected duration of the chart that was saved when the app was suspended.</li>
<li>When launching an app after manually closing it (by swiping from the top to the bottom of the screen), verify that your app starts with the default data.</li>
<li>When launching an app after an unexpected termination such as a crash, verify that your app is still able to launch and that it loads the default data. To cause an unexpected termination for your app, in the Task Manager right click your app &gt; Go to details &gt; right click &gt; end task.</li>
</ul>
<p>For more details, see <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/10/managing-app-lifecycle-so-your-apps-feel-quot-always-alive-quot.aspx" target="_blank">Managing app lifecycle so your apps feel &quot;always alive&quot;</a>.</p>
<h3>Verify app behavior when not running</h3>
<p>A Metro style app can surface info to the user even when it is not running. So, it is important to verify that the below scenarios work as expected.</p>
<h4>Tiles</h4>
<p>Here are the main areas to verify when your app is not running:</p>
<ul>
<li>Verify that the default tile displays as expected. Verify that the tile size, usage, and notifications follow the guidelines in <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465403.aspx" target="_blank">Guidelines and checklist for tiles</a>.</li>
<li>If your app supports <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh779721.aspx" target="_blank">scheduled notifications or periodic/push notifications from the cloud</a>, verify that its tile gets updated even when your app is not running. Examples of this are a weather app that periodically updates its tile with the current temperature, and a sports app that updates its tile with the latest scores pushed from the cloud. </li>
<li>A live tile is one of the best ways to entice users back to your app. Validate that the info in your live tile shows the best of what’s going on inside of your app.</li>
</ul>
<h4>Toast notifications</h4>
<p>If your app supports toast notifications even when it’s not running (using <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh779721.aspx" target="_blank">scheduled notifications or push notification</a>s), verify that the toast notifications trigger and display as expected even when the app is not running. Examples of this are a calendar app that schedules meeting reminders as toast notifications and a news app that displays breaking news as toast notifications.</p>
<h4>Background tasks</h4>
<p>If your app supports background tasks, verify the corresponding behavior.</p>
<ul>
<li>If your app is capable of showing lock screen notifications (e.g. a mail app or a VoIP app that always has to stay up to date), verify that the info surfaced by your app stays up to date even when the PC is not used.</li>
<li>If your app can perform background tasks on certain triggers (e.g. a Photos app that processes pictures from the Photos library when on AC power), verify that your app performs that task correctly when the appropriate conditions are met.</li>
</ul>
<p>For details, see the <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/05/24/being-productive-in-the-background-background-tasks.aspx" target="_blank">Background tasks</a> blog post.</p>
<h3>Conclusion</h3>
<p>Testing your Metro style app and verifying its quality is a critical step to ensure that your users have a great experience with your app. In this blog post, we covered a few key areas related to verifying your Metro style apps including verifying the behavior of your app when it is launched in different contexts, verifying the functionality of your app, and verifying the behavior of your app as it transitions through various states of the Metro style app lifecycle.</p>
<p>In the real world, a user could combine many interactions that impact your app.&#160; For example, a user could, in quick succession, snap your app to the Fill view, rotate the device, and adjust the screen resolution.&#160; So, in addition to testing the app behavior for a specific scenario in isolation, bring out your creative juices and exercise your app to account for such complex interactions. </p>
<p>We hope you find this to be a good starting point to think about how to verify the functionality of your apps and have them represent a high level of quality. In the coming weeks, we plan to do more blog posts that will dive deeper into specific topics pertaining to testing Metro style apps.</p>
<p>Thanks!</p>
<p>&#8211; J. Kalyana Sundaram, Senior SDET, Windows</p>
<p>&#8211; Ashwin Needamangala, Principal Test Lead, Windows</p>
<p>&#8211; Mete Goktepe, Principal Test Manager, Windows</p>
<p>Special thanks to Tom White, Patrik Lundberg, Tom Baxter, Vik Kumar, Rui Sun and Yves Neyrand for their help and contributions to this post. </p>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10328599" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/windowsappdev/archive/2012/07/12/testing-metro-style-apps-in-windows-8.aspx">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/07/testing-metro-style-apps-in-windows-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Metro style apps that stand out from the crowd</title>
		<link>http://www.windows8tricks.net/2012/07/creating-metro-style-apps-that-stand-out-from-the-crowd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-metro-style-apps-that-stand-out-from-the-crowd</link>
		<comments>http://www.windows8tricks.net/2012/07/creating-metro-style-apps-that-stand-out-from-the-crowd/#comments</comments>
		<pubDate>Thu, 12 Jul 2012 04:24:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[Creating]]></category>
		<category><![CDATA[crowd]]></category>
		<category><![CDATA[from]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[stand]]></category>
		<category><![CDATA[Style]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/07/creating-metro-style-apps-that-stand-out-from-the-crowd/</guid>
		<description><![CDATA[When you submit your app into the Store, there will no doubt be other apps in your category that will compete for people’s attention. Being able to crisply showcase the differentiation points in your offerings and staying focused on delivering the core scenarios that you are best at are crucial to a successful Metro style]]></description>
			<content:encoded><![CDATA[<p align="left">When you submit your app into the Store, there will no doubt be other apps in your category that will compete for people’s attention. Being able to crisply showcase the differentiation points in your offerings and staying focused on delivering the core scenarios that you are best at are crucial to a successful Metro style app that will stand out from the crowd. </p>
<p>Windows 8 provides a set of <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh770552.aspx" target="_blank">design patterns</a>, <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465424#ui_controls" target="_blank">common controls</a>, and built-in platform functionalities such as <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465424#contracts_and_capabilities" target="_blank">contracts</a> that can help you focus on what you are best at. For example, just to name a few: the <a href="http://msdn.microsoft.com/en-US/library/windows/apps/hh465302" target="_blank">app bar</a> is a common control that helps people focus on your content and minimize distractions; the <a href="http://go.microsoft.com/fwlink/?LinkId=242592" target="_blank">touch pattern</a> prescribes a set of gestures that are used consistently in platform controls, such as swiping from the edge to bring up the app bar, so that people can focus on confidently use your app without having to learn new interfaces; the <a href="http://msdn.microsoft.com/en-US/library/windows/apps/hh465251" target="_blank">Share contract</a> is the glue that lets two apps work together so that users can accomplish more with your content. </p>
<p>This post is a little different from some of the other posts – rather than talking about coding patterns, we talk about design patterns that you can use in your planning process. I introduce an example app, Food with friends, and start by answering the question that is key to standing out from the crowd: “What is my app best at in its category?”. Then I illustrate some practical steps to designing the app’s structure and layout to highlight the core scenarios and differentiation points that it is best at. This is the first in a series of occasional posts that will come over the next few months. The later posts will continue to use this app as an example and walk through ways that you can take advantage of these various aspects of the Windows 8 platform to create experiences that feel immersive, crafted, fast, and fluid. </p>
<p>Let’s get started! </p>
<h3>Example: Food with friends</h3>
<p>Say we are building an app that helps people find restaurants. Let’s look at the design process for this app.</p>
<h4>1. Identifying the differentiation points</h4>
<p>We will start by identifying a focus that will allow to differentiate ourselves from other competitors in the restaurant and dining category: </p>
<p><b>My app is the best in its category at<i> helping users and their friends find a restaurant to eat at tonight.</i></b></p>
<p>The unique point of view of this app is on helping users <i>and their friends</i> and dining <i>tonight</i>. This app will revolve around getting friends to agree on a place to eat, and will focus on bubbling up friends’ preferences so a user can take them into account when making decisions. This emphasis makes our app stand out from other generic apps in the same category that may simply be providing local restaurant listings. </p>
<p>This “best-at” statement describes the reasons why user will want to buy this app and not a competitor’s in the same category. We will be referring back to it many times as we make design trade-offs and decide on which feature set and platform functionalities to use. </p>
<p>Given this, let’s call this app <i>Food with friends</i>. </p>
<h4>2. Picking the right scenarios</h4>
<p>Next, let’s identify the core scenarios our app will focus on based on our best-at statement. In the process of brainstorming and selecting scenarios, there may be a great number of interesting ones that we could<i> </i>support (such as seeing nutritional value of dishes). But to actually deliver the unique, differentiated, best-in-class experience that our best-at statement promises, we must say no to them if they don’t tie back to our vision. Based on that, here are the core scenarios that this app will be great at: </p>
<ul>
<li>Find restaurants that I want to eat at</li>
<li>Find restaurants that my friends want to eat at</li>
<li>Make dinner plans for tonight with friends</li>
</ul>
<p>We want to start by thinking about scenarios that describe why people want to use the app, before we start thinking about features, which are how they will achieve those goals. Each of our scenarios will encompass a number of features. When we know what the core scenarios are, we can then think about features that will enable those scenarios. We will get to more details on feature selection and design in the next post, but here are some examples of possible features: </p>
<ul>
<li>Find restaurants that I want to eat at: </li>
<ul>
<li>Browse restaurants on a map or in a list</li>
<li>Search by name or keyword</li>
<li>Filter/Sort by category, price and rating</li>
<li>Add/remove restaurants to/from wishlist</li>
</ul>
</ul>
<h4>3. Creating the landing experience</h4>
<p>The landing page is the key to any Metro style app. It is your chance to tell your user what your app is best at. When users open your app you want them to immediately understand what your app’s core scenarios are and how they deliver unique values. A good landing page motivates users to open the app by always providing new and up to date content, and convinces them to stick around and spend more time in the app. It is like a hub, the center of interest and shows the best of the app. </p>
<p>Designing a great hub is about creating a layout that optimizes for bringing content and functionality to people in an easy to explore way. Typical navigation in apps or on the web involves showing a default section of an app, and then relies on users choosing to go to a new section from a navigation bar or table of contents. The trouble with this pattern is that it doesn’t encourage exploration. In order for people to decide to click a tab and navigate to a new section, they need to believe that there is something in there that would be interesting or useful to them. If there are no interesting sections, they’ll switch to another app. For example, this newsreader app uses a tab-based design where people land in a single section, but then have to consciously make a decision to navigate to other sections of the app just based on the name. You cannot tell if any of those 4 other sections are interesting until you switch to it:</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1777.tab_2D00_based_5F00_32723016.jpg" rel="lightbox[1383]" title="tab-based"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="tab-based" border="0" alt="Tab-based landing page design" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5305.tab_2D00_based_5F00_thumb_5F00_522109DE.jpg" width="600" height="338" /></a></p>
<p>Instead, convert this to a hub and simply add panning, which requires no hard decision from users at all, and they will <i>see</i> why the content or functionality of the app is interesting to them.</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/6471.hub_2D00_based_5F00_1D147AAE.jpg" rel="lightbox[1383]" title="hub-based"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="hub-based" border="0" alt="Hub-based landing page design" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2678.hub_2D00_based_5F00_thumb_5F00_5CDE6133.jpg" width="600" height="338" /></a></p>
<p>By laying out the app so it’s easy to explore, we show users why they should stick around. We show them the full breadth of what our app is best at.</p>
<p>So with that in mind, let’s start with a basic hub layout using the Visual Studio Grid project template (<a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh768232(v=win.10).aspx" target="_blank">XAML</a>, <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh758331.aspx#grid_project_template_for_metro_style_apps" target="_blank">HTML</a>). Its landing page (the groupedItemsPage) has a number of sections and selected items from each one: </p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/3240.visual_2D00_studio_2D00_grid_5F00_6AB0A72E.jpg" rel="lightbox[1383]" title="visual studio grid"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="visual studio grid" border="0" alt="Visual studio Grid project template’s landing page" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1106.visual_2D00_studio_2D00_grid_5F00_thumb_5F00_7882ED29.jpg" width="700" height="236" /></a></p>
<p>We want this page to really represent the best-at statement of: <i>My app is the best in its category at helping users and their friends find a restaurant to eat at tonight</i>. The first step is to make each section of our hub represent one of our three core scenarios.<b><i> </i></b>Each<b><i> </i></b>core scenario must be represented (though there could be multiple sections that tie back to a scenario):</p>
<div align="center"></div>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3" width="494" align="center">
<tbody>
<tr>
<td valign="top" width="126">
<p align="left"><b>1. Tonight</b></p>
</td>
<td valign="top" width="366">
<p align="left">Focuses on making dinner plans for tonight with friends</p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>2. Friends’ wishlists</b></p>
</td>
<td valign="top" width="366">
<p align="left">Focuses on finding restaurants that my friends want to eat at</p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>3. My wishlist</b></p>
</td>
<td valign="top" width="366">
<p align="left">Focuses on finding restaurants that I want to eat at</p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>4. All Restaurants</b></p>
</td>
<td valign="top" width="366">
<p align="left">Also focuses on finding restaurants that I want to eat at</p>
</td>
</tr>
</tbody>
</table></div>
<div align="center"></div>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2766.visual_2D00_studio_2D00_grid_2D00_2_5F00_43765DF9.jpg" rel="lightbox[1383]" title="visual studio grid 2"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="visual studio grid 2" border="0" alt="Hub with sections for Tonight, Friends’ wishlist, My wishlist, All restaurant" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1780.visual_2D00_studio_2D00_grid_2D00_2_5F00_thumb_5F00_235B513C.jpg" width="700" height="236" /></a></p>
<p align="left">The order of the sections is strategic. The reason tonight is first is because it is the most relevant section to what is going on <i>right now</i> and so it is likely to change every time you open the app. Info about tonight is also a great candidate for live tile content because it’s fresh, personal and relevant. This lineup means that if people see what is happening tonight on the app’s live tile on the Start screen, they can open the app and see the content they just saw on the live tile right on the hub page. Your app should reward users for opening the app with info that’s new and most important to them. For more on live tiles take a look at Kevin Michael Woley’s <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/16/creating-a-great-tile-experience-part-1.aspx" target="_blank">Creating a great tile experience</a> post.</p>
<div align="center"></div>
<p align="left">Next we put Friends’ wishlists, and then My wishlist – these are in that order for two reasons:</p>
<div align="center"></div>
<div align="center">
<ul>
<li>
<div align="left">The focus of Food with friends is on my friends – that’s the differentiator, and is what Food with friends does that nobody else does in quite the same way. </div>
</li>
<li>
<div align="left">Like the Tonight section, others will update their wishlists while a user is away from the app and so it can change often. It contains info user doesn’t know, while they are more familiar with their own wishlists and so it is less critical to explore it.</div>
</li>
</ul></div>
<p align="left">We put All restaurants at the end. We expect users to go to this section only when they want to manage their wishlist, but according to our best at statement, most of the time users will be making decisions about where to go <i>tonight</i> which means most of the time they will be looking at the wishlists that are already there and at the suggestions for tonight. Having it at the end also provides a nice benefit that the section can expand as long as you like, without pushing off other content. You may be concerned that All restaurants is so far over, but don’t be. Quickly jumping through a list is what <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465319" target="_blank">Semantic Zoom</a> is for. </p>
<h4 align="left">4. Designing the sections</h4>
<p align="left">A key to designing a section to optimize it for its corresponding scenario. It doesn’t need to be a uniform grid of tiles across the whole hub! This is where we can get creative, demonstrate how our app is different from others and bring forward what our app is best at. We also don’t have to show all items in a given section on the landing page because that may be overwhelming. Instead we may want to only bubble up a curated set of items that are the most relevant and up-to-date. For example, we show only the top friends under Friends’ wishlist, and the most recently added restaurants under My Wishlist.</p>
<p align="left">For this app, the first section, Tonight, is all about deciding with your friends where to eat <i>tonight</i>. Because this requires collaboration between your friends and you, this is best as a <a>discussion</a>:</p>
<p align="left"><a></a><a href="http://windows/windows8/DevX/Developer Blog/Blogs/#_msocom_7" name="_msoanchor_7"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="foodwfriends landing" border="0" alt="Landing page with Tonight section filled in with conversations on dinner plans with friends" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4426.foodwfriends_2D00_landing_5F00_1C3C14C4.png" width="700" height="394" /></a></p>
<p align="left">My friend’s wishlist is all about <i>my friends</i> and what they want, so in that section, let’s really make it about the people!</p>
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5164.foodwfriends_2D00_landing2.png_5F00_580F2830.jpg" rel="lightbox[1383]" title="foodwfriends landing2.png"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="foodwfriends landing2.png" border="0" alt="Landing page with Friends’ wishlist section filled in with several friends’ restaurant list" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/0358.foodwfriends_2D00_landing2.png_5F00_thumb_5F00_1E1FE544.jpg" width="700" height="394" /></a></p>
<p align="left">For my wishlist, it’s about the restaurants that I’m most interested in going to, so we bring the restaurant forward:</p>
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/8524.foodwfriendswishlist_5F00_77AA873F.jpg" rel="lightbox[1383]" title="foodwfriendswishlist"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="foodwfriendswishlist" border="0" alt="Landing page with My wishlist section filled in with my restaurant list" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4722.foodwfriendswishlist_5F00_thumb_5F00_708B4AC7.jpg" width="700" height="394" /></a></p>
<p align="left">
<p align="left">And lastly, All restaurants is about navigating the giant collection of restaurants that is out there, so let’s present some of the most popular ones that users might be interested in, and then present categories for easy browsing. With all these parts in place, you can now see how the app’s hub landing page now <a>looks:</a></p>
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4353.landing_2D00_all_2D00_restaurants_5F00_2557BBDC.jpg" rel="lightbox[1383]" title="landing all restaurants"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="landing all restaurants" border="0" alt="Landing page with All restaurants section filled in with restaurant list" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5736.landing_2D00_all_2D00_restaurants_5F00_thumb_5F00_3D0EF342.jpg" width="700" height="394" /></a></p>
<p align="left">A crucial part to delivering a differentiated experience is expressing your product’s brand. This is a topic that deserves its own post, so stay tuned for a deeper dive into layout and visual design tips and techniques that will help your brand’s personality shine through while still maintaining a look and feel consistent with the platform it is created for. For now, let’s take a look at a simple example:</p>
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1263.landing_2D00_branded_5F00_01A2F364.jpg" rel="lightbox[1383]" title="landing branded"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="landing branded" border="0" alt="Food with friends landing experience with branded colors and background image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/3482.landing_2D00_branded_5F00_thumb_5F00_287109A4.jpg" width="700" height="236" /></a></p>
<h4 align="left">5. Laying out the rest of your app</h4>
<p align="left">Now that we have our landing page, it is really easy to lay out the rest of the app. </p>
<p align="left">We know that not all of the sections in the hub were exhaustive, so we need pages entirely dedicated to showing the full set of content for each section. The groupDetailPage in the Visual Studio Grid template is designed for this purpose. We tailor the layout of the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh780650(v=win.10).aspx" target="_blank">ListView</a> on that page to best suit the content type. </p>
<p align="left">My friend’s wishlist:</p>
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/8780.friends_2D00_wishlist_5F00_0855FCE7.jpg" rel="lightbox[1383]" title="friends wishlist"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="friends wishlist" border="0" alt="Friend’s wishlist page with full list of friends and their favorite restaurants" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/0361.friends_2D00_wishlist_5F00_thumb_5F00_0136C06F.jpg" width="700" height="394" /></a></p>
<p align="left">
<p align="left">My wishlist: </p>
<p align="left">
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4401.my_2D00_wishlist_5F00_4F97D820.jpg" rel="lightbox[1383]" title="my wishlist"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="my wishlist" border="0" alt="My wishlist page with my full list of favorite restaurants" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/0020.my_2D00_wishlist_5F00_thumb_5F00_7665EE60.jpg" width="700" height="394" /></a></p>
<p align="left">
<p align="left">All restaurants:</p>
<p align="left">
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4314.all_2D00_restaurants_5F00_41595F30.jpg" rel="lightbox[1383]" title="all restaurants"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="all restaurants" border="0" alt="Full list of all restaurants grouped by featured and cuisine type" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/0513.all_2D00_restaurants_5F00_thumb_5F00_68277570.jpg" width="700" height="394" /></a></p>
<p align="left">
<p align="left">We also know that there are two core entities reflected on the hub: restaurants and people. That means we need two variants of the item detail page (itemDetailPage in the Grid project template) where users can see info on an item when they tap/click it:</p>
<p align="left">
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4807.friend_2D00_profile_5F00_75F9BB6B.jpg" rel="lightbox[1383]" title="friend profile"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="friend profile" border="0" alt="A friend’s page with her profile information, her wish list, and her reviews" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4810.friend_2D00_profile_5F00_thumb_5F00_6EDA7EF3.jpg" width="700" height="394" /></a></p>
<p align="left">
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/8623.restaurant_2D00_profile_5F00_67BB427B.jpg" rel="lightbox[1383]" title="restaurant profile"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="restaurant profile" border="0" alt="A restaurant’s page with its hours, location, contact information, photos and reviews from other users " src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/3817.restaurant_2D00_profile_5F00_thumb_5F00_27852901.jpg" width="700" height="394" /></a></p>
<p align="left">
<p align="left">When designing each page, it is just as critical to continue to think about what each page is trying to be best at, and how it contributes to helping your app deliver on its “best at” statement.</p>
<h4 align="left">6. Navigating the UI</h4>
<p align="left">Now that we have the various pages, all we need to do is provide the user a way to move between them. Navigating the UI is quite unlikely the<i> </i>thing that any app is designed to be best at. We can apply existing <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh761500.aspx" target="_blank">navigation patterns</a> that users already know so they can quickly get to our app’s content and functionality. In this example, we use the Grid project template, which follows the hierarchical system pattern. For example, tapping a tile takes you to the item’s detail page. Tapping a section header in the hub takes you to that section. Tapping back takes you to where you just came from (not up). Much of this is built into the Grid project template. In a future post, we will go into more depth on the implementation and tips for building more advanced in-app navigation.</p>
<p align="left"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2425.app_2D00_hierarchy_5F00_611BB3B1.jpg" rel="lightbox[1383]" title="app hierarchy"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="app hierarchy" border="0" alt="A screen shot showing the hierarchy of the app&#39;s content" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/4162.app_2D00_hierarchy_5F00_thumb_5F00_0E9CD375.jpg" width="700" height="382" /></a></p>
<h4 align="left">Summary</h4>
<p align="left">Figuring out what you are best in its category at is the first and most important step to creating great Metro style app that will stand out from the crowd. As we have seen, identifying and focusing on the differentiation points influences many foundational decisions that you will make around your content structure, landing experience, page layout, and navigation. In future posts, we will continue to build on this and show how you can use the Windows 8 platform to make your app the best in its category. To review some of the resources that are mentioned in this post, take a look at the content on <a href="http://design.windows.com" target="_blank">http://design.windows.com</a>. </p>
<p align="left">
<p align="left">&#8211; Bonny Lau, Senior Program Manager, Windows</p>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10327644" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/windowsappdev/archive/2012/07/11/creating-metro-style-apps-that-stand-out-from-the-crowd.aspx">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/07/creating-metro-style-apps-that-stand-out-from-the-crowd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Readying Metro style apps for launch</title>
		<link>http://www.windows8tricks.net/2012/07/readying-metro-style-apps-for-launch/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=readying-metro-style-apps-for-launch</link>
		<comments>http://www.windows8tricks.net/2012/07/readying-metro-style-apps-for-launch/#comments</comments>
		<pubDate>Wed, 04 Jul 2012 11:19:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[launch]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Readying]]></category>
		<category><![CDATA[Style]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/07/readying-metro-style-apps-for-launch/</guid>
		<description><![CDATA[We know many folks are looking forward to RTM. Developers currently working on apps in the Store are especially excited. We have hundreds of apps in the Windows Store now and many more on the way. There&#8217;s a broad set of developers around the world that we have been working closely with since the first]]></description>
			<content:encoded><![CDATA[<blockquote>
<p><i>We know many folks are looking forward to RTM. Developers currently working on apps in the Store are especially excited. We have hundreds of apps in the Windows Store now and many more on the way. There&rsquo;s a broad set of developers around the world that we have been working closely with since the first Developer Preview. The WinRT platform is evolving rapidly during development based on feedback, and we have the dual task of keeping the Store up and running so we can supply apps to the millions of Preview users, while also getting ready for the next build. It means that if we change or add APIs or improve the tools, the apps will change and require an updated OS to test and verify the app. That&rsquo;s why we have been providing updated builds to developers who have or are committed to having apps in the Store through strong partnerships.&nbsp; </i></p>
<p><i>This post explains the work we&rsquo;ve been doing since September to keep developers updated with APIs and tools so that apps can stay up to date. We&rsquo;re doing this even after the Release Preview, just to make sure new apps are ready to go once we get to broad availability. <b>This post was authored by Dennis Flanagan, who leads our ecosystem outreach team</b>.&nbsp; &#8211;Steven</i></p>
<hr /></blockquote>
<p>As we approach the release of Windows 8, the catalog of Metro style apps continues to grow. To date, people have experienced apps that Microsoft has included with the downloaded build, and those that are offered in the Store in both the Consumer Preview and Release Preview timeframe. Many of those apps are great examples of immersive, touch-first Metro style experiences. However, like the Windows releases they run on, these apps are preview versions of the apps to come. The final versions of all Metro style apps will be available when Windows 8 becomes generally available.</p>
<p>Last year, we began working closely with the developer community by releasing early versions of the Windows 8 platform and tools. We decided to engage developers earlier in the engineering process so we could help them build skills in Metro style app development and give them the opportunity to influence the platform through feedback. Since September of 2011 we have released 8 developer preview versions. Some of these versions have been available to a limited developer audience. Some have been distributed broadly. All of these releases had similar goals:</p>
<ul>
<li>Deliver new capabilities and APIs</li>
<li>Update tools to simplify Metro style app development</li>
<li>Enhance performance and reliability</li>
<li>Respond to developer feedback</li>
</ul>
<p>We released our first Developer Preview version at the <a href="http://www.buildwindows.com/" target="_blank">//build conference</a> in Anaheim. This version introduced developers to the Windows 8 platform, tools and programming models. The WinRT platform included new APIs, and we used the conference to present literally hundreds of technical sessions and samples to give developers a basic understanding of the platform. . Many developers got right to work building Metro style apps, produced some impressive early results, and provided us with useful feedback and recommendations about how to improve the platform and tools.</p>
<p>We made it clear that the first Developer Preview (&#8220;DP1&#8243;) was an early version of the code, and we had a lot of work to complete Windows 8. DP4 and DP5, released in January and February of this year, were targeted at developers who wanted to be the first to publish applications in the Windows Store. By the time we released the Consumer Preview in February of 2012, we had added almost a thousand new WinRT APIs, and had modified hundreds of other APIs based on developer feedback.</p>
<p>For a detailed description of the changes that happened between //build and Consumer Preview, check out these posts on our <a href="http://blogs.msdn.com/b/windowsappdev/" target="_blank">App Developer blog</a>:</p>
<ul>
<li><a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/03/01/what-s-changed-since-build-part-1.aspx">What&rsquo;s changed for app developers since //build/ (part 1)</a></li>
<li><a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/03/06/what-s-changed-for-app-developers-since-build-part-2.aspx">What&rsquo;s changed for app developers since //build/ (part 2)</a></li>
</ul>
<p>In April and May of this year, we released DP6 and DP7, which allowed developers to prepare their apps for the Release Preview. However, in close collaboration with the development community, we&#8217;ve continued to evolve the platform in response to their feedback. By the time we delivered the Release Preview, we had added 334 more APIs and continued to change existing APIs to address feedback.</p>
<p>One example of a change we made in Release Preview (RP) based on developer feedback is the HTML <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465496.aspx" target="_blank">ListView control</a> (in WinJS). This was an area where lots of developers had difficulties, so we overhauled it to make it easier to work with and to allow a much more extensive degree of performance tuning.</p>
<p>We also made lots of improvements to developer resources, such as templates in <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516" target="_blank">Visual Studio</a>. We even added a new template that makes it easier for developers to start a new project and get a great app up and running in very little time.</p>
<p><a href="http://msdn.microsoft.com/en-us/windows/apps/br229516">Design tools</a> were another focus area for improvements. Metro is a design-forward experience, which means the app&rsquo;s user interface is one of the key ways developers get their apps noticed and differentiate them. We did a lot of work to make it as easy as possible for developers to integrate all the new Metro style design concepts into their apps.</p>
<p>For a complete overview of the changes between CP and RP, see <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/05/31/what-s-changed-for-app-developers-since-the-consumer-preview.aspx" target="_blank">What&#8217;s changed for app developers since the Consumer Preview</a>.</p>
<p>Our next major milestone is the release to manufacturing (RTM). When the code reaches this milestone, the platform is complete for general availability (GA), and so we won&rsquo;t have interim updates for developers.</p>
<p>When Developers get the RTM version, they will continue enhancing the features, capabilities and performance of their apps. Some of the apps you&rsquo;ve already seen will look and perform differently when you download the final released version. There are also many more apps in development that haven&rsquo;t been released to the Store yet. Many of those developers are waiting for RTM to put the finishing touches on their apps.</p>
<p>The release of Windows 8 will be a great milestone for app developers, but it is really just the beginning. A great benefit of the built-in Windows Store and update mechanism is that they provide developers with the opportunity to gain wide distribution for new apps and continuously improve apps that they&#8217;ve already released. As the app developer community evolves, we expect app developers to take advantage of this and provide regular updates to apps.</p>
<p>&#8211;Dennis</p>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10326543" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/b8/archive/2012/07/03/readying-metro-style-apps-for-launch.aspx">Building Windows 8</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/07/readying-metro-style-apps-for-launch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Windows 8 Dev Center: Everything you need to design, build, and sell a Metro style app</title>
		<link>http://www.windows8tricks.net/2012/06/the-windows-8-dev-center-everything-you-need-to-design-build-and-sell-a-metro-style-app/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-windows-8-dev-center-everything-you-need-to-design-build-and-sell-a-metro-style-app</link>
		<comments>http://www.windows8tricks.net/2012/06/the-windows-8-dev-center-everything-you-need-to-design-build-and-sell-a-metro-style-app/#comments</comments>
		<pubDate>Sat, 09 Jun 2012 13:27:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Center]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[need]]></category>
		<category><![CDATA[sell]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/06/the-windows-8-dev-center-everything-you-need-to-design-build-and-sell-a-metro-style-app/</guid>
		<description><![CDATA[For Windows 8, we completely reimagined not just the platform, but also how we share app development info with you. Launched 9 months ago, the Windows Dev Center is the one place where you can find all the info and resources you need to get going. Whether you’re new to development, seeking inspiration for the]]></description>
			<content:encoded><![CDATA[<p>For Windows 8, we completely reimagined not just the platform, but also how we share app development info with you. Launched 9 months ago, the Windows <a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Dev Center</a> is the one place where you can find all the info and resources you need to get going. Whether you’re new to development, seeking inspiration for the next great app, or you’re simply stuck and need help, you can find it here.</p>
<p>We talked to many developers, and heard a lot about how difficult it could be to find the right info in the MSDN Library. The goal we set for Windows 8 developer content was to try to provide exactly the right content when you needed it, and not have too much info get in your way. To that end we focused on how to do things, instead of on why we built a given feature the way we did. You told us that when you start learning about a new scenario or feature, you want to try it out quickly and learn the details later. We also heard loud and clear that you want to get going quickly and not read a lot of docs. With the new Windows 8 Dev Center, you don’t have to track down docs, tools, samples, and other assets in various locations; it’s all in one place. We also improved search, so you can find what you need easier. </p>
<p>And, you don’t have to be a dev to find a lot of interesting info in the <a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Dev Center</a>. If you’re a creative professional or a design expert and don’t want to see anything other than design, we have “a center within a center” for you that contains just the design content. Just go directly to <a href="http://msdn.microsoft.com/library/windows/apps/hh779072" target="_blank">design.windows.com</a>. We could have called it the Windows Design and Dev Center, but that’s just too long!</p>
<h3>The structure and navigation</h3>
<p>The Windows <a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Dev Center</a> is broken into 4 sections: Metro style apps, Internet Explorer, Desktop, and Hardware. You can access them all from dev.windows.com.</p>
<p>All these sections are structured similarly, with a nod toward the important Metro style design principle of content over chrome. In this post, we focus on the Metro style apps section only, because that’s what most readers of this blog are interested in. Here’s what it looks like:</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5381.Dev_5F00_center_5F00_7527F937.jpg" rel="lightbox[1340]" title="Dev_center"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Dev_center" border="0" alt="The Metro style apps page of the Windows Dev Center" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2642.Dev_5F00_center_5F00_thumb_5F00_54A0B985.jpg" width="500" height="444" /></a></p>
<p>You can easily navigate the center by using the links at the top of the page. </p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Home</a> orients you to the site, and gives you a general idea of what content we have for you.</li>
<li>When the Store becomes available (soon!), you’ll use the <a href="https://login.live.com/login.srf?wa=wsignin1.0&amp;rpsnv=11&amp;ct=1336435004&amp;rver=6.2.6289.0&amp;wp=MBI_SSL&amp;wreply=https%3a%2f%2fappdev.microsoft.com%2fStorePortals&amp;lc=1033&amp;id=278678&amp;mkt=en-us" target="_blank">Dashboard</a> to sign up and become a Windows Store developer. After you sign up, you’ll also use this tab to upload your apps, access telemetry, and see how your apps are doing in different markets around the world. </li>
<li><a href="http://msdn.microsoft.com/en-us/library/windows/apps/" target="_blank">Docs</a> is your gateway to platform documentation, including general info, Quickstarts (hands-on content that gets you familiar with basics of a feature quickly), tutorials, and reference. Using the navigation pane on the left, you can jump to the appropriate topic immediately. If you want more info before you jump, the main pane contains more detail. We improved navigation both within an article, and from one topic to another. We added the “In this article” sidebar where you can see all the sections of the article and can jump directly to the section that interests you. In some articles we also list relevant APIs if appropriate.</li>
<li>Use <a href="http://code.msdn.microsoft.com/windowsapps/" target="_blank">Samples</a> to find Metro style samples to play with. There are already over 550 samples (and growing!) available in multiple programming languages, and we invite you to upload your own samples to share with the community.</li>
<li><a href="http://msdn.microsoft.com/en-us/windows/apps/br229516.aspx" target="_blank">Downloads</a> is where you find the tools like Visual Studio 2012 Express RC for Windows 8 and the SDK. Visual Studio 2012 Express now also includes Blend for Visual Studio to help you quickly create visually attractive, fun apps. </li>
<li>You can use <a href="http://msdn.microsoft.com/en-us/windows/apps/hh690938" target="_blank">Support</a> to get technical help with your account, or request 1:1 help with your dashboard. We provide this dashboard help for free to anyone with a Microsoft developer account. For really complex problems that go beyond the free help, you can also buy help with your apps from our experts.</li>
<li>Finally, <a href="http://msdn.microsoft.com/en-us/windows/apps/br229515" target="_blank">Community resources</a> can link you with other developers. You can ask questions, help others with their technical issues, or read the latest news about Windows 8 Metro style app development.</li>
</ul>
<h3>Get started</h3>
<p>If you want a quick orientation, the best place to go is <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br211386.aspx" target="_blank">Getting started with Metro style apps</a>. Here you can learn what makes a Metro style app great, and follow introductory tutorials that give you a taste of Windows 8 development. The tutorials feature many code examples in all 4 supported programming models: HTML5 with JavaScript, XAML with C# or VB, XAML with native C++, plus DirectX with native C++. Reusing your existing skills and code assets is a core premise of Windows 8 development, and we go out of our way to fulfill that promise on the Dev Center.</p>
<h3>Get the resources</h3>
<p>Your fingers might be itching to start developing your app, but first you need the right tools. Go to the <a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Dev Center</a> to <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516" target="_blank">download the tools</a>. Make sure you download Microsoft Visual Studio 11 Express for Windows 8, which includes Windows 8 SDK, Blend for Visual Studio, and project templates.</p>
<p>If you need help designing appealing Metro style apps, download our <a href="http://go.microsoft.com/fwlink/?LinkId=241449" target="_blank">design assets</a>. These are .psd files for controls, layouts, components, and project templates to help you lay out your UI.</p>
<p>You will find lots of other resources too, including the Multilingual App Toolkit for Visual Studio 11 Beta, which can help you create apps for the world markets. The best part is, all these downloads are free.</p>
<h3>Samples</h3>
<p>We are always asked for samples, and with a good reason. A sample can show you how someone else already solved the problem you are trying to solve, or you can start with a sample as a foundation for your own app. We now have over 550 official Microsoft samples, plus additional community samples, and the number is growing. Each tells you how to compile and run it, plus we give you any special instructions you need. Check them out in the <a href="http://code.msdn.microsoft.com/windowsapps/" target="_blank">samples gallery</a> or <a href="http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples" target="_blank">download the sample app pack</a> if you want all of them at once. Over a quarter million devs already have!</p>
<p>You can search for the samples you want by programming language (JavaScript, C++, C#, Visual Basic), by source (Microsoft or community), by technology (Metro style app, JavaScript, Windows Runtime, XAML, and so on), or by topic (User interface, Audio and video, Devices and sensors, and so on).</p>
<p>If you want to showcase your great ideas, post your own samples! You can also rate or comment on samples, give feedback, or ask questions.</p>
<p>Can’t find a sample you need? You can request one, or <a href="http://code.msdn.microsoft.com/windowsapps/site/requests?f%5B0%5D.Type=RequestStatus&amp;f%5B0%5D.Value=Open&amp;f%5B0%5D.Text=Open" target="_blank">vote</a> for samples that others requested so that we create the ones that people really want. Then check out the “Completed” tab to see the samples we created as a result of community demand.</p>
<h3>From app conception to the Store</h3>
<p>Now that you have all the tools, and have seen some samples, it’s time to start thinking about your apps. But what makes a Metro style app great? Info on the <a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Dev Center</a> can help you decide what kind of app to build, what kind of info it should include to appeal to the broadest possible audience, and how to present your app’s content in a compelling way. This info is laid out in the order we think you’ll need it.</p>
<h4>Start with an idea</h4>
<p>Not sure how to turn your idea into an app? Start with <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465427" target="_blank">Planning Metro style apps</a> and follow our step-by-step planning process. There’s a lot to think about, including not just what the app will do, but how to present it to the best advantage, how to make it appeal to a global audience, and how you can make money from your app. </p>
<h4>Designing UX for apps</h4>
<p>A hallmark of great apps is an outstanding user experience (UX). But making your app compelling and interesting can be intimidating. In <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh779072" target="_blank">Designing UX for apps</a>, we provide design patterns for navigation, commanding, and touch interaction. We provide specific help for popular Windows Store categories, including games, entertainment, news, and productivity. You can also <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh700403" target="_blank">download design assets for Metro style apps</a> so you don’t have to start from scratch. We also help you assess usability of your app, so you can be sure your customers find it intuitive and easy to use. </p>
<p>If you already have an app on a different platform and are wondering how to redesign it to follow Metro style app design, we provide <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh770549.aspx" target="_blank">case studies</a> that show you how to convert a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh868264.aspx" target="_blank">Website to a Metro style app</a>, and how to convert an <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh868262.aspx" target="_blank">iPad app to a Metro style</a> one. And to improve the visual appeal of your app, take a look at our <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh975420.aspx" target="_blank">animations design</a> videos.</p>
<h4>Developing apps</h4>
<p>Now that you have your app concept firmly in mind, it’s time to start developing. You already know what language you will use to <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br229565" target="_blank">develop Metro style apps</a>. We provide a language selector control at the top of many pages, so you can see JavaScript and HTML content only, or Visual Basic/C#/C++ and XAML content only. We’re continually adding to the content for each language, so check back soon if the content you’re looking for doesn’t appear yet.</p>
<p>When you want info about a specific feature, you can start with a Quickstart that introduces the feature by walking you through common use cases. These articles include a lot of code to help you get started quickly, thus the name <i>Quickstart.</i> We also provide roadmaps for each of the major development models to help you decide where might want to go next. In many cases we also include guidelines and checklists for using a feature, to help ensure your apps pass certification and you can submit it to the Windows Store. Finally, we have in-depth documentation for key features if you need more detail. </p>
<p>Many articles contain code snippets. We use them as illustrations to jumpstart your own development. But you can also easily run them in Visual Studio. Simply click <b>Copy</b> in the upper right corner of the snippet, and the code will be pasted onto your Clipboard. You can then paste it into your own code. (You can get the sample code this way too.) Always be careful to include appropriate error handling and data validation when copying/pasting code from an article in the Dev Center.</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/5700.code_5F00_snippet_5F00_test_5F00_31AB93DA.jpg" rel="lightbox[1340]" title="code_snippet_test"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="code_snippet_test" border="0" alt="code_snippet_test" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/2656.code_5F00_snippet_5F00_test_5F00_thumb_5F00_2A8C5762.jpg" width="600" height="232" /></a></p>
<p>While building your app, you might also need access to complete reference material for the platform. For detailed API info, see <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br211369" target="_blank">API reference for Metro style apps</a>. </p>
<p>Before you can submit your app to Windows Store, you must package it. The easiest way to do so is to use Visual Studio. See <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh454036" target="_blank">Packaging your app using Visual Studio</a> for more detail.</p>
<p>To make sure your app runs great and is ready for the Store, you must debug and test it. We give you all the info about <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh441481" target="_blank">Debugging and testing Windows Metro style apps</a> to get this done quickly.</p>
<h4>Selling and managing your apps</h4>
<p>After you develop your app, it’s time to share it with the world. We provide you with a great platform for sharing apps – the Windows Store. In the <a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Dev Center</a>, we guide you through the process of submitting your app for certification, and listing it in the Windows Store. If you aren’t sure how to advertise your app in the catalog, we provide you with tips on how to write descriptions that will tempt users to try your app. When you’re ready to submit your app to the Store, <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br230836" target="_blank">Selling apps</a> takes you through the process. It also explains the different licensing models available and provides suggestions for when to use each. Finally, you’ll want to know how to price your app so that it’s competitive, and how to add in-app offers to sell additional features. <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh694084.aspx" target="_blank">Making money with your app</a> explains all of this in detail. </p>
<p>You can sell your apps in multiple languages in markets around the world. <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh694064.aspx" target="_blank">Windows Store markets</a> explains the details.</p>
<h3>If you want to get deeper technical info</h3>
<p>The content we looked at so far will help you get started developing a great app. But sometimes you need more detail. In <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br211361" target="_blank">Concepts and architecture</a>, we explain technical details behind the Metro style app development platform and share advanced techniques for building apps. For a complete survey of how to build apps from end-to-end, you can find guidance in the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br211375" target="_blank">End-to-end apps</a> and games section. </p>
<p>Another good source of deep technical info is <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465413.aspx" target="_blank">White papers for Metro style apps</a>.</p>
<h3>What to do when you’re stuck</h3>
<p>If you get stuck and can’t find a solution to your problem, there are other devs in the community who may be able to help. <a href="http://msdn.microsoft.com/en-us/windows/apps/br229515.aspx" target="_blank">Community resources</a> includes forums and blogs. The forums are a great place to ask questions, bounce ideas off other developers, or provide support for others who need help. Many of the forum participants are members of our tech support team, so you can get accurate answers to your questions quickly.</p>
<p>The blogs, such as this one, are a great place to learn the latest news about Windows 8 development and to give us feedback. In addition to the <a href="http://blogs.msdn.com/b/windowsappdev/" target="_blank">Windows 8 app developer blog</a> (this blog), we have the <a href="http://blogs.msdn.com/b/windowsstore/" target="_blank">Windows Store developer blog</a> where members of the Windows Web Services team talk about the business of the Store, and the <a href="http://blogs.msdn.com/b/b8/" target="_blank">Building Windows 8 blog</a>, where you can find the inside scoop from Windows President Steven Sinofsky and the Windows engineering team.</p>
<p>You can also sign up here for a Windows Dev Camp, and attend at any of the locations around the world.</p>
<h3>We speak your language</h3>
<p>We realize that many people around the world are interested in Windows, and many of them don’t read English. We now support the content and the Store in 12 languages, and we plan to add the most important content in additional 12. We support the tools and the forums in 10 languages, and the blogs in 8.</p>
<h3>Closing</h3>
<p>As you can see, for Windows 8 we completely revamped the way we share info with you. We focused more on how you actually use the content, and reorganized the <a href="http://msdn.microsoft.com/en-us/windows/apps/default" target="_blank">Dev Center</a> to reflect this.</p>
<p>The Dev Center isn’t static, it’s a constantly evolving site. Our dedicated team of programmer writers and editors, have worked hard to craft reference docs and feature overviews you expect, but there’s far more to the site. The team is now focused on creating scenario oriented guidance that helps you better understand how various features work together to complete more complex tasks. We’re still working on this guidance, and we update the Dev Center frequently, so stay tuned for more.</p>
<p>We hope you find our content easier to use. We look forward to your feedback.</p>
<p>&#8211; Marzena Makuta, Senior Editor, Windows</p>
<p>Thanks to Keith Boyd for his contribution.</p>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10317412" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/windowsappdev/archive/2012/06/08/the-windows-8-dev-center-everything-you-need-to-design-build-and-sell-a-metro-style-app.aspx">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/06/the-windows-8-dev-center-everything-you-need-to-design-build-and-sell-a-metro-style-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delivering reliable and trustworthy Metro style apps</title>
		<link>http://www.windows8tricks.net/2012/05/delivering-reliable-and-trustworthy-metro-style-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=delivering-reliable-and-trustworthy-metro-style-apps</link>
		<comments>http://www.windows8tricks.net/2012/05/delivering-reliable-and-trustworthy-metro-style-apps/#comments</comments>
		<pubDate>Sun, 20 May 2012 05:25:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[Delivering]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[reliable]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[trustworthy]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/05/delivering-reliable-and-trustworthy-metro-style-apps/</guid>
		<description><![CDATA[As we developed the app model for Windows 8 and the new Metro style apps, a key architectural requirement has been to deliver apps to customers that can be used with confidence&#8211;confidence that apps will be well-behaved with respect to resources, that apps will not interfere with other apps, that apps use system resources with]]></description>
			<content:encoded><![CDATA[<p style="padding-left: 60px"><em>As we developed the app model for Windows 8 and the new Metro style apps, a key architectural requirement has been to deliver apps to customers that can be used with confidence&#8211;confidence that apps will be well-behaved with respect to resources, that apps will not interfere with other apps, that apps use system resources with your permission, that apps can be installed and uninstalled with ease, and so on.&#160; These attributes require a robust platform and strong set of tools for developers.&#160; This is an effort that requires a fresh start and cannot be retrofitted on an existing system.&#160; Windows 8 is a fresh start in this regard.&#160; This post details some of the work we have done at the platform level to deliver reliable and trustworthy Metro style apps.&#160; <strong>This post is authored by John Hazen, a program manager on our Developer Experience team. </strong>&#8211;Steven</em></p>
<p>One of our core principles in the development of the Windows 8 Metro style app platform was to ensure that users would have confidence in their apps. This is a mission we’re in together; in this post, I explain our vision for app confidence and reliability and help you build confidence by design into your apps.</p>
<p>Let me start by explaining what we mean by <i>confidence</i>. Picture a customer browsing the Windows Store looking at a Metro style app; we want them to be thinking only about the app and whether or not it is right for them. We want them to assume—in fact be confident—that the app will behave the way they expect and thus will perform well on their system, will use only the data and information they authorize, and will harmoniously co-exist with their other applications.</p>
<p>Our goal with the platform is to help us all build great apps that embody this vision of confidence so that we get confidence by default. To that end we made investments throughout the system. Here’s how we picture it:</p>
<p><img title="App Confidence" style="background-image: none; float: none; margin-left: auto; display: block; margin-right: auto" border="0" alt="Diagram of factors contributing to App Confidence as enumerated in the caption" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-29-43-metablogapi/6840.AppConfidence01_5F00_226595B6.png" width="700" height="299" /></p>
<p align="center"><em>App Confidence: Windows 8 SDK for Metro style apps, Windows App Certification Kit, App Signatures,      <br />App Container, Ratings and Reviews, Store Onboarding, Frictionless Install, Telemetry Feedback</em></p>
<p>This post covers these areas and towards the end goes into depth on our app capabilities. First, a quick overview:</p>
<ul>
<li><b>Windows Store</b> – For customers, it starts with the Store, their one-stop-shop for Metro style apps. To get into the Store your app is reviewed for both technical and policy compliance, including security checks. After it’s published to the Store, your app will be rated and reviewed by the community. Together, the onboarding process and community reviews help create an environment in which customers can try apps with confidence. </li>
<li><strong>App install</strong> – Windows 8 handles all the details of deploying apps on your behalf so your customers don’t have to worry that installing, updating, or removing one app will adversely affect other apps. </li>
<li><b>SDK</b> – The Windows 8 SDK for Metro style apps provides a well-defined set of APIs that help you build reliable apps that conform to the Store onboarding requirements and provide the best experiences for your customers. </li>
<li><b>App container and capabilities</b> – Windows 8 provides a greater degree of separation between apps than was possible with traditional desktop apps, so you can build apps that interact with each other in more predictable ways, giving customers a more consistent experience. </li>
</ul>
<p>We of course recognize that any onboarding process can be gamed, API sets can be abused, SDK limits cleverly avoided, and that app containers are not impenetrable. But we are confident that the investments we made in this new ecosystem will help you build apps that delight customers. This multi-dimensional approach is the most effective way to build customer confidence and we will improve each dimension over time as we learn from experience. Now let’s talk about confidence.</p>
<h3><b>The Windows Store</b></h3>
<p>Several folks on the team have shared quite a bit on the <a href="http://blogs.msdn.com/b/windowsstore/archive/2012/01/20/designing-the-windows-store-user-experience.aspx" target="_blank">Windows Store Blog</a><span style="text-decoration: underline"></span> about the overall design and plan for the Store. If you have not had a chance yet, read about the Store, because it plays a central role in helping you connect with your customers. Let’s look at a few ways in which the Store helps build confidence in the app ecosystem.</p>
<p>First, the Store onboarding process establishes a consistent baseline for app quality and reliability. The technical conformance tests, contained in the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh694081.aspx" target="_blank">Windows App Certification Kit</a>, help you know that you meet the expected standards before you submit your app. As you and other devs continue to deliver apps that meet these standards, customers will be excited to discover and try out new apps, creating a stronger app ecosystem for all of us.</p>
<p>The Store also makes it easy for customers to provide ratings and reviews that will help the best apps stand out, enticing even more customers to try out the top rated apps with confidence. In the sample app listing page below, note the highlights not just for ratings and reviews, but also two other important elements of the app listing page. Prior to installing a new app, customers can see what permissions the app has once it is installed (more detail on this later in the blog). After installing an app if the customer has concerns about app content or behavior, they can easily report their concern and we can follow up with you to address any problems identified. Helping customers decide which apps best meet their needs and allowing customers to provide input and feedback is an important way to improve overall confidence in the Windows 8 app ecosystem.</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-29-43-metablogapi/1321.xbox_2D00_live2_5F00_5525765D.jpg" target="_blank" rel="lightbox[1297]" title="Sample game app"><img title="Sample game app" style="background-image: none; float: none; margin-left: auto; display: block; margin-right: auto" border="0" alt="Sample game app listing page on Windows Store, calling out ratings, reviews, permissions and reporting link" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-29-43-metablogapi/6102.xbox_2D00_live2_5F00_thumb_5F00_42DCAF9B.jpg" width="700" height="478" /></a></p>
<p align="center"><em>App listing page from the Windows Store</em></p>
<p>Finally, the Store collects telemetry data that can help you investigate problems your customers see, including the number and types of crashes they suffered. We review this automated telemetry for indications that an app’s behavior is unreliable or inconsistent with the expectations of our customers. Our goal is to make effective use not only of the individual feedback that customers provide on apps through ratings and reviews, but also provide insight into how your app is actually behaving on customers’ machines and give you the opportunity to improve your app based on this data.</p>
<p>In all these ways, the Windows Store is your partner in connecting you with people who want your apps, and helping them have a great experience with your apps.</p>
<h3><b>Apps are just a click away</b></h3>
<p>When you have your customer’s attention on the app listing page, you don’t want anything to get in the way of your customer getting your app. On Windows 8, getting an app is a matter of clicking a single button. Customers no longer have to wade through a series of questions or click button after button. After logging into the Store, when they find something they like, they just click the button, confirm the purchase, and go!</p>
<p>The great news for you is that you don’t have to write a single line of installation code to make this magic happen; it is all provided for you as part of Windows 8. Not only is installation handled, but Windows uses digital signatures to ensure the integrity of your app all the way from the Store to installation and even when the app is loaded and running on your customer’s computer. If Windows detects that the app no longer matches its digital signature, it guides the customer to download a corrected version from the Store.</p>
<p>Because Windows installs each app in a discrete location with separate and private locations for each app’s data and settings, customers don’t have to worry that installing, or removing, one app will interfere with the behavior of other apps or their computer. Customers will be more willing to try more apps than ever before, knowing that installing and removing apps won’t degrade their experience over time (in fact, with Windows 8 contracts, each app you install makes the experience better). You benefit by knowing that there is little another app might do that will damage your customer’s experience of your app.</p>
<p>Having a single, verifiable, and consistent mechanism to install apps not only simplifies your work, it provides an easy and positive experience for your customers, giving them confidence to get even more of your great apps. You can learn more about app deployment in <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516" target="_blank">App packages and deployment</a>.</p>
<h3><b>Windows 8 SDK for Metro style apps</b></h3>
<p>The better experience customers have with your apps, the more readily they will try new apps and updates as you release them. The <a href="http://msdn.microsoft.com/library/windows/apps/br211369" target="_blank">Windows 8 SDK for Metro style apps</a> is a great foundation for you to build apps that customers won’t hesitate to install.</p>
<p>We put a lot of thought into the API set we offer for Metro style apps, not only to simplify the Windows programming environment, but also to provide a well-tested platform on which you could confidently build your apps, knowing they will work well with the Windows 8 Metro style app model.</p>
<p>Resist the temptation to find ways to invoke APIs that are not included in the SDK. This ultimately undermines the expectations that customers have for your app. APIs that are outside the SDK are not guaranteed to work with Metro style apps either in this release or in future releases, so you may find that your app doesn’t function properly for all customers. These APIs may also not function properly in the async environment that is foundational to Metro style app design. Finally these APIs may undermine customer confidence by accessing resources or data that Metro style apps would not normally interact with. For all these reasons, we have provided checks in the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh694081.aspx" target="_blank">Windows App Certification Kit</a> to help you catch places where you might have inadvertently called interfaces not exposed by the SDK.</p>
<p>While it is possible to hide or obfuscate calls to APIs that are not included in the SDK, this is still a violation of customer expectations and Store policy. In the end, we have created this platform to help developers like you to build amazing apps that work well with the system and with other apps and devices to delight customers. Working with the Metro style SDK is fundamental to your realizing that goal.</p>
<h3><b>Working well together and apart</b></h3>
<p>A clean installation process is important to your customers, and the SDK helps you build apps that integrate well with the system. Beyond this, customers expect a high degree of reliability from your app and our platform. We help you achieve your reliability goals by providing a greater degree of separation between Metro style apps than is possible for traditional Windows desktop applications. On Windows 8, each Metro style app runs in the context of a unique app container that helps insulate it and its data from other Metro style apps.</p>
<p>App containers provide a few characteristics that are shared by all Metro style apps. They:</p>
<ul>
<li>Provide a dedicated environment for your app, including your own store for data and settings. You have little worry that some other Metro style app will change your app’s data, settings, or behavior. </li>
<li>Help ensure that your app doesn’t accidently interfere with the reliability of the Windows platform itself, or accidently use your customers’ data or devices in ways they don’t expect. </li>
<li>Provide a well-defined way to extend the capabilities of your app through declarations you make in the manifest and disclose to your customer in the app listing page. </li>
</ul>
<p>Having this degree of separation makes it far easier to write apps that are reliable and respectful of the user. At the same time, we all want apps that interact well with one another. Windows 8 provides several mechanisms for Metro style apps to work with each other and with the platform to provide these satisfying experiences, including:</p>
<ul>
<li><span style="text-decoration: underline"><a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464920.aspx#traits_4_right_contracts" target="_blank">App contracts</a></span>, which are the glue that binds Metro style apps together and to the system UI. </li>
<li>The <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465182.aspx" target="_blank">FilePicker</a><span style="text-decoration: underline"></span>, which allows your app to interact with data the user selects. </li>
<li><span style="text-decoration: underline"><a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx" target="_blank">App capability declarations</a></span>, which allow your app to programmatically interact with devices and data, when appropriate for your functionality. </li>
</ul>
<p>These are all well-defined ways for your app to engage more deeply with other apps and the system. The app container exists to help you deliver on your customer’s expectations of reliability and respectful use of their system and data. The constraints of the app container are designed to help realize customers’ expectations for consistent and intuitive app behaviors, and using techniques that allow your app to run code outside of an app container is a violation of user trust and Store policy.</p>
<p>In our discussions with developers during this preview period, we have seen apps that have misunderstood or accidently misused some of these mechanisms, so let’s go into more detail about the app capabilities in particular.</p>
<h3><b>App capability declarations</b></h3>
<p>The app container can be extended in a variety of ways using capability declarations, each of which is designed to enable certain scenarios. Therefore, we recommend that you use them only under certain conditions. These capabilities fall into 4 primary buckets:</p>
<ul>
<li><b>Data libraries:</b> By default, apps have no access to the customer’s data libraries, like the Music library, or the Documents library. We recommend that you use the FilePicker to interact with these libraries, but in some rare cases it is necessary for your app to be able to directly read and manage data in these locations. </li>
<li><b>Device access</b>: By default, apps can’t use devices that most users consider sensitive for their privacy, including the webcam, microphone, and location. When apps need these devices, they must both declare their intent, and get consent from the user. </li>
<li><b>Network access:</b> By default, apps have no access to the customer’s networks. Because most apps interact with the Internet, we enabled this particular capability in all the Visual Studio templates for Metro style apps. If your app needs more than just simple Internet access, you can read about your options below. </li>
<li><b>User identity</b>: These capabilities provide direct access to a particular customer’s corporate logon info, or to certificates associated with their identity. These capabilities, although rarely needed, are necessary for certain enterprise apps, and you might need to use them in scenarios like banking transactions in which a smartcard might be required for authorization. </li>
</ul>
<p>Declaring a capability in any of these categories is as simple as checking it off in the Visual Studio manifest designer. But add capabilities only if they are critical to realizing a scenario for an app. During the Consumer Preview, we saw several apps submitted to the Store that declared every capability or a capability that was not essential for the app. So, while the list of possible capabilities is relatively short, it is worth reviewing in more detail each of these capabilities and how to use them.</p>
<p><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-29-43-metablogapi/1881.VS_2D00_smaller_5F00_1B260DA4.jpg" target="_blank" rel="lightbox[1297]" title="Visual Studio manifest designer"><img title="Visual Studio manifest designer" style="background-image: none; float: none; margin-left: auto; display: block; margin-right: auto" border="0" alt="Screenshot of Visual Studio manifest designer, showing the capabilities tab where you can select system features or devices your app can use" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-29-43-metablogapi/1307.VS_2D00_smaller_5F00_thumb_5F00_5CFCCD25.jpg" width="700" height="428" /></a></p>
<p align="center"><em>Visual Studio&#8217;s manifest designer</em></p>
<h3><b>Data libraries </b></h3>
<p>These capabilities grant your app access to user data that wasn’t necessarily created in your app. Users expect apps to be respectful of access to their private data. One way to honor the trust users place in your app is by declaring only the minimum access necessary for your app. In most cases you can avoid using these capabilities entirely by using the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465182.aspx" target="_blank">FilePicker</a><span style="text-decoration: underline"></span>, through which the user can browse files anywhere on their hard drive or network. For example, use the FilePicker to provide a File open experience, or to add Save as to your app in order to give your user the opportunity to save content from your app into their library locations or to removable storage.</p>
<div align="center">
<table class="b8table" cellspacing="0" cellpadding="3" align="center" border="0">
<tbody>
<tr>
<td valign="top" width="126">
<p><b>Manifest declaration</b></p>
</td>
<td valign="top" width="487">
<p><b>What it provides</b></p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>musicLibrary</b></p>
</td>
<td valign="top" width="487">
<p align="left">Provides the capability to add, change, or delete files in the Music Library for the local PC and HomeGroup PCs.</p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>videoLibrary</b></p>
</td>
<td valign="top" width="487">
<p align="left">Provides the capability to add, change, or delete files in the Videos Library for the local PC and HomeGroup PCs.</p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>pictureLibrary</b></p>
</td>
<td valign="top" width="487">
<p align="left">Provides the capability to add, change, or delete files in the Pictures Library for the local PC and HomeGroup PCs.</p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>documentsLibrary</b></p>
</td>
<td valign="top" width="487">
<p align="left">Provides the capability to add, change, or delete files in the Documents Library for the local PC. The app can only access file types in the Documents Library that are defined using the File Type Associations declaration. The app can&#8217;t access Document Libraries on HomeGroup PCs.</p>
</td>
</tr>
<tr>
<td valign="top" width="126">
<p align="left"><b>removableStorage</b></p>
</td>
<td valign="top" width="487">
<p align="left">Provides the capability to add, change, or delete files on removable storage devices. The app can only access file types on removable storage that are defined in the manifest using the File Type Associations declaration. The app can&#8217;t access removable storage on HomeGroup PCs.</p>
</td>
</tr>
</tbody>
</table></div>
<p>During the Consumer Preview, we saw app submissions that declared these capabilities when they really didn’t need to. For example, apps declared documentsLibrary for a variety of reasons including:</p>
<ul>
<li>Storing app-specific settings in the documents library. The private store is designed to provide this function. You can learn more about app settings and storage <a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/05/10/trending-forum-topics-answering-your-questions.aspx" target="_blank">here</a>. </li>
<li>Store a user-generated file. This is more properly accomplished using the FilePicker to allow the user to save the file to any location, including the documents library. </li>
<li>Sharing a document with another app. The Sharing contract is designed for this purpose. </li>
</ul>
<p>If your app is designed to be the primary handler on the system for a given file type, for example a Fax Viewer that needs to handle all .TIFF files in the user’s documents library, then declare this capability.</p>
<h3>Device access</h3>
<p>Many devices, like orientation sensors and accelerometers, are available to any app. But most customers consider certain devices more sensitive than others, given that they are strongly associated with user privacy. There are a lot of great apps you can build on these devices. For example, if you have a casual game that allows shared gameplay, using proximity is a great way to establish a connection between devices.</p>
<p>Because these devices are closely coupled to user privacy, Windows 8 ensures that if you declare the capability, the customer will be prompted to approve this access the first time your app tries to access the particular device. For example, if your app offers mapping, you likely want to access the customer’s geolocation data. The first time your app tries to get this info, the customer sees a prompt to approve your app’s access. This approval sticks until the customer decides to explicitly remove the access through Settings at a later time. Because the customer can decline your app’s access to these devices, even if you have added the capability to the manifest, design your app to handle the lack of access gracefully. For example, if the customer has denied your app access to the built in GPS, you could simply prompt the user to select their location from a map.</p>
<div align="center">
<table class="b8table" cellspacing="0" cellpadding="3" align="center" border="0">
<tbody>
<tr>
<td valign="top" width="129">
<p><b>Manifest declaration</b></p>
</td>
<td valign="top" width="484">
<p><b>What it provides</b></p>
</td>
</tr>
<tr>
<td valign="top" width="129">
<p align="left"><b>location</b></p>
</td>
<td valign="top" width="484">
<p align="left">Provides access to the current location, which is obtained from dedicated hardware like a GPS sensor in the PC or derived from available network information.</p>
</td>
</tr>
<tr>
<td valign="top" width="129">
<p align="left"><b>webcam</b></p>
</td>
<td valign="top" width="484">
<p align="left">Provides access to the webcam&#8217;s video feed, which allows the app to capture snapshots and movies from connected webcams.</p>
</td>
</tr>
<tr>
<td valign="top" width="129">
<p align="left"><b>microphone</b></p>
</td>
<td valign="top" width="484">
<p align="left">Provides access to the microphone&#8217;s audio feed, which allows the app to record audio from connected microphones.</p>
</td>
</tr>
<tr>
<td valign="top" width="129">
<p align="left"><b>proximity</b></p>
</td>
<td valign="top" width="484">
<p align="left">Provides the capability to connect to devices in close proximity to the PC via near field proximity radio. Near field proximity may be used to send files or communicate with an app on a nearby device.</p>
</td>
</tr>
</tbody>
</table></div>
<h3>Network access</h3>
<p>Most apps need an Internet connection, so the Visual Studio templates for Metro style apps include the internetClient capability by default. If your app doesn’t need to communicate over the Internet, you should remove this capability. The internetClientServer capability is generally used in peer-to-peer (P2P) scenarios like gaming or VOIP, but unless your app must open a port in the firewall, don’t use this capability. Use the privateNetworkClientServer capability when your app needs to communicate over private networks, for example between devices within a home, or over a corporate network connection.</p>
<div align="center">
<table class="b8table" cellspacing="0" cellpadding="3" align="center" border="0">
<tbody>
<tr>
<td valign="top" width="158">
<p><b>Manifest declaration</b></p>
</td>
<td valign="top" width="458">
<p><b>What it provides</b></p>
</td>
</tr>
<tr>
<td valign="top" width="158">
<p align="left"><b>internetClient</b></p>
</td>
<td valign="top" width="458">
<p align="left">Provides outbound access to the Internet and networks in public places like airports and coffee shops. Most apps that require Internet should use this capability.</p>
</td>
</tr>
<tr>
<td valign="top" width="158">
<p align="left"><b>internetClientServer</b></p>
</td>
<td valign="top" width="458">
<p align="left">Provides inbound and outbound access to the Internet and the networks in Public places like airports and coffee shops. This capability is a superset of internetClient. The internetClient capability doesn&#8217;t need to be enabled if this capability is also enabled.</p>
</td>
</tr>
<tr>
<td valign="top" width="158">
<p align="left"><b>privateNetworkClientServer</b></p>
</td>
<td valign="top" width="458">
<p align="left">Provides inbound and outbound access to Intranet networks that have an authenticated domain controller, or that the user has designated as either home or work networks.</p>
</td>
</tr>
</tbody>
</table></div>
<h3>User identity</h3>
<p>Most developers don’t need these capabilities. Use of these capabilities will be highly restricted and subject to additional onboarding policy and review. But there are cases where such capabilities are necessary and appropriate, for example some banks require two-factor authentication and need to allow customers to provide a smartcard that carries a digital certificate that confirms their identity. Other apps that are designed primarily for enterprise customers rather than consumers might need access to corporate resources that cannot be accesses without domain credentials.</p>
<div align="center">
<table class="b8table" cellspacing="0" cellpadding="3" align="center" border="0">
<tbody>
<tr>
<td valign="top" width="135">
<p><b>Manifest declaration</b><b></b></p>
</td>
<td valign="top" width="478">
<p><b>What it provides</b></p>
</td>
</tr>
<tr>
<td valign="top" width="135">
<p align="left"><b>enterpriseAuthentication</b></p>
</td>
<td valign="top" width="478">
<p align="left">Provides the capability to connect to enterprise intranet resources that require domain credentials.</p>
</td>
</tr>
<tr>
<td valign="top" width="135">
<p align="left"><b>sharedUserCertificates</b></p>
</td>
<td valign="top" width="478">
<p align="left">Provides the capability to access software and hardware certificates, such as smart card certificates, for validating a user&#8217;s identity. When related APIs are invoked at runtime, the user must take action (insert card, select certificate, etc.). This capability is not necessary if your app includes a private certificate via a Certificates declaration.</p>
</td>
</tr>
</tbody>
</table></div>
<p><b>Building confidence</b></p>
<p>Customers want to safely enjoy Windows 8 and the apps you build. The Metro style app experience is designed to make it easy for you to build apps that everyone can try and buy with confidence. This sets up a constructive cycle where people love and buy lots of apps that then generates opportunities for developers to create and deliver even more great Metro style apps.</p>
<p>As I noted at the beginning, we’re in this together; we are confident that the collective investments we made in this new ecosystem will help you build apps that people will be delighted with, and we look forward to partnering with you in delivering amazing new experiences to our joint customers.</p>
<p>&#8211;John Hazen</p>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10305059" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/b8/archive/2012/05/17/delivering-reliable-and-trustworthy-metro-style-apps.aspx">Building Windows 8</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/05/delivering-reliable-and-trustworthy-metro-style-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to improve performance in your Metro style app</title>
		<link>http://www.windows8tricks.net/2012/05/how-to-improve-performance-in-your-metro-style-app/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-improve-performance-in-your-metro-style-app</link>
		<comments>http://www.windows8tricks.net/2012/05/how-to-improve-performance-in-your-metro-style-app/#comments</comments>
		<pubDate>Thu, 10 May 2012 04:23:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured Posts]]></category>
		<category><![CDATA[For Developers]]></category>
		<category><![CDATA[improve]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Style]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/05/how-to-improve-performance-in-your-metro-style-app/</guid>
		<description><![CDATA[Nobody likes slow or unresponsive apps. Users expect that apps respond immediately to touch, taps, clicks, gestures and key-presses. Users expect that animations are smooth, that they can play, pause and restart their music and videos quickly, and that they never have to wait for the app to catch up with them. This is the]]></description>
			<content:encoded><![CDATA[<p>Nobody likes slow or unresponsive apps. Users expect that apps respond immediately to touch, taps, clicks, gestures and key-presses. Users expect that animations are smooth, that they can play, pause and restart their music and videos quickly, and that they never have to wait for the app to catch up with them. This is the first in a series of posts on how to make your apps &#8220;fast and fluid.&#8221;</p>
<p>We invested a lot of time in the engineering teams thinking about how we can ensure the performance of Metro style apps. We have learned what we can do in the platform to deliver on fast and fluid performance and have also learned what works and what does not work in building apps that deliver great experiences. In this blog I share with you some of the hard lessons from our own experiences so that you can build the best possible experiences for your customers.</p>
<h3>The psychology of performance</h3>
<p>Performance is more than just a stopwatch and efficient algorithms. When I think of performance, I like to take a holistic view and consider how users experience their time using apps. What does it mean for an app to be fast and fluid? One way to think about it is to separate a user’s experiences into three categories: perception, tolerance, and responsiveness.</p>
<h4>Perception: This is taking forever!</h4>
<p>Perception contributes to the “fast” in fast and fluid. We define a user’s perception of performance as how favorably they recall the time it took to perform their tasks within your app. In a perfect world a user’s perceptions would match reality. But often this is not the case, and their perception of time matters more than the reality. Have you ever left an installation to finish on its own, and come back to realize it’s paused part way through, waiting for you to answer one more question?</p>
<p>The more steps you can remember about a process, the slower it seems.</p>
<p><strong>Do:</strong></p>
<ul>
<li>Reduce the amount of time <em>between</em> activities that the user needs to perform to accomplish their task</li>
<li>Make sure that anytime you need to ask the user questions or have them provide info that you are asking all of the questions up front.</li>
</ul>
<p><strong>Don’t:</strong></p>
<ul>
<li>Separate out user activities into multiple periods with some time in between.</li>
</ul>
<h4>Tolerance: Time flies when you’re having fun</h4>
<p>Tolerance contributes to both the fast and fluid of fast and fluid. If perception is a measure of a user’s recollection of how much time passed, then tolerance is a measure of how favorable the passing of that time is. <s></s></p>
<p>When a user doesn’t know how long an action will take, the wait is painful. Imagine you’re using an app to do some photo editing work. When you click to apply a filter, the app becomes unresponsive. The time it spends frozen quickly becomes intolerable, even if it is just for a few seconds.</p>
<p>Photo apps have solved this problem by adding a progress bar or small animation to indicate that it is working on applying the filter. The amount of time users are willing to wait for the work to complete is far higher because there is no uncertainty. The app is both fast and fluid, and the difference is profound.</p>
<p><strong>Do:</strong></p>
<ul>
<li>Take a moment to identify the areas of your app that may require a substantial (&gt;= 1s) loading time.</li>
<li>Take steps to limit or eliminate user uncertainty during these scenarios.</li>
<li>Give users a visual indication of where they are in the process and how long it will take.</li>
<li>Use async APIs to avoid blocking the UI thread and making the app appear frozen.</li>
</ul>
<p><strong>Don’t:</strong></p>
<ul>
<li>Undergo long running actions without providing user feedback.</li>
</ul>
<h4>Responsiveness: Reflexes &lt; reactions &lt; acknowledgements</h4>
<p>Responsiveness contributes to the “fluid” in fast and fluid. If tolerance is a measure of the expectations and favorability of time, then responsiveness is the concept that the expectations of time are relative to the activity being performed. To measure and rate the performance of an activity, there must be a time interval to compare it against. I’ll refer to these time intervals as <em>interaction classes</em>. Internally we use these interaction classes to define responsiveness goals for core scenarios throughout Windows and track failures to meet these goals as bugs in the product.</p>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td valign="top"><strong>Interaction class</strong><strong></strong></td>
<td valign="top"><strong>Target</strong><strong></strong></td>
<td valign="top"><strong>Upper bound </strong><strong></strong></td>
<td valign="top"><strong>Human perception</strong><strong></strong></td>
<td valign="top"><strong>Typical scenario</strong></td>
</tr>
<tr>
<td valign="top"><strong>Instant</strong><strong></strong></td>
<td valign="top">&lt;= 50 ms</td>
<td valign="top">100 ms</td>
<td valign="top">No noticeable delay.</td>
<td valign="top">Input response &#8211; mouse click, button tap, etc.</td>
</tr>
<tr>
<td valign="top"><strong>Fast</strong><strong></strong></td>
<td valign="top">50 – 100 ms</td>
<td valign="top">200 ms</td>
<td valign="top">Minimally noticeable delay. No feedback necessary.</td>
<td valign="top">Pan/Scroll</td>
</tr>
<tr>
<td valign="top"><strong>Typical</strong><strong></strong></td>
<td valign="top">100 – 300 ms</td>
<td valign="top">500 ms</td>
<td valign="top">Quick, but too slow to be described as fast. No feedback necessary.</td>
<td valign="top">Open an in-page dialog (i.e. an info tip, pop up, fly out, toast, etc.)</td>
</tr>
<tr>
<td valign="top"><strong>Responsive</strong><strong></strong></td>
<td valign="top">300 – 500 ms</td>
<td valign="top">1 sec</td>
<td valign="top">Not fast, but still feels responsive. No feedback necessary.</td>
<td valign="top">Navigate to a new page, zooming, display processed or ready data</td>
</tr>
<tr>
<td valign="top"><strong>Continuous</strong><strong></strong></td>
<td valign="top">&gt;500 ms</td>
<td valign="top">10 sec</td>
<td valign="top">Medium wait, no longer feels responsive. Not long enough to do something else. May need feedback.</td>
<td valign="top">Launch the app, Snap the app, error messages, time-outs, update progress indication</td>
</tr>
<tr>
<td valign="top"><strong>Extended</strong><strong></strong></td>
<td valign="top">&gt;5 sec</td>
<td valign="top">&gt;1 minute</td>
<td valign="top">Long enough to do something else while waiting. May need feedback.</td>
<td valign="top">Sync or index a device/library</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Do:</strong></p>
<ul>
<li>Assign the important scenarios of your app to an interaction class representing the desired experience.</li>
<li>Identify if your scenarios are not meeting these goals and optimize them.</li>
<li>Identify if a scenario may require user feedback and provide it.</li>
</ul>
<h3>Key experiences to optimize</h3>
<p>Performance problems show up in various ways. They can reduce battery life, cause panning and scrolling to lag behind the user’s finger, or even make the app appear frozen for an extended period of time. I know that you don’t have infinite time to work on improving performance, so this section will go over some tips on how to identify areas where optimization will have the most impact, and some guidelines that can help you make those optimizations.</p>
<p>One way you can think about making optimizations, is that a process needs to be 20% faster or 20% slower before a user perceives a difference.</p>
<p align="center"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="a process needs to be 20% faster or 20% slower before a user perceives a difference" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/8400.20_2D00_Percent_5F00_4717A7EF.png" alt="Diagram showing 20 percent faster or slower than current time is noticeable" width="350" height="149" border="0" /></p>
<p>You may find &#8220;low-hanging fruit&#8221; in your app that can greatly increase performance for your key scenarios. But when you fix these issues, it becomes increasingly unlikely to stumble across a single performance issue which will immediately reduce the duration of the process by 20%. More often it is an accumulation of smaller problems along the same path which all contribute to the same user experience issue, and in the next section I discuss a great tool for discovering these paths.</p>
<h4>App profiling</h4>
<p>One of the simplest and most readily available techniques for determining where optimizations have the greatest effect is to perform app profiling. Profiling provides data on how much time your app is spending in its various functions, so you can see the hot spots where the app is doing most of its work. Thankfully there is a great profiling tool available in Visual Studio 11 that you can access on the Windows 8 Consumer Preview.</p>
<p>But before you begin, remember that Windows 8 will be run on a wide variety of devices and taking performance measurements on powerful hardware may not truly show performance characteristics on other form factors. For many of my own features, when performing measurements I use a lower-end laptop. For more info see the blog on <a href="http://blogs.msdn.com/b/b8/archive/2012/02/29/running-the-consumer-preview-system-recommendations.aspx" target="_blank">Running the Consumer Preview: system recommendations</a>.</p>
<p>Here’s how to prep a machine for measurements:</p>
<ol>
<li>Make sure the machine is plugged in and <em>not</em> running on battery – many systems operate differently on battery to conserve power.</li>
<li>Don’t use remote desktop to perform measurements because it can disable hardware acceleration and skew results.</li>
<li>Ensure that the total memory utilization on the system is less than 50%. If it’s higher, close apps until you reach 50% to make sure you are measuring the true impact of your app and not other processes.</li>
</ol>
<p>To begin profiling your app:</p>
<ol>
<ol>
<li>Launch your app in Visual Studio.</li>
<li>On the Debug menu pick one of the two Performance Analysis options:</li>
</ol>
</ol>
<p align="center"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Start Performance Analysis Menu" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/2234.Start_2D00_Performance_2D00_Analysis_2D00_Menu_5F00_46AB74FA.png" alt="Menu containing Start Performance Analysis (Alt+F2), Start Performance Analysis Paused (Ctrl+Alt+F2)" width="352" height="197" border="0" /></p>
<ol>
<ul>
<li><strong>Start Performance Analysis</strong>: Immediately start recording usage info and launch the app.</li>
<li><strong>Start Performance Analysis Paused</strong>: Launch the app and later you can resume recording of info. This is used to get the app into a particular state before recording info (such as to test a specific user scenario).</li>
</ul>
<li>After performing the actions you want to measure, go back to Visual Studio and click <strong>Stop profiling</strong>. This causes VS to generate a report and display key information about the app’s activities.</li>
</ol>
<p align="center"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="Stop profiling link" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/8585.Stop_2D00_Profiling_5F00_0D286503.png" alt="Stop profiling link in Visual Studio" width="423" height="173" border="0" /></p>
<p>Two of the most useful views in the performance report are the Call Tree view and the Function Details view. In the Call Tree view, you can see all the functions your app called during execution, how many times they were invoked, and how much time they took to execute. There is also an Expand Hot Path button, which shows you which functions took the longest time to execute. These are the first areas for you to concentrate your optimizations, because they will likely have the largest effect.</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/1050.Expand_2D00_Hot_2D00_Path_5F00_7117A617.png" target="_blank" rel="lightbox[1264]" title="The Expand hot path button in the Visual Studio profiler"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="The Expand hot path button in the Visual Studio profiler" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/0576.Expand_2D00_Hot_2D00_Path_5F00_thumb_5F00_0CBC320E.png" alt="Expand Hot Path button in the Call Tree view" width="702" height="104" border="0" /></a></p>
<p>The report shows both the inclusive and exclusive times for each function. Exclusive time measures the percentage of time spent executing code in that function. Inclusive time is the percentage of time between when the function was called and when it returned. In other words, it is not only the time spent executing code in the function, but also the time spent executing code in any functions that it calls.</p>
<p>For any of the functions in your app, you can open the Function Details view to get detailed info about what the function did, including the specific code that it executed and what functions it called and how long these functions took. In the example shown in the figure, <strong>Array.concat </strong>function is the major contributor to the hot path, taking up 29.7% of app execution time. The Function Details view shows us that <strong>Array.concat</strong> function is actually only taking up about 12.6% of the time itself (shown in orange), and that the majority of the time is actually taken up in <strong>get_MainResourceMap</strong> function, which the concatenation function calls as part of its execution (shown in purple). You can then click on any of these functions to get more details.</p>
<p align="center"><a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31-metablogapi/6013.Function_2D00_Details_5F00_6581E8D8.png" target="_blank" rel="lightbox[1264]" title="The Function Details view provides useful information about the flow of an app"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="The Function Details view provides useful information about the flow of an app" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/0167.Function_2D00_Details_5F00_thumb_5F00_4C19E59E.png" alt="Function Details view for Array.concat shows Calling functions percentege, Current function percentage, and Called functions percentages." width="702" height="186" border="0" /></a></p>
<p>A few weeks before the release of the Windows 8 Consumer Preview, I was using one of the apps and noticed that my laptop was getting hot and the fans started to turn on. Working with the owner of the app, we used profiling to identify some code paths that were causing large amounts of unnecessary CPU usage, which were then fixed. The difference was immediately noticeable, and other app scenarios (such as snapping) were also improved by the changes.</p>
<h4>Suspend is your friend</h4>
<p>App launch occurs only when your app is not suspended – otherwise your app pops back into view nearly instantly as it is resumed. Keeping your app suspended is a technique for managing perception, tolerance, and responsiveness. Users enjoy your app more quickly, and never experience the uncertainty of waiting for your app to load each time they use it. In short, keeping your app from being terminated is a performance grand slam. The easiest way to do that is to keep your app’s memory usage low when suspended.</p>
<p>Before your app gets suspended, it has a few seconds to do some work. During this time, free any large objects that can be easily re-acquired on resume. This keeps your app’s memory footprint low, and greatly reduces the likelihood that the system terminates your app to make room for something else. Here’s how you can see if your app correctly suspends:</p>
<ol>
<li>Launch the app and then go back to the desktop.</li>
<li>Launch the Task Manager by pressing Ctrl+Shift+Esc, and click “More details” to see all available options.</li>
<li>Click View &gt; Status values &gt; Show suspended status.</li>
</ol>
<p align="center"><img style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="How to show suspended apps in Task Manager" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/2318.Show_2D00_Suspended_2D00_Status_5F00_0FEE19F6.png" alt="Under View menu, Group by type is selected, and then Show suspended status is selected." width="385" height="229" border="0" /></p>
<p>After a few seconds, the word “Suspended” appears next to your app’s name. While suspended, make sure your app’s private working set memory usage is significantly lower than when it is running. I recommend that you target these memory metrics for your app while it is suspended, based on its complexity and general size:</p>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td valign="top"><strong>App complexity (approx.)</strong></td>
<td valign="top"><strong>Private set while suspended (max)</strong></td>
</tr>
<tr>
<td valign="top"><strong>Minimal app (ex. Hello World)</strong></td>
<td valign="top">40-60 MB</td>
</tr>
<tr>
<td valign="top"><strong>Medium app (ex. Weather)</strong></td>
<td valign="top">60-80 MB</td>
</tr>
<tr>
<td valign="top"><strong>Large app (ex. Windows Live Photos)</strong></td>
<td valign="top">120-150 MB</td>
</tr>
</tbody>
</table>
</div>
<p>Here’s how you can see how much memory your app is using while suspended:</p>
<ol>
<ol>
<li>Make sure the app is suspended using the steps we saw earlier.</li>
<li>Right-click on the app’s name in Task Manager and click “Go to details.” This will take you to more details about your app’s process (WWAHost.exe is the process for all Metro style apps using JavaScript; otherwise your app’s name appears as the process).</li>
<li>Make sure that the “Memory (private working set)” column is present. If not, right-click any column, go to <strong>Select columns,</strong> and select <strong>Memory (private working set)</strong>.</li>
</ol>
</ol>
<p align="center"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="Select Memory (private working set)" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/8407.Memory_2D00_Private_2D00_Working_2D00_Set_5F00_4FB8007B.png" alt="Memory (private working set) is selected in list of column names" width="315" height="330" border="0" /></p>
<ol>
<li>The value listed under this column is the private working set of your app.</li>
</ol>
<p align="center"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="Measuring the private working set for WWAHost.exe" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/1134.WWAHost_2D00_Memory_2D00_Usage_5F00_566B09FE.png" alt="Memory usage appears as 20,736 K" width="545" height="26" border="0" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3>Being a good citizen in the app ecosystem</h3>
<p>As disappointing as it may sound, your app is not the only one that will be used <img src='http://www.windows8tricks.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Therefore, be a good citizen when running on the user’s system so that they don’t begin to attribute any perceived latencies in the system to your app and start to mentally relate it to bad performance or battery life on their system. Here are a couple tips to help your app play well with others.</p>
<h4>Don’t spike memory usage</h4>
<p>The system’s job is to accommodate the resource needs of all Metro style apps by automatically terminating suspended apps to make room for new ones, freeing the user from having to manage resources. A side effect of this is that if an app requests a large amount of memory, then other apps might be terminated– even if the app frees that memory soon after requesting it. To avoid this issue when tackling heavyweight operations, it is best to approach them in small chunks.</p>
<p>If you are coding in a memory managed language (such as JavaScript or C#), it is extremely difficult to control when memory allocations occur. However, an easy trap to fall into is loading resources which are too large for the resolution of the current system and scaling them down. You can use the new <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh781216.aspx" target="_blank">Thumbnail APIs</a> to acquire resources appropriate for the target resolution and avoid having an unnecessarily high overhead. We used this approach to greatly reduce the memory usage of a picture based puzzle game that we use for testing.</p>
<p>Regardless of language, I recommend that you target these runtime memory metrics for your app, based on its complexity and general size:</p>
<div align="center">
<table class="b8table" border="0" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td valign="top"><strong>App complexity (approx.)</strong></td>
<td valign="top"><strong>Total working set (max)</strong></td>
</tr>
<tr>
<td valign="top"><strong>Minimal app (ex. Hello World)</strong></td>
<td valign="top">50-70 MB</td>
</tr>
<tr>
<td valign="top"><strong>Medium app (ex. Weather)</strong></td>
<td valign="top">80-100 MB</td>
</tr>
<tr>
<td valign="top"><strong>Large app (ex. Photos)</strong></td>
<td valign="top">120-150 MB</td>
</tr>
</tbody>
</table>
</div>
<p>Here’s how you can see how much memory your app is using while running:</p>
<ol>
<li>Launch the Task Manager by pressing Ctrl+Shift+Esc, and click <strong>More details</strong> to see all available options.</li>
<li>Click the Options menu item, and make sure that <strong>Always on top</strong> is checked.</li>
<li>Launch your app. When the app appears in Task Manager, right-click it and click <strong>Go to details</strong>.</li>
<li>Make sure that the Working set (memory) column is present. If not, right-click any column, and go to <strong>Select columns</strong>. Check the <strong>Working set (memory)</strong>column.
<p align="center"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="Enabling the working set (memory) column" src="http://www.windows8tricks.net/wp-content/uploads/2012/07/3276.Working_2D00_Set_2D00_memory_5F00_2B2672F7.png" alt="Working set (memory) is selected in list of columns" width="308" height="322" border="0" /></p>
</li>
<li>The value listed under this column is the total working set of your app.</li>
</ol>
<h4>Minimize use of system resources while idle or snapped</h4>
<p>One of the biggest concerns for users is the battery life of their devices. Therefore, I recommend that your Metro style apps help conserve energy by freeing their use of system resources when the user is not actively interacting with them. Here are just a few tips to reduce resource usage:</p>
<p><strong>Don’t run animations, audio, or background videos while snapped.</strong></p>
<ul>
<li>Your app is no longer the center of attention. Make your app feel colorful and usable, but don’t take away from the resources available to the primary app or use the battery.</li>
<li>This assumes your app isn’t a dedicated music/video playback client.</li>
</ul>
<p><strong>Don’t run animations, audio or background videos in an infinite loop</strong>.</p>
<ul>
<li>If the user hasn’t interacted with the app over some small duration, pause these activities. You can safely resume them when the user next interacts with your app.</li>
<li>I’ve seen apps go from 40% CPU usage while idle down to 0% simply because they paused their background activities.</li>
</ul>
<p><strong>Don’t perform file caching, device syncing, or any other disk-intensive operation while snapped or idle.</strong></p>
<ul>
<li>Using the disk unnecessarily increases seek times for other operations and uses a lot of power.</li>
</ul>
<h3>Going forward</h3>
<p>In this post I described how you can think about performance, methods for setting goals for the key experiences in your app, and talked about some tools to help identify areas that you might need to optimize. My next post will cover how to go about making these optimizations for the biggest problem areas, and how to avoid some common pitfalls. I hope these tips will prove useful to you!</p>
<p>Until next time,</p>
<p>&#8211; David Tepper, Program Manager, Windows</p>
<div style="clear: both;"></div>
<p><img src="" alt="" width="1" height="1" /><br />
<a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/03/how-to-improve-performance-in-your-metro-style-app.aspx" rel="nofollow">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/05/how-to-improve-performance-in-your-metro-style-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tackling performance killers: Common performance problems with Metro style apps</title>
		<link>http://www.windows8tricks.net/2012/05/tackling-performance-killers-common-performance-problems-with-metro-style-apps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tackling-performance-killers-common-performance-problems-with-metro-style-apps</link>
		<comments>http://www.windows8tricks.net/2012/05/tackling-performance-killers-common-performance-problems-with-metro-style-apps/#comments</comments>
		<pubDate>Wed, 09 May 2012 01:22:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[Common]]></category>
		<category><![CDATA[killers]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[problems]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Tackling]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/05/tackling-performance-killers-common-performance-problems-with-metro-style-apps/</guid>
		<description><![CDATA[Now that you had time to read my previous post, How to improve performance in your Metro style app , on the methodology and tools available to help you create fast and fluid apps, I want to dig into the common performance killers I have seen in apps. In this post, I go over the]]></description>
			<content:encoded><![CDATA[<p>Now that you had time to read my previous post, How to improve performance in your Metro style app , on the methodology and tools available to help you create <i>fast and fluid</i> apps, I want to dig into the common performance killers I have seen in apps. In this post, I go over the top guidance points which I have observed to result in measureable and noticeable improvements for Metro style apps, both written in JavaScript and in XAML. Plus, I tell you about 5 specific practices that I know will make a big difference, regardless of what language you are using. The good news is that they don’t depend on clever tricks or complex operations. I am confident that following these guidelines will hugely improve your app’s performance. Let me know in the comments how these help you, and share your own tips. </p>
<h3>General guidance</h3>
<p>Rely on packaged content, not network content.</p>
<ul>
<li>Local images and files are always faster to retrieve than those over the network. </li>
<li>If your app needs to load a “live” image, it is best to use a local image as a placeholder while it is being retrieved.</li>
</ul>
<p>Scale local images to the right size.</p>
<ul>
<li>If an image is always going to be displayed at the same resolution, then package it at that resolution pre-scaled. This prevents the image from being scaled at runtime each time it is shown, incurring a performance penalty many times throughout the app’s lifecycle.</li>
<li>If the image may be shown at multiple resolutions, package multiple versions of the image unless you have a strong reason not to. </li>
</ul>
<p>Keep the launch times of your modern app fast.</p>
<ul>
<li>Perform network operations only after the splash screen disappears. </li>
<li>Defer loading databases and other large in-memory objects while the app is activating. </li>
<li>If you have large tasks to complete, provide a custom splash screen or pared down landing page so that your app can accomplish these tasks in the background. </li>
</ul>
<p>Windows 8 runs on a wide range of devices, use media content appropriate for the user&#8217;s resolution.</p>
<ul>
<li>Loading content that is too small for a user’s resolution has reduced fidelity. </li>
<li>Loading content that is too large for a user’s resolution puts an unnecessary strain on the resources of the system.</li>
</ul>
<p>Emphasize responsiveness in your apps. </p>
<ul>
<li>Don’t block the UI thread with synchronous APIs. Use asynchronous APIs or call synchronous APIs in a non-blocking context (such as from another thread).</li>
<li>Move time-intensive calculations to a thread that is not the UI thread. This is important because users will likely notice delays longer than 100ms.</li>
<li>Break apart time-consuming work into smaller chunks, allowing the UI thread to listen for user input in between.</li>
<li>Use web workers/threads to offload expensive work.</li>
<li>Don’t draw to the screen faster than it can refresh. Input events fire much faster than the screen refresh rate. So using these events to update the screen causes a large amount of unnecessary work. Synchronize your draws to the screen refresh rate instead.</li>
</ul>
<h3>Tweaking performance of Metro style apps using JavaScript</h3>
<p>When coding Metro style apps in JavaScript, all the tips and tricks you already know for coding JavaScript in web sites still apply. But for Metro style apps written in JavaScript, here are the top 3 techniques that yield the most impactful performance gains, based on our research and observations. For more info, see <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465194.aspx" target="_blank">Performance best practices for Metro style apps using JavaScript</a>, in the Dev Center.</p>
<h4>Use thumbnails for quick rendering</h4>
<p>The file system and media files are an important part of most apps, and also one of the most common sources of performance issues. Accessing media files can be slow, because it takes memory and CPU cycles to store and decode or display the media. </p>
<p>Instead of scaling down a large version of an image to display as a thumbnail, use the Windows Runtime thumbnail APIs. Scaling down a full-size image is inefficient because the app must read and decode the full-size image and then spend additional time scaling it. The Windows Runtime provides a set of APIs backed by an efficient cache to allow the app to quickly get a smaller version of an image to use for a thumbnail.</p>
<p>This example prompts the user for an image and then displays the image. </p>
<blockquote><div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">// Pick an image file</span><br />picker.pickSingleFileAsync()<br />.then(<span style="color: rgb(0, 0, 255);">function</span> (file) {<br />  <span style="color: rgb(0, 0, 255);">var</span> imgTag = document.getElementById(<span style="color: rgb(0, 96, 128);">&quot;imageTag&quot;</span>);<br />  imgTag.src = URL.createObjectURL(file, <span style="color: rgb(0, 0, 255);">false</span>);<br />});</pre>
</p></div>
</blockquote>
<p>This example works well when you want to render the image at, or near, its full size, but it&#8217;s inefficient for displaying a thumbnail view of the image. The thumbnail APIs return a thumbnail version of the image that the app can decode and display much faster than the full-sized image. The next example uses the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.getthumbnailasync.aspx" target="_blank">getThumbnailAsync</a><strong></strong> method to retrieve the image and create a thumbnail based on it. </p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">// Pick an image file</span><br />picker.pickSingleFileAsync()<br />.then(<span style="color: rgb(0, 0, 255);">function</span> (file) {<br />  <span style="color: rgb(0, 0, 255);">var</span> properties = Windows.Storage.FileProperties.ThumbnailMode;<br />  <span style="color: rgb(0, 0, 255);">return</span> file.getThumbnailAsync(properties.singleItem, 1024);<br />})<br />.then(<span style="color: rgb(0, 0, 255);">function</span> (thumb) {<br />  <span style="color: rgb(0, 0, 255);">var</span> imgTag = document.getElementById(<span style="color: rgb(0, 96, 128);">&quot;imageTag&quot;</span>);<br />  imgTag.src = URL.createObjectURL(thumb, <span style="color: rgb(0, 0, 255);">false</span>);<br />});</pre>
</p></div>
</blockquote>
<p>Our measurements show that this pattern can improve image loading times by as much as 1000% (that is, the image loads up to 10 times faster when using the thumbnail APIs versus accessing it directly from disk and scaling it). </p>
<h4>Keep DOM interactions to a minimum</h4>
<p>In the platform for Metro style apps using JavaScript, the DOM and the JavaScript engine are separate components. Any JavaScript operation that involves communication between these components is relatively expensive when compared to operations that can be carried out purely within the JavaScript runtime. So it&#8217;s important to keep interactions between these components to a minimum. For example, getting or setting properties of DOM elements can be fairly expensive. This example accesses the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh453011.aspx"><strong>body</strong></a> property and several other properties repeatedly. </p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">// Don’t use: inefficient code. </span><br /><span style="color: rgb(0, 0, 255);">function</span> calculateSum() {<br />    <span style="color: rgb(0, 128, 0);">// Retrieve Values</span><br />    <span style="color: rgb(0, 0, 255);">var</span> lSide = document.body.all.lSide.value;<br />    <span style="color: rgb(0, 0, 255);">var</span> rSide = document.body.all.rSide.value;<br /><br />    <span style="color: rgb(0, 128, 0);">// Generate Result</span><br />    document.body.all.result.value = lSide + rSide;<br />}<br /><br /><span style="color: rgb(0, 0, 255);">function</span> updateResultsStyle() {<br />    <span style="color: rgb(0, 0, 255);">if</span> (document.body.all.result.value &gt; 10) {<br />        document.body.resultsDiv.<span style="color: rgb(0, 0, 255);">class</span> = <span style="color: rgb(0, 96, 128);">&quot;highlighted&quot;</span>;<br />    } <span style="color: rgb(0, 0, 255);">else</span> {<br />        document.body.resultsDiv.<span style="color: rgb(0, 0, 255);">class</span> = <span style="color: rgb(0, 96, 128);">&quot;normal&quot;</span>;<br />    }<br />}</pre>
</p></div>
</blockquote>
<p>The next example improves the code by caching the value of the DOM properties instead of repeatedly accessing them.</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">function</span> calculateSum() {<br />    <span style="color: rgb(0, 128, 0);">// Retrieve Values</span><br />    <span style="color: rgb(0, 0, 255);">var</span> all = document.body.all;<br />    <span style="color: rgb(0, 0, 255);">var</span> lSide = all.lSide.value;<br />    <span style="color: rgb(0, 0, 255);">var</span> rSide = all.rSide.value;<br /><br />    <span style="color: rgb(0, 128, 0);">// Generate Result</span><br />    all.result.value = lSide + rSide;<br />}<br /><br /><span style="color: rgb(0, 0, 255);">function</span> updateResultsStyle() {<br />    <span style="color: rgb(0, 0, 255);">var</span> body = document.body;<br />    <span style="color: rgb(0, 0, 255);">var</span> all = body.all;<br />    <span style="color: rgb(0, 0, 255);">if</span> (all.result.value &gt; 10) {<br />        body.resultsDiv.<span style="color: rgb(0, 0, 255);">class</span> = <span style="color: rgb(0, 96, 128);">&quot;highlighted&quot;</span>;<br />    } <span style="color: rgb(0, 0, 255);">else</span> {<br />        body.resultsDiv.<span style="color: rgb(0, 0, 255);">class</span> = <span style="color: rgb(0, 96, 128);">&quot;normal&quot;</span>;<br />    }<br />}</pre>
</p></div>
</blockquote>
<p>Use DOM objects only to store info that directly affects how the DOM lays out or draws elements. If the <em><b>lSide</b></em> and <em><b>rSide</b></em> properties from the previous example store only info about the internal state of the app, don&#8217;t attach them to a DOM object. The next example uses pure JavaScript objects to store the internal state of the app. The example updates DOM elements only when the display needs to be updated.</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">var</span> state = {<br />    lValue: 0,<br />    rValue: 0,<br />    result: 0<br />};<br /><br /><span style="color: rgb(0, 0, 255);">function</span> calculateSum() {<br />    state.result = lValue + rValue;<br />}<br /><br /><span style="color: rgb(0, 0, 255);">function</span> updateResultsStyle() {<br />    <span style="color: rgb(0, 0, 255);">var</span> body = document.body;<br />    <span style="color: rgb(0, 0, 255);">if</span> (result &gt; 10) {<br />        body.resultsDiv.<span style="color: rgb(0, 0, 255);">class</span> = <span style="color: rgb(0, 96, 128);">&quot;highlighted&quot;</span>;<br />    } <span style="color: rgb(0, 0, 255);">else</span> {<br />        body.resultsDiv.<span style="color: rgb(0, 0, 255);">class</span> = <span style="color: rgb(0, 96, 128);">&quot;normal&quot;</span>;<br />    }<br />}</pre>
</p></div>
</blockquote>
<p>Our measurements show that simply accessing data in the DOM can result in up to a 700% increase in access time when compared to accessing variables not tied to the DOM. </p>
<h4>Manage layout efficiently</h4>
<p>To render an app onscreen, the system must perform complex processing that applies the rules of HTML, CSS, and other specifications to the size and position of the elements in the DOM. This process is called a <i>layout pass</i> and can be very expensive. </p>
<p><a name="batch_api_calls_that_trigger_a_layout_pa"></a>APIs that trigger a layout pass include:</p>
<ul>
<li>window.getComputedStyle </li>
<li>offsetHeight</li>
<li>offsetWidth</li>
<li>scrollLeft</li>
<li>scrollTop</li>
</ul>
<p>A layout pass occurs as part of calling these APIs if anything that affects layout has changed since layout info was last gathered. One way to reduce the number of layout passes is to batch API calls that trigger a layout pass. To see how to do this, let&#8217;s take a look at the next code snippet. In both of the examples here, we are adjusting the <b>offsetHeight</b> and <b>offsetWidth</b> of an element by 5. First, take a look at a common but inefficient way to adjust the <b>offsetHeight</b> and <b>offsetWidth</b>:</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">// Don't use: inefficient code.</span><br /><span style="color: rgb(0, 0, 255);">function</span> updatePosition(){<br />    <span style="color: rgb(0, 128, 0);">// Calculate the layout of this element and retrieve its offsetHeight</span><br />    <span style="color: rgb(0, 0, 255);">var</span> oH = e.offsetHeight; <br /><br />    <span style="color: rgb(0, 128, 0);">// Set this element's offsetHeight to a new value</span><br />    e.offsetHeight = oH + 5; <br /><br />    <span style="color: rgb(0, 128, 0);">// Calculate the layout of this element again because it was changed by the  </span><br />    <span style="color: rgb(0, 128, 0);">// previous line, and then retrieve its offsetWidth</span><br />    <span style="color: rgb(0, 0, 255);">var</span> oW = e.offsetWidth; <br /><br />    <span style="color: rgb(0, 128, 0);">// Set this element's offsetWidth to a new value</span><br />    e.offsetWidth = oW + 5; <br />}<br /><br /><span style="color: rgb(0, 128, 0);">// At some later point the Web platform calculates layout again to take this change into account and render <br />the element to the screen</span></pre>
</p></div>
</blockquote>
<p>The previous example triggers 3 layout passes. Now take a look at a better way to achieve the same result: </p>
<blockquote>
<div>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">function</span> updatePosition() {<br />    <span style="color: rgb(0, 128, 0);">// Calculate the layout of this element and retrieve its offsetHeight</span><br />    <span style="color: rgb(0, 0, 255);">var</span> height  = e.offsetHeight + 5;  <br /><br />    <span style="color: rgb(0, 128, 0);">// Because the previous line already did the layout calculation and no fields were changed, this line retrieves <br />the offsetWidth from the previous line</span><br />    <span style="color: rgb(0, 0, 255);">var</span> width = e.offsetWidth + 5; <br /><br />    <span style="color: rgb(0, 128, 0);">//set this element's offsetWidth to a new value</span><br />    e.offsetWidth = height;<br /><br />    <span style="color: rgb(0, 128, 0);">//set this element's offsetHeight to a new value</span><br />    e.offsetHeight = width;<br />}<br /><br /><span style="color: rgb(0, 128, 0);">// At some later point the system calculates layout again to take this change into account and render element to the screen</span><br /></pre>
</p></div>
</blockquote>
<p>Even though the second example is only slightly different than the first, it triggers only 2 layout passes instead of 3, a 33% improvement. The performance impact varies, depending on the size and complexity of the DOM and its associated styles. The richer your app’s UI, the more important following this guideline becomes.</p>
<h3>Tweaking performance of Metro style apps written in XAML</h3>
<p>Well-structured XAML pays dividends in many key scenarios including activation time, page navigation, and memory usage. Here are a few tips to help tune the XAML of your app.</p>
<h4>Avoid duplication</h4>
<p>Parsing XAML and creating corresponding objects in memory can be time-consuming for complex UI with deep element trees. This is why we recommend that you load only the XAML needed to get past the startup process. The easiest thing to do is load only pages needed to display the first visual. Carefully examine the XAML of your first page to make sure it contains everything it needs. If you reference a control or style that is defined somewhere else, the framework parses that file too.</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">&lt;!--This is the first page an app displays. A resource used by this page, TextColor, is defined in <br />AppStyles.xaml which means that file must be parsed when this page is loaded. Because AppStyles.xaml <br />contains many app-wide resources, all of these resources need to be parsed even though they aren’t <br />necessary to start the app. --&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Page</span> ...<span style="color: rgb(0, 0, 255);">&gt;</span> <br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">TextBox</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;{StaticResource TextColor}&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Page</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br />Contents of AppStyles.xaml<br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">ResourceDictionary</span> …<span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;TextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br /><br />    <span style="color: rgb(0, 128, 0);">&lt;!--many other resources used across the app and not necessarily for startup.--&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">ResourceDictionary</span><span style="color: rgb(0, 0, 255);">&gt;</span> <br /></pre>
<p></div>
</blockquote>
<p>Trim resource dictionaries. Store app-wide resources in the Application object to avoid duplication, but move resources specific to single pages to the resource dictionary of that page. This reduces the amount of XAML parsed when the app starts and only incur the cost of parsing that XAML when a user navigates to the specific page.</p>
<blockquote>
<div></div>
<div>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">&lt;!--Bad: XAML which is specific to a page should not be included in the App’s resource</span><br /><span style="color: rgb(0, 128, 0);">   dictionary. The app incurs the cost of parsing resources that are not immediately</span><br /><span style="color: rgb(0, 128, 0);">   necessary at startup, instead of parsing on demand. These page specific resources should be</span><br /><span style="color: rgb(0, 128, 0);">   moved to the resource dictionary for that page.--&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Application</span> …<span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Application.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;DefaultAppTextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;HomePageTextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;SecondPageTextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;ThirdPageTextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Application.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Application</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br />XAML for the home page of the app<br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Page</span> ...<span style="color: rgb(0, 0, 255);">&gt;</span>    <br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">TextBox</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;{StaticResource HomePageTextColor}&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Page</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br />XAML for the second page of the app<br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Page</span> ...<span style="color: rgb(0, 0, 255);">&gt;</span> <br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Button</span> <span style="color: rgb(255, 0, 0);">Content</span><span style="color: rgb(0, 0, 255);">=&quot;Submit&quot;</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;{StaticResource SecondPageColor}&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Page</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /></pre>
</p></div>
</blockquote>
<blockquote>
<div>&#160; </p>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">&lt;!--Good: All page specific XAML has been moved to the resource dictionary for the</span><br /><span style="color: rgb(0, 128, 0);">   page on which it’s used. The home page specific XAML was not moved because it must</span><br /><span style="color: rgb(0, 128, 0);">   be parsed at start up anyway. Moving it to the resource dictionary of the home page</span><br /><span style="color: rgb(0, 128, 0);">   wouldn’t be bad either.--&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Application</span> …<span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Application.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;DefaultAppTextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;HomePageTextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Application.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Application</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br />XAML for the home page of the app<br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Page</span> ...<span style="color: rgb(0, 0, 255);">&gt;</span>    <br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">TextBox</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;{StaticResource HomePageTextColor}&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Page</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br />XAML for the second page of the app<br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Page</span> ...<span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Page.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">SolidColorBrush</span> <span style="color: rgb(255, 0, 0);">x:Key</span><span style="color: rgb(0, 0, 255);">=&quot;SecondPageTextColor&quot;</span> <span style="color: rgb(255, 0, 0);">Color</span><span style="color: rgb(0, 0, 255);">=&quot;#FF3F42CC&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Page.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />    <br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Button</span> <span style="color: rgb(255, 0, 0);">Content</span><span style="color: rgb(0, 0, 255);">=&quot;Submit&quot;</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;{StaticResource SecondPageTextColor}&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">StackPanel</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Page</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /></pre>
</p></div>
</p></div>
</blockquote>
<h4>Optimize element count</h4>
<p>The XAML framework is designed to display thousands of objects but reducing the number of elements on a page will make your app layout and render scenes even faster. There are a few tricks that you can use to reduce a scene’s element count while maintaining the same level of visual complexity. </p>
<ul>
<li>Avoid unnecessary elements. For example, set the <b>Background</b> property on panels to provide a background color instead of placing colored Rects behind the elements in that panel.</li>
</ul>
<blockquote>
<div>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">&lt;!--Bad XAML uses an unnecessary Rectangle to give the Grid a black background--&gt;</span>                                                                <br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Rectangle</span> <span style="color: rgb(255, 0, 0);">Fill</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />   <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /></pre>
</p></div>
<div>&#160;</div>
<div>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 128, 0);">&lt;!--Good XAML uses the Grid’s background property--&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br /></pre>
</p></div>
</blockquote>
<ul>
<li>
<p>Collapse elements that are not visible because they are blocked or transparent.</p>
</li>
<li>
<p>If the same vector-based element is re-used multiple times, consider making it an image. Memory for an image is allocated only once per image Uri. In contrast, vector-based elements are instantiated for every instance.</p>
</li>
</ul>
<h4>Use independent animations</h4>
<p>Animations can be calculated from beginning to end when they are created. Sometimes the changes to the property being animated don’t affect rest of the objects in a scene. These are called independent animations and they are run on the composition thread instead of the UI thread. This guarantees that they remain smooth because the composition thread is updated at a consistent cadence. All these are guaranteed to be independent:</p>
<ul>
<li>Object animations using key frames</li>
<li>Zero-duration animations</li>
<li>Canvas.Left/Top</li>
<li>UIElement.Opacity</li>
<li>SolidColorBrush.Color when applied to many properties</li>
<li>Subproperties of</li>
<ul>
<li>UIElement.RenderTransform</li>
<li>UIElement.Projection</li>
<li>RectangleGeometry of UIElement.Clip</li>
</ul>
</ul>
<p>Dependent animations affect layout and can’t be calculated without extra input from the UI thread. These animations include modifications to properties like width and height. By default dependent animations are not run and require an opt-in from the app developer. When enabled, they will run smoothly if the UI thread remains unblocked; but they begin to stutter if the framework or app is doing a lot of other work.</p>
<p>The XAML framework has worked hard to make almost all animations independent by default; but there are some actions you can take to disable this optimization. Be very cautious when doing the following:</p>
<ul>
<li>Setting the <b>EnableDependentAnimation</b> property allows a dependent animation to run on the UI thread. Convert these animations into an independent version. For example animate <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.scaletransform.scalex.aspx" target="_blank">ScaleTransform.XScale</a> and <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.scaletransform.scaley.aspx" target="_blank">ScaleTransform.YScale</a> instead of the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.frameworkelement.width.aspx" target="_blank">Width</a> and <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.frameworkelement.height.aspx" target="_blank">Height</a> of an object.</li>
<li>Making per frame updates which are effectively dependent animations. An example of this is applying transformations in the handler for <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.compositiontarget.rendering.aspx" target="_blank">CompositonTarget.Rendering</a>.</li>
<li>Running any animation considered independent in an element with CacheMode=BitmapCache. This is considered dependent because the cache must be re-rasterized each frame.</li>
</ul>
<p>Creating fast and fluid apps that are rich and complex is an art. I shared some specific things for you to consider, but it is rare that any one tool or technique is the key to good performance. More often it is a collection of good practices starting with considering performance early in your design. I hope that this blog will set you on the right path for delivering on your customers’ high expectations.</p>
<p>Happy (and efficient) coding!</p>
<p>-Dave Tepper, Program Manager, Windows</p>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10290941" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/05/tackling-performance-killers-common-performance-problems-with-metro-style-apps.aspx">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/05/tackling-performance-killers-common-performance-problems-with-metro-style-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fast and fluid animations in your Metro style app</title>
		<link>http://www.windows8tricks.net/2012/05/fast-and-fluid-animations-in-your-metro-style-app/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fast-and-fluid-animations-in-your-metro-style-app</link>
		<comments>http://www.windows8tricks.net/2012/05/fast-and-fluid-animations-in-your-metro-style-app/#comments</comments>
		<pubDate>Thu, 03 May 2012 10:18:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[For Developers]]></category>
		<category><![CDATA[animations]]></category>
		<category><![CDATA[Fast]]></category>
		<category><![CDATA[fluid]]></category>
		<category><![CDATA[Metro]]></category>
		<category><![CDATA[Style]]></category>

		<guid isPermaLink="false">http://www.windows8tricks.net/2012/05/fast-and-fluid-animations-in-your-metro-style-app/</guid>
		<description><![CDATA[Fast and fluid animations bring apps to life. In Windows 8 Consumer Preview, you will notice that animations are an integral part of the user experience. When you log in to your PC, the items in the Start menu animate in. When you launch an immersive app or zoom into the Start menu, the experience]]></description>
			<content:encoded><![CDATA[<p>Fast and fluid animations bring apps to life. In Windows 8 Consumer Preview, you will notice that animations are an integral part of the user experience. When you log in to your PC, the items in the Start menu animate in. When you launch an immersive app or zoom into the Start menu, the experience is enriched with a smooth animation. Animations can tell the user what happened as a result of a specific action. This visual feedback instills user confidence in the app’s responsiveness. Even a simple addition or deletion of an item in a list can be made fluid, modern, and informative using a subtle animation (as seen in&#160; <a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/BPS-1004" target="_blank">Jensen Harris’s //build/ session</a>, around minute 25:00).</p>
<p>This short video demonstrates UI enriched with smooth animations. </p>
<p align="center"><video poster="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-51-31/3108.Fast-and-fluid-animation-sample.jpg" controls="controls" width="480" height="270"><source src="http://media.ch9.ms/ch9/659d/0fc45493-3b60-4a49-82c5-014fe8f8659d/FastAndFluid.mp4"></source><span style="color: rgb(38, 8, 89); font-size: 1.15em;"><strong>Your browser doesn&#8217;t support HTML5 video. </strong></span></video>    <br /><span><em>Download this video to view it in your favorite media player: </em>      <br /><a href="http://media.ch9.ms/ch9/659d/0fc45493-3b60-4a49-82c5-014fe8f8659d/FastAndFluid_high.mp4">High quality MP4</a> | <a href="http://media.ch9.ms/ch9/659d/0fc45493-3b60-4a49-82c5-014fe8f8659d/FastAndFluid.mp4">Lower quality MP4</a></span></p>
<p>In Windows 8, animations are a key component of the Metro style personality and you can bring this personality to your own apps!</p>
<p>Here is what’s in this blog post:</p>
<ol>
<li>A brief overview of the animation engine</li>
<li>How to get started using the Animation Library</li>
<li>Custom animations and how to take advantage of the animation engine improvements</li>
<li>Tips ‘n tricks for incorporating animations in your Metro style apps.</li>
</ol>
<h3>Independent animation</h3>
<p>A big part of the Windows 8 experience is smooth and glitch-free animations, which are achieved through a capability called independent animation. An <i>independent animation</i> is an animation that runs independently from thread running the core UI logic. (A <i>dependent animation</i> runs on the UI thread.) In Windows 8 many of the animated elements are composed by a composition engine that runs on a separate thread. The engine’s work is offloaded from the CPU to the GPU. Moving composition to a non-UI thread means that the animation won’t jitter or be blocked by the app working on the UI thread (such as JavaScript code execution or sync operations). The GPU hardware is optimized for delivering visually rich graphics and makes use of video memory resources. Using the GPU greatly improves performance, allowing animations to run at a smooth and consistent frame rate. </p>
<p>You don’t need additional markup to make your animation take advantage of the independent animation capability. The system determines when it is possible to compose the animation independently. To make animations in your apps performant and smooth, you need to follow the independent <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh849087.aspx" target="_blank">animation guidelines</a> in the Dev Center. These guidelines are most useful when creating custom animations, which we&#8217;ll dive into later in this post. </p>
<p>Now, let’s get started with learning how you can enhance your apps by first making use of the metro-style animations that are provided in the Animation Library.</p>
<h3>Animation Library</h3>
<p>The <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465165.aspx" target="_blank">Animation Library</a> is a suite of Metro style animations that has been built specifically to take advantage of the platform’s independent animation capability. These animations are used throughout Windows UI and are also available for your Metro app. Think of this library as providing a palette of animations that do the right thing for you and are already designed to be fast and fluid.</p>
<p>As app developers ourselves, we love this feature because we don’t have to spend time creating animations that have the Windows 8 look and feel. Simply use the Animation Library and your app now is part of the Windows experience. </p>
<p>This library animates the Windows UI itself. These animations are clean and purposeful. We put a lot of attention into getting the timing and animation curves exactly right so that the user gets fast and fluid feedback when they interact with the Windows UI. So when designing animations in your app, we recommend that you first look at the Animation Library to find the best animation that fits your need. </p>
<p>It doesn’t matter if you are using HTML or XAML, the Animation Library provides you with a way to use the right animations and ensures that your UI will be fast and fluid. Let’s look at some examples.</p>
<h4>JavaScript example</h4>
<p>The JavaScript/HTML Personality Library is built with CSS3 animations and transitions. These animations are used for app navigation, content transitions and Windows 8 controls. </p>
<p>A simple yet compelling animation is the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/br212672.aspx" target="_blank">EnterPage animation</a>. Use it when displaying content for the first time or transitioning between pages in a running app. </p>
<p>This example demonstrates how you can use this simple API in your app. </p>
<h4>HTML</h4>
<blockquote><div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />      <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">div</span> <span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">=&quot;input&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />         Some content here<br />      <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">div</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />      <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">button</span> <span style="color: rgb(255, 0, 0);">onclick</span><span style="color: rgb(0, 0, 255);">=&quot;runAnimation()&quot;</span>, <span style="color: rgb(255, 0, 0);">Run</span> <span style="color: rgb(255, 0, 0);">animation</span>&amp;<span style="color: rgb(255, 0, 0);">lt</span>;/<span style="color: rgb(255, 0, 0);">button</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
<p>    <strong></strong></div>
</blockquote>
<h4>CSS</h4>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">style</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   #input<br />   {<br />      background-color:blue;<br />   }<br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">style</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
</p></div>
</blockquote>
<h4>JavaScript</h4>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">&lt;script&gt;       <br />   <span style="color: rgb(0, 0, 255);">function</span> runAnimation(){<br />      enterPage = WinJS.UI.Animation.enterPage(input);<br />   }<br />&lt;/script&gt;</pre>
</p></div>
</blockquote>
<h4>XAML example</h4>
<p>In XAML, the built-in Animation Library entails two concepts: Theme transitions and theme animations.</p>
<p><b>Theme transitions</b> are typically used to animate visuals on the screen as they are loading, unloading or changing location on the screen. XAML layout system triggers these built-in animations in response to changes in the layout of the page.</p>
<p>These layout triggers include:</p>
<ol>
<li>Adding a UIElement to the page or visual tree.</li>
<li>Removing a UIElement from the page or visual tree.</li>
<li>Updating the layout properties of an existing UIElement on the page or visual tree that causes its location or size to be updated.</li>
</ol>
<p>A particular theme transition may respond to any or all of the layout triggers. The <b>EntranceThemeTransition</b> responds to trigger #1 and animates UIElements as they are added to the page or visual tree. In the next example, all of Grid’s children are animated using <b>EntranceThemeTransition</b>.</p>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid.ChildrenTransitions</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">TransitionCollection</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />            <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">EntranceThemeTransition</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">TransitionCollection</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid.ChildrenTransitions</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br />    <span style="color: rgb(0, 128, 0);">&lt;!-- Grid's children go here --&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
</p></div>
</blockquote>
<p><b>Theme animations</b> are built-in animations that are typically run on user interaction and you must trigger them to run. The easiest way to run a theme animation is to call the <b>Begin</b> method on <b>Storyboard</b> class. If you are familiar with the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.visualstatemanager.aspx" target="_blank">VisualStateManager</a> (VSM), a theme animation can be put inside a visual state of a control. This example shows how to trigger a theme animation using the <b>Begin</b> method:</p>
<h4>XAML</h4>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;{StaticResource ApplicationPageBackgroundBrush}&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Storyboard</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;downAnimation&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />            <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">TapDownThemeAnimation</span> <span style="color: rgb(255, 0, 0);">TargetName</span><span style="color: rgb(0, 0, 255);">=&quot;rectangle&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Storyboard</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Storyboard</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;upAnimation&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />            <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">TapUpThemeAnimation</span> <span style="color: rgb(255, 0, 0);">TargetName</span><span style="color: rgb(0, 0, 255);">=&quot;rectangle&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Storyboard</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Rectangle</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;rectangle&quot;</span> <br />                <span style="color: rgb(255, 0, 0);">PointerPressed</span><span style="color: rgb(0, 0, 255);">=&quot;Rectangle_PointerPressed&quot;</span> <br />                <span style="color: rgb(255, 0, 0);">PointerReleased</span><span style="color: rgb(0, 0, 255);">=&quot;rectangle_PointerReleased&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
</p></div>
</blockquote>
<h4>Code</h4>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><br />private void Rectangle_PointerPressed(object sender, PointerEventArgs e)<br />{<br />    downAnimation.Begin();<br />}<br /><br />private void rectangle_PointerReleased(object sender, PointerEventArgs e)<br />{<br />    upAnimation.Begin();<br />}</pre>
</p></div>
</blockquote>
<h3>Custom animations</h3>
<p>As powerful as the Animation Library is, it can’t cover all your scenarios. For such cases, you can build your own custom animations that the system runs independently (see <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh849087.aspx" target="_blank">Animating</a> for design guidance on building your own animations). This is where you need to be more careful about how to build an animation so that it doesn’t end up running on the UI thread. </p>
<p>You can still use dependent animations in your app. We encourage you to follow the independent animation guidance for custom animations but if your scenario requires animations that cannot be independently animated then the animation can still be run dependently. </p>
<p>The examples here demonstrate the use of a 3D non-affine independent animation that is not in the Animation Library.</p>
<h4>JavaScript </h4>
<p>For JavaScript apps, you can access the independent animation capability for custom animations via the CSS3 <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh441191.aspx" target="_blank">Animation</a> and <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh453384.aspx" target="_blank">Transition</a> syntax newly introduced to the Microsoft web platform in IE10. Independent animation supports only properties that don’t require re-layout or re-rendering. That means, independent animation for JavaScript apps is applicable to and supported only for CSS Animations/Transitions that target CSS3 2D and 3D <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh453377.aspx" target="_blank">Transforms</a> or <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff972268.aspx" target="_blank">Opacity</a>. Animations of other CSS properties run dependently on the UI thread.</p>
<h4>Example of HTML custom animation</h4>
<p>The example here demonstrates a simple CSS 3D flip. </p>
<h4>HTML</h4>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />      <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">&gt;</span>Html animations CSS3<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />      <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">div</span> <span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">=&quot;parent&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />         <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">div</span> <span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">=&quot;box&quot;</span> <span style="color: rgb(255, 0, 0);">onclick</span><span style="color: rgb(0, 0, 255);">=&quot;className='move'&quot;</span> <span style="color: rgb(0, 0, 255);">&gt;</span>Click me for CSS Change!<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">div</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />      <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">div</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
</p></div>
</blockquote>
<h4>CSS</h4>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">style</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />   body<br />   { <br />      background-color:gray; <br />   }<br />   #box<br />   {<br />      position: relative;        <br />      background-color:green;<br />      width:300px;<br />      height:300px<br />   }<br />   <br />   #box.move<br />   {<br />      -ms-transition-property: -ms-transform;<br />      -ms-transition-duration: 1s;<br />      -ms-transition-timing-function: ease-in;    <br />      -ms-transform: rotateY(-180deg);<br />      -ms-transform-origin: 50% 50%;    <br />   }<br /><br />   #parent{-ms-perspective: 600px;}<br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">style</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
</p></div>
</blockquote>
<h4>XAML</h4>
<p>For XAML apps, a specific subset of properties are supported independently (you can find more info in the Windows 8 Developer Center). These properties include canvas positioning, opacity, render transforms, projections, clips and color. </p>
<p>Animating any property, besides the list we just looked at, results in a dependent animation. Meaning, the animation runs on the UI thread and thus will be at a risk of glitching. To encourage the development of fast and fluid UI XAML runs only independent animations unless you explicitly enable dependent animations. If you want to run a dependent animation, you can use the <b>EnableDependentAnimation</b> property on Timeline. There’s also a global static <b>AllowDependentAnimations</b> property that you can set to false to disable all dependent animations in your app.</p>
<h4>Example of a XAML custom animation</h4>
<p>The next example shows how to animate properties on <b>PlaneProjection</b> that the system runs independently. The animation concepts and syntax are exactly the same as in other XAML technologies but have been enhanced in Windows 8 to run independently, resulting in better performance characteristics for apps.</p>
<blockquote>
<div>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Storyboard</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;customAnimation&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />            <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">DoubleAnimation</span> <span style="color: rgb(255, 0, 0);">Storyboard</span>.<span style="color: rgb(255, 0, 0);">TargetProperty</span><span style="color: rgb(0, 0, 255);">=&quot;RotationY&quot;</span> <span style="color: rgb(255, 0, 0);">Storyboard</span>.<span style="color: rgb(255, 0, 0);">TargetName</span><span style="color: rgb(0, 0, 255);">=&quot;projection&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Duration</span><span style="color: rgb(0, 0, 255);">=&quot;0:0:1&quot;</span> <span style="color: rgb(255, 0, 0);">To</span><span style="color: rgb(0, 0, 255);">=&quot;-180&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Storyboard</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid.Resources</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <br />    <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Red&quot;</span> <span style="color: rgb(255, 0, 0);">Height</span><span style="color: rgb(0, 0, 255);">=&quot;400&quot;</span> <span style="color: rgb(255, 0, 0);">Width</span><span style="color: rgb(0, 0, 255);">=&quot;600&quot;</span> <span style="color: rgb(255, 0, 0);">PointerPressed</span><span style="color: rgb(0, 0, 255);">=&quot;Grid_PointerPressed&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid.Projection</span><span style="color: rgb(0, 0, 255);">&gt;</span><br />            <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlaneProjection</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;projection&quot;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><br />        <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid.Projection</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><br />        <span style="color: rgb(0, 128, 0);">&lt;!-- Grid's children go here --&gt;</span><br /><br />    <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">Grid</span><span style="color: rgb(0, 0, 255);">&gt;</span><br /></pre>
</p></div>
</blockquote>
<div>&#160;</div>
<blockquote>
<div id="codeSnippetWrapper">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet"><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">void</span> Grid_PointerPressed(<span style="color: rgb(0, 0, 255);">object</span> sender, PointerEventArgs e)<br />{<br />    customAnimation.Begin();<br />}</pre>
</p></div>
</blockquote>
<h3>Best practices for independent animations</h3>
<p>As with all systems, there are some limitations for independent animation. These limitations are different for the HTML and XAML platforms. In general you get independent animations except for these cases:</p>
<ol>
<li><b>Animating property that affects layout: </b>These properties, such as CSS Width, trigger re-layout and are not supported independently.</li>
<li><b>State of the animating element doesn’t follow independent animation guidelines: </b>Independent animations that don’t follow the guidelines (see <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh849087.aspx">Animating</a> post) are not supported by the system.</li>
<li><b>Insufficient system resources</b>: If the system doesn’t have sufficient resources (e.g. Video memory) then the animation falls back to dependent composition. </li>
</ol>
<p>Here are a few guidelines for independent animations.</p>
<h4>JavaScript</h4>
<ol>
<li><b>Avoid infinite animation</b>: When using independent animations, the GPU is allocating video memory. In CSS it is possible to specify <i>–ms-iteration-count: infinite</i>. When you set this property value, the specified animation will continue to run forever. This means your app holds on to the animating element’s video memory until you stop the animation. To stop an infinite animation, you can remove the <i>–ms-animation-name </i>value or change the animating element’s display property to be <i>display: none</i>.
<p></li>
<li><b>Don’t toggle the CSS Visibility property: </b>When you set an independent animating element to <i>visibility: hidden </i>and then back to <i>visibility: visible</i>, this element is no longer independent. The animation continues but now it is composed on the UI thread. <i> </i></li>
<li>
<div>
<p><b>Place independent animating elements on top: </b>Because independent composition uses your GPU, there is a limit to how much your system can compose independently. If your independent animation is behind other UI elements, those UI elements on top will also be composed independently. By doing this you are unnecessarily consuming video memory.<b> </b>To avoid this problem, make sure to have all independent animations on top of all other UI elements<b>. </b>If your independent animation is very low in the stack, it is at risk of falling back to a dependent animation.</p>
<p>You can have your independent animations on top by: <b></b></p>
<ul>
<li>Giving your independent animating elements a high z-index.<b></b></li>
<li>Using non-negative z-indexes for independently animating elements. <b></b></li>
<li>Not overlapping your independent animation with other elements. <b></b></li>
</ul></div>
</li>
<li><b>Don’t use large surfaces and too many independent animations: </b>Similar to making placing your independent animation on top, be aware of how big your animating element is and how many you are animating at one time. Independent animations are limited by the system’s GPU. If you go beyond this limit, your animations fall back to the dependent UI thread. If you are noticing your animations not being smooth, you can use the <b>IsIndependentlyComposed</b><i> </i>API to query your element.
<p><b></b></li>
<li><b>Use IsIndependentlyComposed API: </b>You can use this API to determine if an HTML element is being composed independently from the UI thread. This property will return true for independentl animating elements, subscrollers and elements that overlap and independently animating element. </li>
</ol>
<h4>XAML</h4>
<ol>
<li><b>Scale the elements for Height and Width animations</b>: Animating <b>Height</b> and/or <b>Width</b> properties of <b>UIElement</b> results in a dependent animation because these properties require layout changes which can only be done on the UI thread. To have a similar effect of animating <b>Height</b> or <b>Width</b>, you can animate the Scale of the control. <b>ScaleTransform</b> are animated independently, this approach provides for a better frame rate.</li>
<li><b>Don’t animate cache content</b>: If you set the <b>CacheMode</b> property (<b>UIElement.CacheMode</b>) of an element to <b>BitmapCache</b>, then all animations in the visual sub-tree are run dependently. This is because we have to recreate the entire cache in every frame. The solution is to simply not animate cached content.</li>
<li><b>Don’t use infinite animations of Progress controls:</b> <b>ProgressRing</b> and <b>ProgressBar</b> have infinite animations that can continue on running even if the control is not visible in the page, which may prevent the CPU from going into low power or idle mode. We recommend that you set <b>ProgressRing.IsActive</b> and <b>ProgressBar.IsIndeterminate</b> properties to false when you’re not showing the respective controls.</li>
</ol>
<h3>In closing</h3>
<p>We are excited about the fast and fluid user experiences that independent animation enables for Windows 8 apps. We hope that you find the Animation Library and the support for custom animations that run independently of the UI thread useful when you create compelling user experiences in your Metro style apps for Windows 8.</p>
<p>&#8211; Angelina Gambo and Hamid Mahmood<br />
  <br />&#160;&#160;&#160; Program Managers, Windows</p>
<div style="clear:both;"></div>
<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=10299422" width="1" height="1"><br />
<a rel="nofollow" href="http://blogs.msdn.com/b/windowsappdev/archive/2012/05/01/fast-and-fluid-animations-in-your-metro-style-app.aspx">Windows 8 app developer blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.windows8tricks.net/2012/05/fast-and-fluid-animations-in-your-metro-style-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://media.ch9.ms/ch9/659d/0fc45493-3b60-4a49-82c5-014fe8f8659d/FastAndFluid.mp4" length="566387" type="video/mp4" />
<enclosure url="http://media.ch9.ms/ch9/659d/0fc45493-3b60-4a49-82c5-014fe8f8659d/FastAndFluid_high.mp4" length="1711357" type="video/mp4" />
		</item>
	</channel>
</rss>
