<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>top-silverlight</title>
	
	<link>http://www.top-silverlight.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 27 Apr 2012 12:37:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Top-silverlight" /><feedburner:info uri="top-silverlight" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Develop your app for everyone–localize your UI</title>
		<link>http://www.top-silverlight.com/2012/04/27/develop-your-app-for-everyonelocalize-your-ui.html</link>
		<comments>http://www.top-silverlight.com/2012/04/27/develop-your-app-for-everyonelocalize-your-ui.html#comments</comments>
		<pubDate>Fri, 27 Apr 2012 12:37:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/04/27/develop-your-app-for-everyonelocalize-your-ui.html</guid>
		<description><![CDATA[Being more involved in the engineering process of a product I had the chance to participate in the design of various features instead of just the ones that I’m responsible for delivering.  One of those areas was the way we would enable developers to produce localized applications.  Before this process I have to be honest [...]]]></description>
			<content:encoded><![CDATA[<p>Being more involved in the engineering process of a product I had the chance to participate in the design of various features instead of just the ones that I’m responsible for delivering.  One of those areas was the way we would enable developers to produce localized applications.  Before this process I have to be honest and as an app developer never really paid much attention to providing localized versions of any app that I wrote.  I had absolutely no good reason for coming to that decision, just never bothered.  In helping to design and understand localization a bit more I can say that it is easy to do this in your app and there shouldn’t be any excuse for any app developer to create their application in a way to make it localized at any given moment.  Note I didn’t say localized immediately, but rather I mean to create your app in a way that would make it easy to provide a localized version in a fairly quick turnaround.</p>
<p>As I do some app development for Windows 8 I wanted to share my thoughts around localization and what it really means to me to provide a ‘world-ready’ application.  The three areas of focus are 1) how the platforms support a localized app, 2) what technical tools you have to automate localization 3) getting culture-correct localization and 4) testing your localized app.</p>
<h2>Platform support for localization</h2>
<p>The first thing you have to understand is how the platform you are targeting enables support for your app to easily be localized.  This may be in how you organize your content, how you name certain things, and how you write code.  For most platforms there is a pretty predictable method of doing this.  I would argue not all platforms make this extremely intuitive, but also state that inferring how (and what) you want to localize your app isn’t something a platform can predict well for every app.  It is important for the app developer to <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465405.aspx">plan for a global market</a> and fully understand the models before writing a line of code to understand how to make the app localized more easily later in the process.</p>
<p>For Windows 8, a new resource model is introduced for WinRT that is common across the entire platform regardless of the UI framework choice.  The areas you should understand are <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.resources.aspx"><strong>Windows.ApplicationModel.Resources</strong></a> and <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.resources.core.aspx"><strong>Windows.ApplicationModel.Resources.Core</strong></a>.  These two areas are where most Windows 8 developers will spend most of their time with regard to localization of UI strings (and other content).  For most, the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.resources.resourceloader.getstring.aspx">GetString()</a> method is probably where you’ll spend your time when using code.  String values are indexed during the build process of your application.  Your strings will either reside in a RESJSON (for HTML/JS) or RESW (for XAML) file.  Both of these are essentially name/value collections for your strings.  An example of the process of naming and managing your string resources can be found here: <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465248.aspx">How to manage string resources</a>.</p>
<blockquote><p><strong>NOTE:</strong> Yes the Consumer Preview version of that documentation shows only Javascript right now, but will be updated.  The naming conventions are the same.</p>
</blockquote>
<p>In XAML we created a new way to do XAML UI localization in your markup, by moving some functionality into the platform for you.  Previously in platforms like Silverlight people used <a href="http://timheuer.com/blog/archive/2009/08/26/silverlight-string-localization.aspx">techniques like data binding</a> to accomplish the mapping from the RESX-generated class to the UI.  Because the indexing of the string resources changed a bit (i.e., currently no strongly-typed resource class representation), we wanted to have the platform do some more heavy lifting for you.  We already load the index file (resources.pri) automatically during load of the app, so we’re aware of the resources and all the context the app may have (i.e., what locale, screen resolution, etc.).  Because of this we enabled a markup mechanism in XAML for you to provide easy string localization.  Let’s use a simple example of a TextBlock that you might have a static string:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>TextBlock</span> <span>x:Uid</span><span>="MyTextBlock"</span> <span>FontSize</span><span>="24.667"</span> <span>Text</span><span>="Design Placeholder"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Notice the x:Uid value here.  This now maps back to the key in your RESW file.  Anything with that starting key will have properties merged into it.  So we can have a key in our RESW for “Text” using the key name <em>MyTextBlock.Text</em> with a value of “Hello World” and the runtime will do the replacement for you.  This applies to properties other than text (i.e. width) as well as attached properties.  While we think this is a great new method, it may not work for everyone’s situations and you still have control over retrieving strings using the Windows.ApplicationModel.Resources WinRT APIs.  You can read more about this method with some examples here: <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh771181.aspx"><strong>QuickStart: Make your Metro style app world ready</strong></a> and an SDK Sample here: <a href="http://code.msdn.microsoft.com/windowsapps/Application-resources-and-cd0c6eaa">Application Resources</a>.</p>
<h2>Tools to help with localizing content</h2>
<p>Once you have understood what your platform provides and you have taken the effort to prepare your app for easy localization, the next step is to actually use tools/process to perform the localization.  I’ve come across a few tools that I think are helpful for XAML developers who are ‘small shops’ and don’t have an existing process for app localization.</p>
<p>The easiest thing for a developer to do is to use machine translation using automated services.  There are a few tools out there that I think can be helpful for this method.  It is important to note we are talking about machine translation here…I will get to that point later on in the post.</p>
<p><strong>RESX Translator with Bing</strong></p>
<p>Since the RESW format is identical with RESW (restriction is that RESW only supports string values currently), you can use a lot of existing RESX tools.  There is a <a href="http://resxtranslatorbing.codeplex.com/"><strong>RESX Translator with Bing</strong> project on CodePlex</a> that was done by Microsoft UK Consulting Services.  This allows you to select a file and source language and translate to any language that Microsoft Translator supports.  </p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="RESX Translator with Bing" src="http://storage2.timheuer.com/bingtranslator.png" /></p>
<p>Since the current project supports (and only loads) .resx files, I had submitted some patch files to quickly make it support the .resw file extension.  The contributor hasn’t accepted these patches, but you can <a href="http://resxtranslatorbing.codeplex.com/SourceControl/list/patches">find them on the patches section for the project</a>.</p>
<p><strong>Multilingual App Toolkit</strong></p>
<p>Released with the Visual Studio 11 Beta, the <a href="http://msdn.microsoft.com/en-us/windows/apps/hh848309"><strong>Multilingual App Toolkit</strong></a> from Microsoft provides an integrated method for generating resources for your app.  One of the benefits of this app is that it produces some standards-based files that are used to send to localizers and can be used in other tools.  This includes the TPX and <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xliff"><strong>XLIFF</strong></a> file formats.  Once installed the tool is integrated within visual studio and your flow would be something like the following.</p>
<p>First you’d have your app and an initial RESW file containing your default language (in my case en-US) resources.  Once I have that I can right-click on the project and choose <em>Add translation languages</em> and when doing so, launches:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Add translation language dialog" src="http://storage2.timheuer.com/mltranslist.png" /></p>
<p>which I can select the languages I would prefer.  Notice the translator icon next to some of them indicating that these could be machine-translated.  Once you select the languages you want, you’ll see a folder within your app that contains the configuration information:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Multilingual resources folder" src="http://storage2.timheuer.com/mlfolder.png" /></p>
<p>Now if you open the XLF files you’ll basically see some XML that contains configuration information but initially won’t see any of your string values.  You need to do a build to populate those files.  After building you’ll see the XLF files regenerated with the keys to be localized:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;?</span><span>xml</span> <span>version</span><span>="1.0"</span> <span>encoding</span><span>="utf-8"</span>?<span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> <span>&lt;</span><span>xliff</span> <span>version</span><span>="1.2"</span> <span>xmlns</span><span>="urn:oasis:names:tc:xliff:document:1.2"</span> <span>xmlns:xsi</span><span>="http://www.w3.org/2001/XMLSchema-instance"</span> <span>xsi:schemaLocation</span><span>="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>   <span>&lt;</span><span>file</span> <span>datatype</span><span>="xml"</span> <span>source-language</span><span>="en-US"</span> <span>target-language</span><span>="de-DE"</span> <span>original</span><span>="LocTesting_Multilingual.prilog.xml"</span> <span>tool-id</span><span>="MAT"</span> <span>product-name</span><span>="LocTesting"</span> <span>product-version</span><span>="Version 1"</span> <span>build-num</span><span>="1.0.0.0"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     <span>&lt;</span><span>header</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>       <span>&lt;</span><span>tool</span> <span>tool-id</span><span>="MAT"</span> <span>tool-name</span><span>="Multilingual App Toolkit"</span> <span>tool-version</span><span>="1.0"</span> <span>tool-company</span><span>="Microsoft"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     <span>&lt;/</span><span>header</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>&lt;</span><span>body</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>       <span>&lt;</span><span>group</span> <span>id</span><span>="Resources"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>         <span>&lt;</span><span>trans-unit</span> <span>id</span><span>="Resources\SomeTextBlock\Text"</span> <span>translate</span><span>="yes"</span> <span>xml:space</span><span>="preserve"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>           <span>&lt;</span><span>source</span><span>&gt;</span>Good morning!  Have a nice day!<span>&lt;/</span><span>source</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>           <span>&lt;</span><span>target</span> <span>state</span><span>="new"</span><span>&gt;</span>Good morning!  Have a nice day!<span>&lt;/</span><span>target</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>         <span>&lt;/</span><span>trans-unit</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>         <span>&lt;</span><span>trans-unit</span> <span>id</span><span>="Resources\SomeButton\Content"</span> <span>translate</span><span>="yes"</span> <span>xml:space</span><span>="preserve"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  14:</span>           <span>&lt;</span><span>source</span><span>&gt;</span>Click to Save<span>&lt;/</span><span>source</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  15:</span>           <span>&lt;</span><span>target</span> <span>state</span><span>="new"</span><span>&gt;</span>Click to Save<span>&lt;/</span><span>target</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  16:</span>         <span>&lt;/</span><span>trans-unit</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  17:</span>       <span>&lt;/</span><span>group</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  18:</span>     <span>&lt;/</span><span>body</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  19:</span>   <span>&lt;/</span><span>file</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  20:</span> <span>&lt;/</span><span>xliff</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Now you send those off for translation by right-clicking on the XLF file and choosing <em>Send for translation</em> which will give you a dialog to choose if you want to mail them or save to a folder and which format (TPX/XLIFF).  At this point your translation process can begin.  If you don’t have a translation process where you would normally send the XLIFF files, you can use the <strong>MAT Localization Editor</strong> that is installed with the toolkit.  Launching this tool and opening your XLIFF file will allow you (or the person doing translations) to edit the files with the correct value.  The MAT editor also has the Microsoft Translator capability as well.  Here’s an example of the above German file in the editor with one value translated by the Microsoft Translator:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="MAT Localization Editor" src="http://storage2.timheuer.com/mateditor.png" /></p>
<p>Once you have the edited XLIFF file you import that back into your project.  Notice there are some other workflow-related properties in the XLIFF (i.e., Signed off, ready for review, etc.) that you can enforce.  Right-click on the XLF file in your project and choose <em>Import translation</em> and the XLIFF file that was modified.  Once imported, when I build next the signed-off items will be indexed within my app’s resource lookup (resources.pri) and packaged.  You will not see any new RESW files generated as using this process does the indexing during the build process with the XLF file and a build task.</p>
<p><strong>Amanuens</strong></p>
<p>Another tool that I’ve come across is <a href="http://www.amanuens.com"><strong>Amanuens</strong></a>, which is more of a service/tool than anything that integrates into Visual Studio or runs on your machine.  This service acts as a broker to translators.  You basically create a project and then upload files to be localized.  After you login and create a project (specifying the type as Metro as they now <a href="http://blog.amanuens.com/2012/03/06/support-for-windows-metro-resource-files/">support Windows 8 application file types</a>) then you upload your “master” RESW/RESJSON file.  After doing that you can assign a translation and this is the core of their service.  You can assign a file for translation to a person that is a user on the system as you may have a German speaking friend who might help you out.  Or you can assign to an agency and get a quote:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Amanuens agency service" src="http://storage2.timheuer.com/amanuensagency.png" /></p>
<p>This way you can send it off and wait.  Either way when the translation comes back you just download the file, put it in your project in the appropriate folder and rebuild your app.  Amanuens is a <a href="http://amanuens.com/pricing">pay service</a> with a free option, but if you have an app and want to manage the workflow of that process, it seems like a pretty cool service.  They also have automatic source control synchronization that you can opt-in for so as your translations come in, they are automatically in your app via a repo sync.</p>
<h2 />
<h2>Culture-correct localization</h2>
<p>While all the above tools are awesome and fast to get you started, to build a really targeted localized app it is highly recommended you do more than machine translation, or at a minimum verify that machine translation.  Many times, especially for east Asian languages, the machine translation can be grammatically incorrect or sometimes culturally insensitive as most do dictionary-based translation rather than really understanding any context.</p>
<p>I recall a time in high school where a classmate went to Germany for exchange.  Having taken 6 semesters of German she felt pretty confident in her skills.  Little did she know her hoch Deutsch would prove to be a problem.  Upon arrival she went to a café with some friends and proclaimed she was hot.  However, her dictionary translation was bad and she effectively said “I’m horny” which immediately caught the attention of all the men in the room.  So it is key to understand context and culture when translating!</p>
<p>For this services like Amanuens really help out in both the flow and identifying a person to do the translation.  If you don’t know anyone who speaks Swedish, but want to target that market, using a service could help you get more culturally-correct translations for your app over <em>just</em> machine translation.  This, of course, does not come without a cost, but usually it is minimal and is a one-time translation.</p>
<p>One thing I’d love to see happen is somewhat of a co-op of software developers from around the world to offer translation help.  Working at Microsoft I had the chance to get correct translations of my Sudoku app for German, Japanese, Korean and French.  It was helpful to just send off the RESW file and get back the translation from a human who speaks the language and understands technology terms as well.  A service like Amanuens can help facilitate that co-op having a bank of users that are willing to donate their translation services for your project.  I think the struggle is that it is mostly English apps that need the help and hard for an English person to really reciprocate the value.  But if you are willing to help out other software developers perhaps we can start this co-op idea?</p>
<h2>Testing your localized app</h2>
<p>[!!_Śò ẃĥâт đõ Уôú ďó įƒ ўôú đõи'ť ћãνê тŕáйşłâţêď ţę×т ýęţ áйď ẅàήт тó тęšť ÿòµѓ ãрρ?_!!!!!!!!!!!!!!!!!!!!!!!!]</p>
<p>Could you read that?  Squint a little more.  It is what we call Pseudo Language.  Not a ‘real’ language but something that simulates a lot of different characteristics of localized language challenges.  Using the Multilingual Toolkit you can have all your strings translated to this Pseudo Language (sometimes called “ploc” within the walls of Microsoft) to test your app before your real language translations come in.  Using ploc helps you identify various artifacts that may exist in localizing an app.  Let’s take a simple example from above.  We had a button that said “Click to Save” in English and we translated it to German.  When rendered it would look like this respectively:</p>
<p><img src="http://storage2.timheuer.com/buttonen.png" /> <img src="http://storage2.timheuer.com/buttonde.png" /></p>
<p>Notice that the German translation didn’t fit within the Button MaxWidth we had set because the translation of the text was longer than our English version.  Testing this is important for us to realize we need to change the constraint of the XAML sizes to accommodate our languages that we are targeting.</p>
<p>Historically testing localized versions of apps may have been challenging requiring you to install a language pack, try to navigate menus that you may not understand, or relying on others to verify for you.  In Windows 8, this process has become easier using the language list preferences.  The Building Windows 8 blog had a post called “<strong><a href="http://blogs.msdn.com/b/b8/archive/2012/02/21/using-the-language-you-want.aspx">Using the language you want</a></strong>” which talks about this concept in detail.  </p>
<blockquote>
<p><strong>NOTE:</strong> If using the Pseudo Language option and you want to test, when in the Language panel search for “qps-ploc” and you’ll see it under English (qps-ploc) as an option and then you can really test the boundaries of your app with the ploc strings!</p>
</blockquote>
<p>Effectively as a developer I can go into the Language panel, add German, set it as my first language and run my app.  Now I’ll get my German resources first and I can visible verify things that need to be changed without installing any language pack on my machine…and I can quickly change back without any reboots.</p>
<h2>Summary</h2>
<p>Developing your application to be world-ready doesn’t have to be a huge undertaking and can turn out not to be difficult at all for your app.  While not every app is going to be the same and how you choose to architect your code may dictate <strong>how</strong> you get your resources, the concepts are still the same and starting with the mindset that your app may be localized at some point is the right thing to do.  Using RESW/RESJSON from the start and understanding the options you have for extracting those resources will make localization later very easy…in fact in some cases as easy as just putting in the updated RESW file and recompiling.</p>
<p>Start smart from the beginning and think global even if you aren’t ready for it just yet.  You never know when your German friend might help out translating for you and then you can instantly expand to that market within a day!</p>
<p>Hope this helps!</p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/winrt/default.aspx" rel="tag">winrt</a>, <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/localization/default.aspx" rel="tag">localization</a>, <a href="http://timheuer.com/blog/Tags/xliff/default.aspx" rel="tag">xliff</a>, <a href="http://timheuer.com/blog/Tags/translator/default.aspx" rel="tag">translator</a>, <a href="http://timheuer.com/blog/Tags/globalization/default.aspx" rel="tag">globalization</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14836.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/_YifJibItKigoXJ1FoaBnbH3qGQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/_YifJibItKigoXJ1FoaBnbH3qGQ/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/_YifJibItKigoXJ1FoaBnbH3qGQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/_YifJibItKigoXJ1FoaBnbH3qGQ/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/oa8sktFJiSg" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/04/27/develop-your-app-for-everyonelocalize-your-ui.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Metro app development hidden gem: anonymous type binding</title>
		<link>http://www.top-silverlight.com/2012/04/12/metro-app-development-hidden-gem-anonymous-type-binding.html</link>
		<comments>http://www.top-silverlight.com/2012/04/12/metro-app-development-hidden-gem-anonymous-type-binding.html#comments</comments>
		<pubDate>Thu, 12 Apr 2012 02:16:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/04/12/metro-app-development-hidden-gem-anonymous-type-binding.html</guid>
		<description><![CDATA[Just a little post to point out a hidden gem if you are a .NET developer creating a Metro style app: you can bind to anonymous types.  This came up in a discussion with a customer today that I was having and, frankly, I never tried it until then because my mind was back in [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little post to point out a hidden gem if you are a .NET developer creating a Metro style app: you can bind to anonymous types.  This came up in a discussion with a customer today that I was having and, frankly, I never tried it until then because my mind was back in Silverlight where this isn’t possible.  There may not be a tone of cases where this is valuable for you, but knowing it is there may help.</p>
<p>Let’s assume I have a basic class Person:</p>
<div>
<div>
<pre><span>   1:</span> <span>public</span> <span>class</span> Person</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>public</span> <span>int</span> Age { get; set; }</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     <span>public</span> <span>string</span> FirstName { get; set; }</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     <span>public</span> <span>string</span> Gender { get; set; }</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>And in my application I have a list of that Person type that I somehow received.  In this example, I’m just hard-coding it right now. </p>
<div>
<div>
<pre><span>   1:</span> List&lt;Person&gt; people = <span>new</span> List&lt;Person&gt;();</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> people.Add(<span>new</span> Person() { Age = 38, FirstName = <span>"Tim"</span>, Gender = <span>"Male"</span> });</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span> people.Add(<span>new</span> Person() { Age = 9, FirstName = <span>"Zoe"</span>, Gender = <span>"Female"</span> });</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span> people.Add(<span>new</span> Person() { Age = 5, FirstName = <span>"Zane"</span>, Gender = <span>"Male"</span> });</pre>
<p><!--CRLF--></div>
</div>
<p>I can then decide I want to bind to a ListView control which has a particular template:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>ListView</span> <span>x:Name</span><span>="PeopleList"</span> <span>Width</span><span>="500"</span> <span>Height</span><span>="300"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>&lt;</span><span>ListView.ItemTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>         <span>&lt;</span><span>DataTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>             <span>&lt;</span><span>StackPanel</span> <span>Orientation</span><span>="Horizontal"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>                 <span>&lt;</span><span>TextBlock</span> <span>Text</span><span>="{Binding TheName}"</span> <span>Margin</span><span>="0,0,10,0"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>                 <span>&lt;</span><span>TextBlock</span> <span>Text</span><span>="{Binding GuysAge}"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>             <span>&lt;/</span><span>StackPanel</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>         <span>&lt;/</span><span>DataTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>     <span>&lt;/</span><span>ListView.ItemTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span> <span>&lt;/</span><span>ListView</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Notice that I’m binding to properties (TheName and GuysAge) that don’t exist on my Person class?  In my code, I can then create a LINQ query to filter out only the “dudes” from my list and bind that result:</p>
<div>
<div>
<pre><span>   1:</span> var onlyGuys = from g <span>in</span> people</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>                <span>where</span> g.Gender == <span>"Male"</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>                orderby g.FirstName descending</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>                select <span>new</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>                {</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>                    GuysAge = g.Age,</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>                    TheName = g.FirstName,</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>                    Gender = <span>"Dude"</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>                };</pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  11:</span> PeopleList.ItemsSource = onlyGuys;</pre>
<p><!--CRLF--></div>
</div>
<p>The result is that my ListView now shows 2 people in the list.  Nice.</p>
<h2>Get in the real world</h2>
<p>Now I would probably agree that since you already have a strongly-typed class this is probably not the use case here.  It certainly might be helpful, but you already have a class (and in this example, one that you completely control so you could shape it to be what you really need).  What about those times you don’t have a class or you don’t own the type coming back?  JSON ring a bell?  Using the sample JSON response (I’m not focusing on how to retrieve data here just how to bind to it) from Twitter APIs, we can demonstrate how this might be more helpful.  Here’s the Twitter JSON data I’m referring to in this example: <a href="https://dev.twitter.com/docs/api/1/get/statuses/mentions">Twitter Mentions API</a>.</p>
<p>My app wants to retrieve and bind to Twitter data but I don’t really want to have a “TwitterResponse” data type that I have to serialize in/out in my code.  The mention data is an array of mentions.  For the sake of simplicity I’ve basically put my JSON string in a file rather than confuse this sample in how to work with Twitter.  My code looks like this (assume that ‘data’ is the resulting Twitter mentions JSON string:</p>
<div>
<div>
<pre><span>   1:</span> <span>// parse the data into a JsonArray object</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> var mentions = JsonArray.Parse(data);</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   4:</span> <span>// build the query out of the mentions</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span> var qry = from m <span>in</span> mentions</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>           select <span>new</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>           {</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>               MentionText = m.GetObject()[<span>"text"</span>].GetString(),</pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>               FromUser = m.GetObject()[<span>"user"</span>].GetObject()[<span>"screen_name"</span>].GetString(),</pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>               ProfilePic = m.GetObject()[<span>"user"</span>].GetObject()[<span>"profile_image_url"</span>].GetString()</pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>           };</pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  13:</span> MentionData.ItemsSource = qry;</pre>
<p><!--CRLF--></div>
</div>
<p>Notice the LINQ query for creating a “new” type that I will bind to my ListView.  In my XAML I have a simple DataTemplate to demonstrate:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>ListView</span> <span>x:Name</span><span>="MentionData"</span> <span>Width</span><span>="500"</span> <span>Height</span><span>="300"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>&lt;</span><span>ListView.ItemTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>         <span>&lt;</span><span>DataTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>             <span>&lt;</span><span>StackPanel</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>                 <span>&lt;</span><span>TextBlock</span> <span>Text</span><span>="{Binding FromUser}"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>                 <span>&lt;</span><span>TextBlock</span> <span>Text</span><span>="{Binding MentionText}"</span> <span>TextWrapping</span><span>="Wrap"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>             <span>&lt;/</span><span>StackPanel</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>         <span>&lt;/</span><span>DataTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>     <span>&lt;/</span><span>ListView.ItemTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span> <span>&lt;/</span><span>ListView</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>The result is me being able to create a LINQ query and create a new anonymous type and directly bind to it.</p>
<p>Voila!  Perhaps you already discovered this little gem and are using it.  It is a welcome addition to the data binding story for Metro style app development with XAML and .NET!  Of course the same benefit can be had for XML data using XLINQ queries, so while this example is for JSON data, really any source data applies…it is all about that new anonymous type you create!</p>
<p>Hope this helps!</p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/linq/default.aspx" rel="tag">linq</a>, <a href="http://timheuer.com/blog/Tags/metro/default.aspx" rel="tag">metro</a>, <a href="http://timheuer.com/blog/Tags/win8/default.aspx" rel="tag">win8</a>, <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/anonymous/default.aspx" rel="tag">anonymous</a>, <a href="http://timheuer.com/blog/Tags/databinding/default.aspx" rel="tag">databinding</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14835.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/-pA7caVeGo7M-DaRb1OJX1i4JBo/0/da"><img src="http://feedads.g.doubleclick.net/~a/-pA7caVeGo7M-DaRb1OJX1i4JBo/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/-pA7caVeGo7M-DaRb1OJX1i4JBo/1/da"><img src="http://feedads.g.doubleclick.net/~a/-pA7caVeGo7M-DaRb1OJX1i4JBo/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/I4Oa_9-ejI4" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/04/12/metro-app-development-hidden-gem-anonymous-type-binding.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stung by Azure Data Transfer fees</title>
		<link>http://www.top-silverlight.com/2012/04/10/stung-by-azure-data-transfer-fees.html</link>
		<comments>http://www.top-silverlight.com/2012/04/10/stung-by-azure-data-transfer-fees.html#comments</comments>
		<pubDate>Tue, 10 Apr 2012 13:14:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/04/10/stung-by-azure-data-transfer-fees.html</guid>
		<description><![CDATA[I should have known better honestly.  I’ve had one strike with cloud billing catching me by surprise and I’m not sure why I’m shocked it happened again.  This time, however, I thought I really did plan it out, pay attention to things and asked what I thought were the right questions.  Unfortunately I didn’t get [...]]]></description>
			<content:encoded><![CDATA[<p>I should have known better honestly.  I’ve had one strike with cloud billing catching me by surprise and I’m not sure why I’m shocked it happened again.  This time, however, I thought I really did plan it out, pay attention to things and asked what I thought were the right questions.  Unfortunately I didn’t get the full answers.  This time I was stung by my shiny new <a href="http://timheuer.com/blog/archive/2012/02/20/migrating-existing-sql-server-to-sql-azure.aspx">SQL Azure service choice</a>.</p>
<p>A while back I heard about the change in price for some Windows Azure services and the one that piqued my interest was the SQL Azure.  At the time it hit me right as I needed to move around some of my hosting aspects of my site.  The lure of the $5/month SQL Azure database (as long as it was &lt; 100MB) was appealing to me.  The SQL server aspect of my site has always been a management headache for me as I don’t want to have to worry about growing logs, etc.</p>
<h2>Stung by marketing</h2>
<p>I followed the announcements to the <a href="http://www.windowsazure.com">http://www.windowsazure.com</a> site and read the descriptions of the services.  I was immediately convinced of the value and heck, it was a service from my company so why shouldn’t I give it a try and support it?  When I began to set it up, however, there were questions being asked during setup and I started to get concerned.  I asked around about if this $5 fee was really the only fee.  I didn’t want to get surprises by things like compute time.  Perhaps I wasn’t asking specific enough questions, but all answers I got was that signs pointed to <em>yes, that would be my only fee</em>.</p>
<blockquote><p><strong>NOTE</strong>: As of this writing yes I am a Microsoft employee, but this is my own opinion and I realize that peoples’ expectations and results vary.  This is only my experience.  I’m not only an employee but also a customer of Microsoft services and in this instance a full paying customer.  No internal benefits are used in my personal Azure hosting accounts.</p>
</blockquote>
<p>Yesterday I learned that wasn’t the case.  I received my first Azure billing statement and it was way more than I expected.  Yes my $5 database was there as expected, but also was suddenly “Data Transfer” charges of $55.</p>
<h2>Trying to make sense of billing</h2>
<p>I immediately tried to make sense of this billing.  I immediately remembered that I had created a storage account as well for a quick test and perhaps I forgot to disable/delete that service.  I logged into the management portal and saw that my storage account was properly deleted and nowhere to be seen.  But how to make sense of these charges from the past week then?  Luckily Azure provides detail usage download data so I grabbed that.  The CSV file I download did indeed provide some detail…perhaps too much as some of it I couldn’t discern, namely the one piece that I had hoped would help me: Resource ID.  This ID was a GUID that I thought pointed to a service that I used.  It did not, or at least that GUID was nowhere to be seen on my Azure management portal.</p>
<p>I contacted the billing support immediately to help.  I was able to talk with a human fairly quickly which was a plus.  The gentleman explained to me that I had a lot of outgoing data leaving the Azure data centers and that was the source of the costs.  He asked if I knew if anything was connecting to my SQL Azure instance externally.  Well, duh, yes it was my site!  He went on to explain that this constitutes “Data Transfer” and I’m billed at a per GB rate for any data that leaves the Azure data center.  </p>
<p>I took a deep breath and asked where this was documented in my SQL Azure sign-up process.  We walked through the site together and he agreed that it wasn’t clear.  After being put on hold for a while, I was assured I would receive a credit for the misunderstanding.  Unfortunately for Azure, the damage was done and they lost a customer.</p>
<h2>Where the failure occurred</h2>
<p>For me the failure was twofold: me for not fully understanding terms and Azure for not fully explaining them in context.  I say “in context” because that was the key piece that was missing in my registration of my account.  Let me explain the flow I took (as I sent this same piece of internal feedback today as well) as a customer once I heard the announcement about the SQL Azure pricing changes:</p>
<ul>
<li>I received notice of updated SQL Azure pricing</li>
<li>I visited the site <a href="http://www.windowsazure.com">http://www.windowsazure.com</a> for more information</li>
<li>I clicked the top-level “PRICING” link provided as that was my fear</li>
<li>I was presented with a fancy graphical calculator.  I moved the slider up to 100MB and confirmed the pricing on the side (no asterisks or anything)</li>
<li>I notice a “Learn more about pricing, billing and metering” link underneath the calculator and click it to learn more</li>
<li>I’m presented with a section of 10 different options all presented at the same level giving the appearance as unique services.</li>
<li>I choose the Database one and again read through and confirm the charge for the 100MB database option.</li>
<li>I click the “More about databases” link to double-verify and am presented with another detailed description of the billing</li>
</ul>
<p>Not once during that process was <strong>context</strong> provided.  Not at any of the steps above (3 different pricing screens) was there context that additional fees could also apply to any given service.  Data transfer, in fact, doesn’t even describe itself very well.  As I was assured in asking folks involved in Azure about my concern on pricing, this “Data Transfer” wasn’t brought up at all.  I’m not sure why at all it is listed along side services and almost presented as a separate service as it appears <strong>all Azure services are subject to data transfer fees</strong>.  This is not made clear during sign up nor marketing of the pricing for each service.  SQL Azure should clearly state that the fees are database *plus* any additional fees resulting from data transfer.  Heck Amazon does this with S3 which also makes it so confusing to anticipate the cost of billing there as well…but at least it is presented that I need to factor that into my calculation.</p>
<h2>I’m to blame, so why am I whining</h2>
<p>I said I’m to blame as well for not understanding better what I’m getting into.  It is unfortunate because I really did like the service and felt an assurance of more reliability with my database then I had before.  The management portal was great and the uptime and log management was something I didn’t have to think about anymore.  </p>
<p>So why, you might ask, am I complaining about a service fee for something that was providing me value?  </p>
<blockquote><p><strong>NOTE:</strong> You may ask why I didn’t just move my site within Azure as well so that no data would be leaving the data centers.  This is a fair question, but unfortunately my site won’t run on any Azure hosting services and additionally I manage a few sites on a single server so it is cost prohibitive to have multiple Azure hosting instances for me right now.</p>
</blockquote>
<p>Well it is simple.  I’m not made of money.  This blog has no accounting department or annual budget and such, I have to be smart about even the smallest cost.  I already have sunk costs into the server that hosts this site as well as a few others.  A $5/month database fee was nothing and justifiable easily with the value I was getting and the minor additional cost.  $50 (and growing) just wasn’t justifiable to me.  It was already at the same cost as my dedicated server and just no longer made sense for my scenario here.  In this instance I’m the “little guy” and need to think like one.  Perhaps cloud services are not for me.</p>
<h2>Summary</h2>
<p>So what did I learn?  Well, I really need to understand bandwidth and transfer data better for the sites I have.  Unfortunately this isn’t totally predictable for me and as such if I can’t predict the cost then it isn’t something that I should be using.  If you are considering these types of services regardless of if they are from Azure or Amazon (or whomever) you need to really plan out not only the service but <strong>how</strong> it will be used.  Don’t be lured by those shiny cost calculators that let you use sliders and show you awesome pricing but don’t help you estimate (or alert you) to that some of those sliders should be linked together.</p>
<p>I think Azure (and other similar services) have real customer value…there is no doubt in that.  For me, however, it just isn’t the time right now.  The services, based on my configuration needs, just don’t make sense.  Had I had a clearer picture of this when signing up, I wouldn’t have been in this situation of frustration.  Choose your services wisely and understand your total usage of them.  For me it currently doesn’t make sense and I’m moving back to a SQL Express account on my server.  Yes I’ll have to manage it a bit more, but my costs will be known and predictable.</p>
<p>Hope this helps.</p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/azure/default.aspx" rel="tag">azure</a>, <a href="http://timheuer.com/blog/Tags/cloud/default.aspx" rel="tag">cloud</a>, <a href="http://timheuer.com/blog/Tags/s3/default.aspx" rel="tag">s3</a>, <a href="http://timheuer.com/blog/Tags/amazon/default.aspx" rel="tag">amazon</a>, <a href="http://timheuer.com/blog/Tags/sql/default.aspx" rel="tag">sql</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14834.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/vzmtDW5jytDUwTvNvaQzuHuBjq4/0/da"><img src="http://feedads.g.doubleclick.net/~a/vzmtDW5jytDUwTvNvaQzuHuBjq4/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/vzmtDW5jytDUwTvNvaQzuHuBjq4/1/da"><img src="http://feedads.g.doubleclick.net/~a/vzmtDW5jytDUwTvNvaQzuHuBjq4/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/56zgwvKzjfA" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/04/10/stung-by-azure-data-transfer-fees.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redesigning my blog for adaptive layout</title>
		<link>http://www.top-silverlight.com/2012/04/03/redesigning-my-blog-for-adaptive-layout.html</link>
		<comments>http://www.top-silverlight.com/2012/04/03/redesigning-my-blog-for-adaptive-layout.html#comments</comments>
		<pubDate>Mon, 02 Apr 2012 19:33:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/04/03/redesigning-my-blog-for-adaptive-layout.html</guid>
		<description><![CDATA[My blog runs on Subtext which has a pretty good skinning model (albeit a tad outdated) and allows you to customize whatever you want.  I’ve had my own custom theme since 2009.  I figured I was due for an update.  I was further strengthened by a post from Jon Galloway last week. There wasn&#8217;t a [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://timheuer.com/blog/archive/2009/02/09/my-blogger-toolbox-tools-for-blogging.aspx">blog runs on Subtext</a> which has a pretty good skinning model (albeit a tad outdated) and allows you to customize whatever you want.  I’ve had my own custom theme since 2009.  I figured I was due for an update.  I was further strengthened by a post from <a href="http://twitter.com/jongalloway">Jon Galloway</a> last week.</p>
<blockquote><p>There wasn&#8217;t a vote, but if there was: I don&#8217;t like narrow, fixed width web designs. Use media queries, scale intelligently on widescreen.</p>
<p> — Jon Galloway (@jongalloway) <a href="https://twitter.com/jongalloway/status/185837607815614465">March 30, 2012</a></p></blockquote>
<p>Now when I saw this I figured it was another nudge.  I did also have some time this weekend without any distractions so I took it as an opportunity to do some ‘work’ on this here blog.  Now a while back I was inspired by what <a href="http://www.hanselman.com/blog/HireAndPayADesignerAndBeHappy.aspx">Scott Hanselman had done on his site with a designer</a>.  I reached out to a few designers that I admired, but frankly never heard back <img src='http://www.top-silverlight.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> .  I figured that was okay as I wasn’t in a position to really pay what I know it is worth for a good designer.  So I went looking for things on the web that I could do myself.  I did want some subtle design tweaks to represent some things I’m currently passionate about.</p>
<h2>Bootstrap your CSS</h2>
<p>After some digging I saw a ton of pointers to <a href="http://twitter.github.com/bootstrap">Bootstrap</a>.  This is an Open Source Javascript/CSS library that sets your site up for styling success and layout goodness.  The documentation was some of the better docs I’ve seen for a library.  Each aspect of the library/styles where in the docs that I could visually see, interact with and see the code that produced the behavior.  I liked what I saw and went to work.</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" src="http://storage2.timheuer.com/bootstrap.png" /></p>
<p>When I got all the styles configured (using the basic setup from Bootstrap) I went to work on some of my own minor tweaks.  One of the things I really liked is the <a href="http://twitter.github.com/bootstrap/scaffolding.html#responsive">responsive layout options</a>, not only for the grid but also for different screen sizes.  By adding a simple class I can specify certain aspects that shouldn’t be displayed when viewing the site on a tablet or phone.  There were other cool responsive options for this such as the main menu will switch to a drop-down approach when on a smaller device.  Using <a href="http://getfirebug.com/">Firebug</a>, IE F12 tools and real devices I was able to get the precise tweaks that I wanted.  Here’s what my site looks like on an iPhone as an example:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="timheuer.com on an iPhone" src="http://storage2.timheuer.com/iphonenewsite.png" width="320" height="480" /></p>
<p>Notice the menu at the top is gone but replaced with a little icon (which is a drop-down).  Also notice the sidebar area is no longer visible (it is on the bottom of the site in this device view).  I like this subtle configuration that was really easy to do with just adding a class name to the area I wanted to collapse.</p>
<p>The other thing I wanted was to implement my primary navigation links in a little-more-than-text style.  I used the CSS sprite method by creating a single image that I would then define styles that used clips within that image to pull out the right area.  Here is the image in entirety:</p>
<p><img style="float: none;margin-left: auto;background-color: black;margin-right: auto" src="http://timheuer.com/blog/skins/2012/img/navbarglyphs.png" /></p>
<p>Notice how the normal and hover states are the same image.  </p>
<blockquote><p><strong>NOTE</strong>: I put this on a black background so you can see them but it is actually a transparent background so the theme’s background shows through.</p>
</blockquote>
<p>What I do then is just define a style for the &lt;a&gt; tag like:</p>
<div>
<div>
<pre><span>   1:</span> #follow {</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>background-image</span>: url("navbarglyphs<span>.png</span>");</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>background-position</span>: <span>-195px 0px;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span> }</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   6:</span> #follow:hover {</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>background-image</span>: url("navbarglyphs<span>.png</span>");</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     <span>background-position</span>: -195px <span>-70px;</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Now I was having a bit of difficulty with this because I was misunderstanding the background-position value in CSS.  A quick set of second eyes with <a href="http://twitter.com/ShawnWildermuth">Shawn Wildermuth</a> (who is doing a bunch of <a href="http://wildermuth.com/2012/3/24/Modern_Web_Development_-_Part_8">HTML dev posts right now</a>) helped me realize my math was wrong and I needed to use the negative value instead of what I was using.  Once that forehead-slap moment was done, I was set.  </p>
<p>I still have a few tweaks to go (need to re-work the comments sections but didn’t have the time to think about a design more) but I’m happy with the quick re-design.  It is very simple for sure, but I like it.  I tried on a few different screen sizes and I think I have met Jon’s challenge to adapt to the available space for the screen.  If you are working with a new site and aren’t a CSS/JS guru I highly recommend looking at Bootstrap as a solid starting point for your efforts.</p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/css/default.aspx" rel="tag">css</a>, <a href="http://timheuer.com/blog/Tags/html5/default.aspx" rel="tag">html5</a>, <a href="http://timheuer.com/blog/Tags/js/default.aspx" rel="tag">js</a>, <a href="http://timheuer.com/blog/Tags/subtext/default.aspx" rel="tag">subtext</a>, <a href="http://timheuer.com/blog/Tags/web/default.aspx" rel="tag">web</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14833.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/thaXZYjl2PDgvCyN4fP_6XSqKCE/0/da"><img src="http://feedads.g.doubleclick.net/~a/thaXZYjl2PDgvCyN4fP_6XSqKCE/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/thaXZYjl2PDgvCyN4fP_6XSqKCE/1/da"><img src="http://feedads.g.doubleclick.net/~a/thaXZYjl2PDgvCyN4fP_6XSqKCE/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/0doDFsWOuJg" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/04/03/redesigning-my-blog-for-adaptive-layout.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a ToggleButton in your XAML Metro style AppBar</title>
		<link>http://www.top-silverlight.com/2012/03/21/using-a-togglebutton-in-your-xaml-metro-style-appbar.html</link>
		<comments>http://www.top-silverlight.com/2012/03/21/using-a-togglebutton-in-your-xaml-metro-style-appbar.html#comments</comments>
		<pubDate>Wed, 21 Mar 2012 10:58:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/03/21/using-a-togglebutton-in-your-xaml-metro-style-appbar.html</guid>
		<description><![CDATA[If you’ve been playing around with the Windows 8 Consumer Preview then hopefully you’ve seen the hundreds of samples provided and downloaded some apps form the store.  In a lot of those applications you’ll notice the common theme of the use of an AppBar…the command bar that shows when you swipe from the top or [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve been playing around with the <a href="http://preview.windows.com">Windows 8 Consumer Preview</a> then hopefully you’ve seen the hundreds of samples provided and downloaded some apps form the store.  In a lot of those applications you’ll notice the common theme of the use of an AppBar…the command bar that shows when you swipe from the top or bottom of the screen.  You can also invoke the AppBar by right-clicking or using the <a href="http://timheuer.com/blog/archive/2012/02/29/windows-8-keyboard-shortcuts.aspx">Windows 8 keyboard shortcut</a> of Windows key + ‘z’ to bring it up as well.</p>
<p align="center"><img style="float: none;margin-left: auto;margin-right: auto" alt="Bing Maps AppBar" src="http://storage2.timheuer.com/bingappbar.png" />    <br /><em>Picture of the AppBar in the Bing Maps application</em></p>
<p>Most of the applications use the standard AppBar button concepts that clicking invokes some action for the app.  There may be times, however, where that button serves as a “toggle” to something in your app.  Using the Bing Maps app as an example, the “Show Traffic” command is actually a toggle command that, well, shows traffic.  You want to give your users some visual indication whether that toggle selection is on/off.  This can be accomplished in XAML by using 2 buttons and toggling their visibility, but that may be overkill for what you simple want to do.</p>
<p>The Visual Studio project templates provide a set of styles for the AppBar for you, but more importantly a base style <em>AppBarButtonStyle</em> that serves as the core design.  Altering this just slightly and you can have a <em>ToggleAppBarButtonStyle</em> for your project.  Here’s the style for that base:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Style</span> <span>x:Key</span><span>="ToggleAppBarButtonStyle"</span> <span>TargetType</span><span>="ToggleButton"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="Foreground"</span> <span>Value</span><span>="{StaticResource AppBarItemForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="VerticalAlignment"</span> <span>Value</span><span>="Stretch"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="FontFamily"</span> <span>Value</span><span>="Segoe UI Symbol"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="FontWeight"</span> <span>Value</span><span>="Normal"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="FontSize"</span> <span>Value</span><span>="21.333"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="AutomationProperties.ItemType"</span> <span>Value</span><span>="AppBar ToggleButton"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="Template"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>         <span>&lt;</span><span>Setter.Value</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>             <span>&lt;</span><span>ControlTemplate</span> <span>TargetType</span><span>="ToggleButton"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>                 <span>&lt;</span><span>Grid</span> <span>Width</span><span>="100"</span> <span>Background</span><span>="Transparent"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>                     <span>&lt;</span><span>StackPanel</span> <span>VerticalAlignment</span><span>="Top"</span> <span>Margin</span><span>="0,14,0,13"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>                         <span>&lt;</span><span>Grid</span> <span>Width</span><span>="40"</span> <span>Height</span><span>="40"</span> <span>Margin</span><span>="0,0,0,5"</span> <span>HorizontalAlignment</span><span>="Center"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  14:</span>                             <span>&lt;</span><span>TextBlock</span> <span>x:Name</span><span>="BackgroundGlyph"</span> <span>Text</span><span>="&#xE0A8;"</span> <span>FontFamily</span><span>="Segoe UI Symbol"</span> <span>FontSize</span><span>="53.333"</span> <span>Margin</span><span>="-4,-19,0,0"</span> <span>Foreground</span><span>="{StaticResource AppBarItemBackgroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  15:</span>                             <span>&lt;</span><span>TextBlock</span> <span>x:Name</span><span>="BackgroundCheckedGlyph"</span> <span>Visibility</span><span>="Collapsed"</span> <span>Text</span><span>="&#xE0A8;"</span> <span>FontFamily</span><span>="Segoe UI Symbol"</span> <span>FontSize</span><span>="53.333"</span> <span>Margin</span><span>="-4,-19,0,0"</span> <span>Foreground</span><span>="{StaticResource AppBarItemForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  16:</span>                             <span>&lt;</span><span>TextBlock</span> <span>x:Name</span><span>="OutlineGlyph"</span> <span>Text</span><span>="&#xE0A7;"</span> <span>FontFamily</span><span>="Segoe UI Symbol"</span> <span>FontSize</span><span>="53.333"</span> <span>Margin</span><span>="-4,-19,0,0"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  17:</span>                             <span>&lt;</span><span>ContentPresenter</span> <span>x:Name</span><span>="Content"</span> <span>HorizontalAlignment</span><span>="Center"</span> <span>Margin</span><span>="-1,-1,0,0"</span> <span>VerticalAlignment</span><span>="Center"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  18:</span>                         <span>&lt;/</span><span>Grid</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  19:</span>                         <span>&lt;</span><span>TextBlock</span></pre>
<p><!--CRLF--></p>
<pre><span>  20:</span>                         <span>x:Name</span><span>="TextLabel"</span></pre>
<p><!--CRLF--></p>
<pre><span>  21:</span>                         <span>Text</span><span>="{TemplateBinding AutomationProperties.Name}"</span></pre>
<p><!--CRLF--></p>
<pre><span>  22:</span>                         <span>Margin</span><span>="0,0,2,0"</span></pre>
<p><!--CRLF--></p>
<pre><span>  23:</span>                         <span>FontSize</span><span>="12"</span></pre>
<p><!--CRLF--></p>
<pre><span>  24:</span>                         <span>TextAlignment</span><span>="Center"</span></pre>
<p><!--CRLF--></p>
<pre><span>  25:</span>                         <span>Width</span><span>="88"</span></pre>
<p><!--CRLF--></p>
<pre><span>  26:</span>                         <span>MaxHeight</span><span>="32"</span></pre>
<p><!--CRLF--></p>
<pre><span>  27:</span>                         <span>TextTrimming</span><span>="WordEllipsis"</span></pre>
<p><!--CRLF--></p>
<pre><span>  28:</span>                         <span>Style</span><span>="{StaticResource BasicTextStyle}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  29:</span>                     <span>&lt;/</span><span>StackPanel</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  30:</span>                     <span>&lt;</span><span>Rectangle</span></pre>
<p><!--CRLF--></p>
<pre><span>  31:</span>                         <span>x:Name</span><span>="FocusVisualWhite"</span></pre>
<p><!--CRLF--></p>
<pre><span>  32:</span>                         <span>IsHitTestVisible</span><span>="False"</span></pre>
<p><!--CRLF--></p>
<pre><span>  33:</span>                         <span>Stroke</span><span>="{StaticResource FocusVisualWhiteStrokeBrush}"</span></pre>
<p><!--CRLF--></p>
<pre><span>  34:</span>                         <span>StrokeEndLineCap</span><span>="Square"</span></pre>
<p><!--CRLF--></p>
<pre><span>  35:</span>                         <span>StrokeDashArray</span><span>="1,1"</span></pre>
<p><!--CRLF--></p>
<pre><span>  36:</span>                         <span>Opacity</span><span>="0"</span></pre>
<p><!--CRLF--></p>
<pre><span>  37:</span>                         <span>StrokeDashOffset</span><span>="1.5"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  38:</span>                     <span>&lt;</span><span>Rectangle</span></pre>
<p><!--CRLF--></p>
<pre><span>  39:</span>                         <span>x:Name</span><span>="FocusVisualBlack"</span></pre>
<p><!--CRLF--></p>
<pre><span>  40:</span>                         <span>IsHitTestVisible</span><span>="False"</span></pre>
<p><!--CRLF--></p>
<pre><span>  41:</span>                         <span>Stroke</span><span>="{StaticResource FocusVisualBlackStrokeBrush}"</span></pre>
<p><!--CRLF--></p>
<pre><span>  42:</span>                         <span>StrokeEndLineCap</span><span>="Square"</span></pre>
<p><!--CRLF--></p>
<pre><span>  43:</span>                         <span>StrokeDashArray</span><span>="1,1"</span></pre>
<p><!--CRLF--></p>
<pre><span>  44:</span>                         <span>Opacity</span><span>="0"</span></pre>
<p><!--CRLF--></p>
<pre><span>  45:</span>                         <span>StrokeDashOffset</span><span>="0.5"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  46:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  47:</span>                     <span>&lt;</span><span>VisualStateManager.VisualStateGroups</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  48:</span>                         <span>&lt;</span><span>VisualStateGroup</span> <span>x:Name</span><span>="CommonStates"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  49:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Normal"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  50:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="PointerOver"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  51:</span>                                 <span>&lt;</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  52:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="BackgroundGlyph"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  53:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemHoverBackgroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  54:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  55:</span>                                 <span>&lt;/</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  56:</span>                             <span>&lt;/</span><span>VisualState</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  57:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Pressed"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  58:</span>                                 <span>&lt;</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  59:</span>                                     <span>&lt;</span><span>DoubleAnimation</span></pre>
<p><!--CRLF--></p>
<pre><span>  60:</span>                                     <span>Storyboard</span>.<span>TargetName</span><span>="OutlineGlyph"</span></pre>
<p><!--CRLF--></p>
<pre><span>  61:</span>                                     <span>Storyboard</span>.<span>TargetProperty</span><span>="Opacity"</span></pre>
<p><!--CRLF--></p>
<pre><span>  62:</span>                                     <span>To</span><span>="0"</span></pre>
<p><!--CRLF--></p>
<pre><span>  63:</span>                                     <span>Duration</span><span>="0"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  64:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="BackgroundGlyph"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  65:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  66:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  67:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="Content"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  68:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemPressedForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  69:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  70:</span>                                 <span>&lt;/</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  71:</span>                             <span>&lt;/</span><span>VisualState</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  72:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Disabled"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  73:</span>                                 <span>&lt;</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  74:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="OutlineGlyph"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  75:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemDisabledForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  76:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  77:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="Content"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  78:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemDisabledForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  79:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  80:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="TextLabel"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  81:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemDisabledForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  82:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  83:</span>                                 <span>&lt;/</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  84:</span>                             <span>&lt;/</span><span>VisualState</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  85:</span>                         <span>&lt;/</span><span>VisualStateGroup</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  86:</span>                         <span>&lt;</span><span>VisualStateGroup</span> <span>x:Name</span><span>="FocusStates"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  87:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Focused"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  88:</span>                                 <span>&lt;</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  89:</span>                                     <span>&lt;</span><span>DoubleAnimation</span></pre>
<p><!--CRLF--></p>
<pre><span>  90:</span>                                         <span>Storyboard</span>.<span>TargetName</span><span>="FocusVisualWhite"</span></pre>
<p><!--CRLF--></p>
<pre><span>  91:</span>                                         <span>Storyboard</span>.<span>TargetProperty</span><span>="Opacity"</span></pre>
<p><!--CRLF--></p>
<pre><span>  92:</span>                                         <span>To</span><span>="1"</span></pre>
<p><!--CRLF--></p>
<pre><span>  93:</span>                                         <span>Duration</span><span>="0"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  94:</span>                                     <span>&lt;</span><span>DoubleAnimation</span></pre>
<p><!--CRLF--></p>
<pre><span>  95:</span>                                         <span>Storyboard</span>.<span>TargetName</span><span>="FocusVisualBlack"</span></pre>
<p><!--CRLF--></p>
<pre><span>  96:</span>                                         <span>Storyboard</span>.<span>TargetProperty</span><span>="Opacity"</span></pre>
<p><!--CRLF--></p>
<pre><span>  97:</span>                                         <span>To</span><span>="1"</span></pre>
<p><!--CRLF--></p>
<pre><span>  98:</span>                                         <span>Duration</span><span>="0"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  99:</span>                                 <span>&lt;/</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 100:</span>                             <span>&lt;/</span><span>VisualState</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 101:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Unfocused"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 102:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="PointerFocused"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 103:</span>                         <span>&lt;/</span><span>VisualStateGroup</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 104:</span>                         <span>&lt;</span><span>VisualStateGroup</span> <span>x:Name</span><span>="CheckStates"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 105:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Checked"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 106:</span>                                 <span>&lt;</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 107:</span>                                     <span>&lt;</span><span>DoubleAnimation</span></pre>
<p><!--CRLF--></p>
<pre><span> 108:</span>                                     <span>Storyboard</span>.<span>TargetName</span><span>="OutlineGlyph"</span></pre>
<p><!--CRLF--></p>
<pre><span> 109:</span>                                     <span>Storyboard</span>.<span>TargetProperty</span><span>="Opacity"</span></pre>
<p><!--CRLF--></p>
<pre><span> 110:</span>                                     <span>To</span><span>="0"</span></pre>
<p><!--CRLF--></p>
<pre><span> 111:</span>                                     <span>Duration</span><span>="0"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 112:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="BackgroundGlyph"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 113:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 114:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 115:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="BackgroundCheckedGlyph"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Visibility"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 116:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="Visible"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 117:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 118:</span>                                     <span>&lt;</span><span>ObjectAnimationUsingKeyFrames</span> <span>Storyboard</span>.<span>TargetName</span><span>="Content"</span> <span>Storyboard</span>.<span>TargetProperty</span><span>="Foreground"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 119:</span>                                         <span>&lt;</span><span>DiscreteObjectKeyFrame</span> <span>KeyTime</span><span>="0"</span> <span>Value</span><span>="{StaticResource AppBarItemPressedForegroundBrush}"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 120:</span>                                     <span>&lt;/</span><span>ObjectAnimationUsingKeyFrames</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 121:</span>                                 <span>&lt;/</span><span>Storyboard</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 122:</span>                             <span>&lt;/</span><span>VisualState</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 123:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Unchecked"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 124:</span>                             <span>&lt;</span><span>VisualState</span> <span>x:Name</span><span>="Indeterminate"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 125:</span>                         <span>&lt;/</span><span>VisualStateGroup</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 126:</span>                     <span>&lt;/</span><span>VisualStateManager.VisualStateGroups</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 127:</span>                 <span>&lt;/</span><span>Grid</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 128:</span>             <span>&lt;/</span><span>ControlTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 129:</span>         <span>&lt;/</span><span>Setter.Value</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 130:</span>     <span>&lt;/</span><span>Setter</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span> 131:</span> <span>&lt;/</span><span>Style</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Now with that style we can have a simple style that shows a toggle on and off for the same button:</p>
<div>
<div>
<pre><span>   1:</span> ...</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> <span>&lt;</span><span>Page.BottomAppBar</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>&lt;</span><span>AppBar</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>         <span>&lt;</span><span>ToggleButton</span> <span>Style</span><span>="{StaticResource ToggleAppBarButtonStyle}"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>                 <span>AutomationProperties</span>.<span>Name</span><span>="Search"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>                 <span>Content</span><span>="&#xE11A;"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>&lt;/</span><span>AppBar</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span> <span>&lt;/</span><span>Page.BottomAppBar</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span> ...</pre>
<p><!--CRLF--></div>
</div>
<p>The result would show:</p>
<p><img style="margin-left: 0px;margin-right: 0px" src="http://storage2.timheuer.com/searchtoggleoff.png" /> <img style="margin-left: 0px;margin-right: 0px" src="http://storage2.timheuer.com/searchtoggleon.png" /></p>
<p><em>ToggleButtonAppBarStyle in off/on state</em></p>
<p>This way we exhibit all the same behaviors of the AppBarButtonStyle, but just applied to the ToggleButton element in XAML.  Now we could probably refactor both to have an even more derivative base style and use more BasedOn styling, but how it is currently structured we couldn’t have a ToggleButton based on a Button style.  But thanks to the style/template engine in XAML we can re-use a lot and serve our needs!</p>
<p>Notice that you can set the Content to be whatever you want.  Since my base style uses the Segoe UI Symbol font, I’m setting the unicode value for a glyph here for Search.  A set of some cool glyphs you can use can be found in my previous post on <a href="http://timheuer.com/blog/archive/2012/03/05/visualizing-appbar-command-styles-windows-8.aspx">XAML AppBar button styles</a>.</p>
<p>You can get the ToggleAppBarButtonStyle from here: <a title="https://gist.github.com/2131230" href="https://gist.github.com/2131230">https://gist.github.com/2131230</a>.</p>
<p>Hope this helps!
  </p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/winrt/default.aspx" rel="tag">winrt</a>, <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/appbar/default.aspx" rel="tag">appbar</a>, <a href="http://timheuer.com/blog/Tags/win8/default.aspx" rel="tag">win8</a>, <a href="http://timheuer.com/blog/Tags/metro/default.aspx" rel="tag">metro</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14831.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/uAeRCljPVYDNlQ72vpLdhG-nn24/0/da"><img src="http://feedads.g.doubleclick.net/~a/uAeRCljPVYDNlQ72vpLdhG-nn24/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/uAeRCljPVYDNlQ72vpLdhG-nn24/1/da"><img src="http://feedads.g.doubleclick.net/~a/uAeRCljPVYDNlQ72vpLdhG-nn24/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/K8HWrKk7-Qg" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/03/21/using-a-togglebutton-in-your-xaml-metro-style-appbar.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monetize your Metro style app with Microsoft AdCenter</title>
		<link>http://www.top-silverlight.com/2012/03/09/monetize-your-metro-style-app-with-microsoft-adcenter.html</link>
		<comments>http://www.top-silverlight.com/2012/03/09/monetize-your-metro-style-app-with-microsoft-adcenter.html#comments</comments>
		<pubDate>Fri, 09 Mar 2012 02:04:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/03/09/monetize-your-metro-style-app-with-microsoft-adcenter.html</guid>
		<description><![CDATA[Today, the Microsoft Advertising team announced an update to their AdCenter SDK to include support for monetizing your Metro style apps. In a blog post announcing the update, Ian notes that if you were using the previous SDK that there have been breaking changes and to use the updated SDK.  This update includes support for [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: left" alt="Microsoft Advertising logo" align="left" src="http://storage2.timheuer.com/adCenterCommunity_Logo.png" />Today, the Microsoft Advertising team announced an update to their AdCenter SDK to include support for monetizing your Metro style apps.</p>
<p>In a <a href="http://community.microsoftadvertising.com/blogs/advertising/archive/2012/03/06/developers-microsoft-advertising-sdk-windows-metro-apps.aspx">blog post announcing the update</a>, Ian notes that if you were using the previous SDK that there have been breaking changes and to use the updated SDK.  This update includes support for XAML applications and adding the ad units couldn’t be easier.  After installing their SDK (which was developed using the same distribution concepts in my post about <strong><a href="http://timheuer.com/blog/archive/2012/03/07/creating-custom-controls-for-metro-style-apps.aspx">creating a distributable custom control</a></strong> previous post), you will be able to use <em>Add Reference</em> in Visual Studio, navigate to the Windows/Extensions area and add the SDK.  After that it is as simple as adding the control in your project:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Grid</span> <span>Background</span><span>="{StaticResource ApplicationPageBackgroundBrush}"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>&lt;</span><span>Border</span> <span>Background</span><span>="Red"</span> <span>VerticalAlignment</span><span>="Bottom"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>         <span>&lt;</span><span>ads:AdControl</span> <span>xmlns:ads</span><span>="using:Microsoft.Advertising.WinRT.UI"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>                        <span>VerticalAlignment</span><span>="Bottom"</span> <span>Width</span><span>="728"</span> <span>Height</span><span>="90"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>                        <span>AdUnitId</span><span>="YOUR_AD_UNIT_ID"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>                        <span>ApplicationId</span><span>="YOUR_APPLICATION_ID"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>&lt;/</span><span>Border</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span> <span>&lt;/</span><span>Grid</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Now you do, of course, have to have a pubCenter account and create the ad units beforehand in order for this to work, but that setup time didn’t take long at all.</p>
<p>You may have some time for your own ad units to be provisioned and start serving ads, but the ad team <a href="http://msdn.microsoft.com/en-US/library/hh506361(v=msads.10).aspx">created some test values you can use</a> to see how things all work.  Download the <strong><a href="http://go.microsoft.com/?linkid=9800248">Ads SDK</a></strong> today!</p>
<p>Hope this helps!
  </p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/adcenter/default.aspx" rel="tag">adcenter</a>, <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/metro/default.aspx" rel="tag">metro</a>, <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/winrt/default.aspx" rel="tag">winrt</a>, <a href="http://timheuer.com/blog/Tags/pubcenter/default.aspx" rel="tag">pubcenter</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14830.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/g7LJPJiawC4UziLKJ-a7chzRIL8/0/da"><img src="http://feedads.g.doubleclick.net/~a/g7LJPJiawC4UziLKJ-a7chzRIL8/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/g7LJPJiawC4UziLKJ-a7chzRIL8/1/da"><img src="http://feedads.g.doubleclick.net/~a/g7LJPJiawC4UziLKJ-a7chzRIL8/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/EfoNsIaYp88" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/03/09/monetize-your-metro-style-app-with-microsoft-adcenter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a deployable custom control for XAML Metro style apps</title>
		<link>http://www.top-silverlight.com/2012/03/09/building-a-deployable-custom-control-for-xaml-metro-style-apps.html</link>
		<comments>http://www.top-silverlight.com/2012/03/09/building-a-deployable-custom-control-for-xaml-metro-style-apps.html#comments</comments>
		<pubDate>Fri, 09 Mar 2012 02:04:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/03/09/building-a-deployable-custom-control-for-xaml-metro-style-apps.html</guid>
		<description><![CDATA[At //build one of the surprising immediate things I heard about was folks wanting to build custom controls right away.  I knew that would happen, but not so quick on something so new (WinRT).  The XAML platform did not have good support for building custom controls in the Developer Preview but now that the Consumer [...]]]></description>
			<content:encoded><![CDATA[<p>At //build one of the surprising immediate things I heard about was folks wanting to build custom controls right away.  I knew that would happen, but not so quick on something so new (WinRT).  The XAML platform did not have good support for building custom controls in the Developer Preview but now that the <a href="http://preview.windows.com">Consumer Preview for Windows 8</a> and Visual Studio 11 Beta are out, there is much better support.  There are two key things when thinking about custom controls: 1) building it and 2) making it consumable by developers (even if those developers are your own company).  I’ll try to articulate the methods of both here.</p>
<h2>Defining custom versus user control</h2>
<p>There is usually some debate in the XAML community about the definition of a custom control.  For the purposes of this discussion I define a custom control as a control that provides a generic.xaml, can be styled/templated and is usually encapsulated in its own assembly which can then be distributed.  A custom control can <em>contain</em> user controls, but generally speaking does not.  A typical user control scenario is one that lives within your project and not meant to be consumed by anyone outside your project.</p>
<p>This definition is the same whether we are talking about C++, C# or Visual Basic.  Everything below applies to all languages.</p>
<h2>Creating the custom control</h2>
<p>The fundamentals of a custom control are that it is a class and it provides it’s own template/style.  This style/template definition usually lives in a file located at themes/generic.xaml.  This is the same pattern that has existed in other XAML implementations like WPF, Silverlight and Windows Phone.  The pattern is no different for Metro style apps in this regard.</p>
<p>The creation of the most basic custom control is very simple.  A Windows SDK sample for <a href="http://code.msdn.microsoft.com/windowsapps/XAML-user-and-custom-a8a9505e">XAML User and Custom Controls</a> is available for you to download for the quick review and core concept.  My intent here is to take that a step further for the end-to-end implementation if I were a control vendor.  Let’s first create our control.  For our purposes we will create a control that shows an Image and allows you to specify some Text for the label.  The label, however, will be prepended with some text that comes from string resources.</p>
<p>In Visual Studio we will create a class library project first.</p>
<blockquote><p><strong>NOTE</strong>: You can create a C#/VB Class Library and keep it managed, or convert it to a WinRT component.  You may also create this in C++ using the WinRT Component project type.  Again, these concepts are the same, the syntax will be obviously slightly different for C++ and managed code.</p>
</blockquote>
<p>Once you create the class library (I called mine SimpleCustomControl and deleted the initial Class1.cs file that was created), add an item to the project.  You can do this via right-clicking on the project and choosing add item.  You will be presented with a few options, but the important one is Templated Control.</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Add Item dialog" src="http://storage2.timheuer.com/cc-additem.png" /></p>
<p>Watch was this does to your project as it will do 2 things:</p>
<ul>
<li>Create a new class </li>
<li>Add a Themes folder and place a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.resourcedictionary.aspx">ResourceDictionary</a> called generic.xaml in that folder </li>
</ul>
<p>The themes/generic.xaml is very important if you use the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.control.defaultstylekey.aspx">DefaultStyleKey</a> concept in your class.  This is very much a convention-based approach.  The contents of the class is very simple at this point, with the sole constructor and the DefaultStyleKey wired up:</p>
<div>
<div>
<pre><span>   1:</span> <span>namespace</span> SimpleCustomControl</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>public</span> <span>sealed</span> <span>class</span> LabeledImage : Control</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     {</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>         <span>public</span> LabeledImage()</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>             <span>this</span>.DefaultStyleKey = <span>typeof</span>(LabeledImage);</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>         }</pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>     }</pre>
<p><!--CRLF--></p>
<pre><span>  10:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>This maps to the generic.xaml definition of our control.  Let’s modify our <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.controltemplate.aspx">ControlTemplate</a> in generic.xaml to be a little more than just a border:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Style</span> <span>TargetType</span><span>="local:LabeledImage"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>&lt;</span><span>Setter</span> <span>Property</span><span>="Template"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>         <span>&lt;</span><span>Setter.Value</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>             <span>&lt;</span><span>ControlTemplate</span> <span>TargetType</span><span>="local:LabeledImage"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>                 <span>&lt;</span><span>Border</span> <span>Background</span><span>="LightBlue"</span> <span>BorderBrush</span><span>="Black"</span> <span>BorderThickness</span><span>="2"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>                         <span>HorizontalAlignment</span><span>="Center"</span> <span>Width</span><span>="140"</span> <span>Height</span><span>="150"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>                     <span>&lt;</span><span>StackPanel</span> <span>HorizontalAlignment</span><span>="Center"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>                         <span>&lt;</span><span>Image</span> <span>Stretch</span><span>="Uniform"</span> <span>Width</span><span>="100"</span> <span>Height</span><span>="100"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>                                <span>Source</span><span>="{TemplateBinding ImagePath}"</span> <span>Margin</span><span>="5"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>                         <span>&lt;</span><span>TextBlock</span> <span>TextAlignment</span><span>="Center"</span> <span>FontFamily</span><span>="Segoe UI"</span> <span>FontWeight</span><span>="Light"</span> </pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>                                    <span>FontSize</span><span>="26.667"</span> <span>Foreground</span><span>="Black"</span> <span>x:Name</span><span>="LabelHeader"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>                         <span>&lt;</span><span>TextBlock</span> <span>TextAlignment</span><span>="Center"</span> </pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>                                    <span>Text</span><span>="{TemplateBinding Label}"</span> <span>FontFamily</span><span>="Seqoe UI"</span> <span>FontWeight</span><span>="Light"</span> </pre>
<p><!--CRLF--></p>
<pre><span>  14:</span>                                    <span>FontSize</span><span>="26.667"</span> <span>Foreground</span><span>="Black"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  15:</span>                     <span>&lt;/</span><span>StackPanel</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  16:</span>                 <span>&lt;/</span><span>Border</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  17:</span>             <span>&lt;/</span><span>ControlTemplate</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  18:</span>         <span>&lt;/</span><span>Setter.Value</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  19:</span>     <span>&lt;/</span><span>Setter</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  20:</span> <span>&lt;/</span><span>Style</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Now we have a place for an Image, LabelHeader and a Label.  Notice that we have {<a href="http://msdn.microsoft.com/en-us/library/windows/apps/Hh758288.aspx">TemplatBinding</a>} statements there.  This is how the template binds (duh) to values provided to the control.  So our ControlTemplate is expecting these properties to exist on our control.  We will create these as <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.dependencyproperty.aspx">DependencyProperty</a> types so we can use them in Binding, change notification, etc.  In Visual Studio we can make re-use out of the ‘propdp’ code snippet that exists for WPF.  It is slightly different in the last argument, but it will definitely save you a lot of typing.  We’ll create 2 DependencyProperties like this in our LabeledImage.cs file:</p>
<div>
<div>
<pre><span>   1:</span> <span>public</span> ImageSource ImagePath</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     get { <span>return</span> (ImageSource)GetValue(ImagePathProperty); }</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     set { SetValue(ImagePathProperty, <span>value</span>); }</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span> }</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   7:</span> <span>public</span> <span>static</span> <span>readonly</span> DependencyProperty ImagePathProperty =</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     DependencyProperty.Register(<span>"ImagePath"</span>, <span>typeof</span>(ImageSource), <span>typeof</span>(LabeledImage), <span>new</span> PropertyMetadata(<span>null</span>));</pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  10:</span> <span>public</span> <span>string</span> Label</pre>
<p><!--CRLF--></p>
<pre><span>  11:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>     get { <span>return</span> (<span>string</span>)GetValue(LabelProperty); }</pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>     set { SetValue(LabelProperty, <span>value</span>); }</pre>
<p><!--CRLF--></p>
<pre><span>  14:</span> }</pre>
<p><!--CRLF--></p>
<pre><span>  15:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  16:</span> <span>public</span> <span>static</span> <span>readonly</span> DependencyProperty LabelProperty =</pre>
<p><!--CRLF--></p>
<pre><span>  17:</span>     DependencyProperty.Register(<span>"Label"</span>, <span>typeof</span>(<span>string</span>), <span>typeof</span>(LabeledImage), <span>new</span> PropertyMetadata(<span>null</span>));</pre>
<p><!--CRLF--></div>
</div>
<p>We also had that LabelHeader property.  This is going to be a value coming from a string resource that may be localized at some point.  In our library add a folder called “en” and then within that, using the Add Item dialog in VS, add a Resources.resw file.  Within that Resources.resw file add a name/value pair of name=<em>LabelHeader.Text</em> and value=<em>This is an image of a…</em> and you can save/close the file.</p>
<p>Now back to our class file we are going to set the value of our TextBlock by overriding our template rendering, grabbing a reference to that TextBlock and setting the value from our string resource.</p>
<div>
<div>
<pre><span>   1:</span> <span>protected</span> <span>override</span> <span>void</span> OnApplyTemplate()</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>base</span>.OnApplyTemplate();</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     TextBlock tb = GetTemplateChild(<span>"LabelHeader"</span>) <span>as</span> TextBlock;</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     tb.Text = <span>new</span> ResourceLoader(<span>"SimpleCustomControl/Resources/LabelHeader"</span>).GetString(<span>"Text"</span>);</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Now, I’m showing this way, because it is pretty verbose and there is an easier way…but you wouldn’t know it is easier unless you saw the harder way right?</p>
<p>First it is important to understand how these resources are indexed.  You’ll notice that I’m using a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.resources.resourceloader.aspx">ResourceLoader</a> class to map to what looks like {component}/{resw-file-name}/{property} which is effectively right.  When you create a resw file, at compile-time these get built into a PRI file.  This post isn’t about this whole resource loading process, but you should definitely understand this a bit.  Basically for a control creator perspective you need to understand that your string resources (and file-based resources) live in a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.resources.core.resourcemap.aspx">ResourceMap</a> that is the name of your component.</p>
<blockquote>
<p><strong>NOTE</strong>: An easy way to look at this resource indexing is to use the makepri.exe tool installed with VS.  From a VS command prompt navigate to your build output and you should see a resources.pri file.  Call makepri.exe dump and you’ll get an XML representation of that file you can look at.  Knowing that structure is very helpful.</p>
</blockquote>
<p>I said there was an easier way to get that string though.  First remove the OnApplyTemplate override completely…we don’t need it for this control anymore.  Now in generic.xaml change the x:Name=”LabelHeader” to the following:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Style</span> <span>TargetType</span><span>="local:LabeledImage"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> ...</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>&lt;</span><span>TextBlock</span> <span>TextAlignment</span><span>="Center"</span> <span>FontFamily</span><span>="Segoe UI"</span> <span>FontWeight</span><span>="Light"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>                <span>FontSize</span><span>="26.667"</span> <span>Foreground</span><span>="Black"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>                 <span>x:Uid</span><span>="/SimpleCustomControl/Resources/LabelHeader"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span> ...</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span> <span>&lt;/</span><span>Style</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>This will use the XAML parser way of getting the string resource (note the ResourceMap is still in the x:Uid value).  Using the ResourceMap prefix is necessary when using this method as a custom control vendor.</p>
<p>We are done.  Our control is complete.</p>
<h2>Consuming the control from an application</h2>
<p>We can quickly test our control by adding a new Metro style app to our project.  Once we do this, make that the startup project and add a project reference to our control library.  Then in the default page for our app (BlankPage or MainPage depending on your template choice), add an xmlns to the top and then consume the control:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Page</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>x:Class</span><span>="Application1.BlankPage"</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>xmlns</span><span>="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     <span>xmlns:x</span><span>="http://schemas.microsoft.com/winfx/2006/xaml"</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     <span>xmlns:local</span><span>="using:Application1"</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     <span>xmlns:d</span><span>="http://schemas.microsoft.com/expression/blend/2008"</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>xmlns:mc</span><span>="http://schemas.openxmlformats.org/markup-compatibility/2006"</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     <span>xmlns:controls</span><span>="using:SimpleCustomControl"</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>     <span>mc:Ignorable</span><span>="d"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>     <span>&lt;</span><span>Grid</span> <span>Background</span><span>="{StaticResource ApplicationPageBackgroundBrush}"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>         <span>&lt;</span><span>controls:LabeledImage</span> <span>ImagePath</span><span>="Assets/110Orange.png"</span> <span>Label</span><span>="Orange"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>     <span>&lt;/</span><span>Grid</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  14:</span> <span>&lt;/</span><span>Page</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>See how the ImagePath and Label are used here?  In more advanced scenarios we can bind values from our view model or other ways.  When rendered the control will show like this:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Custom control rendered" src="http://storage2.timheuer.com/cc-rendered.png" /></p>
<p>This is great…but also what we call a “project-to-project” (P2P) reference.  As a control vendor we want to distribute our control, not our source primarily.  So we need to package this up.  There are two ways you can do this.</p>
<h2>Package your control as an Extension SDK</h2>
<p>One of the new methods for distributing Metro style controls in VS11 is via Extension SDKs, also sometimes referred to as non-Framework SDKs.  Extension SDKs are machine-wide and available to all projects once installed.  They can be distributed via the Visual Studio gallery and using the VSIX mechanism…which allows for update notification in Visual Studio.  There are a few intricacies that you can configure your Extension SDK but for most it will get down to three things:</p>
<ul>
<li>Describing your SDK and what it supports </li>
<li>Including the binary that projects need to reference </li>
<li>Including any assets/files that the control relies on to render </li>
</ul>
<p>In examining our sample above we have a few things that map to this:</p>
<ul>
<li>Describing – our sample is a C# custom control so it will only work with managed Metro style apps, we will need to describe this in our SDK </li>
<li>Binary – we have one binary: SimpleCustomControl.dll </li>
<li>Redistributables – we have a generic.xaml and a PRI file with our string resources </li>
</ul>
<p>The last part (redist) probably is making some existing XAML control developers scratch their heads.  <em>Why isn’t the generic.xaml embedded </em>is what you are likely asking yourself.  In Metro style apps, XAML assets are not embedded but rather exist as “loose file” assets for your control.  This is why it is critical for getting the distribution model correct so that the runtime knows where to get the definitions for everything.</p>
<blockquote>
<p><strong>NOTE</strong>: This is a default method.  You can, of course, use other techniques to get your assets into your binary either via string constants, other embedding techniques, etc.  In doing so, however, you will now be managing all those extractions yourself rather than being able to rely on the resource APIs for Metro style apps.</p>
</blockquote>
<p>The first thing we want to do is understand the structure of an SDK.  These live in %ProgramFiles%\Microsoft SDKs\Windows\v8.0\Extension SDKs directory on disk.  Within there you will have your own folder, version and then the layout of your SDK, as described by your manifest.  Here is what our manifest (SDKManifest.xml) would look like for our control:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;?</span><span>xml</span> <span>version</span><span>="1.0"</span> <span>encoding</span><span>="utf-8"</span> ?<span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> <span>&lt;</span><span>FileList</span> </pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>   <span>DisplayName</span><span>="Simple Custom Control"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>   <span>ProductFamilyName</span><span>="Simple Controls"</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>   <span>MinVSVersion</span><span>="11.0"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>   <span>MinToolsVersion</span><span>="4.0"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>   <span>CopyRedistToSubDirectory</span><span>="SimpleCustomControl"</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>   <span>AppliesTo</span><span>="WindowsAppContainer+WindowsXAML+Managed"</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>   <span>MoreInfo</span><span>="http://timheuer.com/blog/"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>   <span>&lt;</span><span>File</span> <span>Reference</span><span>="SimpleCustomControl.dll"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>     <span>&lt;</span><span>ContainsControls</span><span>&gt;</span>True<span>&lt;/</span><span>ContainsControls</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>   <span>&lt;/</span><span>File</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  14:</span> <span>&lt;/</span><span>FileList</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>We are describing the display information as well as some key data:</p>
<ul>
<li>Display data – the title that will show up in Add Reference </li>
<li>CopyRedistToSubdirectory – this would be the name of your component </li>
<li>AppliesTo – what I support; in this I’m saying managed, XAML, Metro style apps </li>
<li>&lt;File&gt; – these are the files that describe components in my SDK (not their loose assets) </li>
</ul>
<p>Now to create the structure.  When you build the DLL your output will give you this:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Build output" src="http://storage2.timheuer.com/cc-buildoutput.png" /></p>
<p>We need to create the following structure that will live under the Extension SDK folder listed above:</p>
<p>%ProgramFiles%\Microsoft SDKs\Windows\v8.0\Extension SDKs\</p>
<p>&#8211;SimpleCustomControl</p>
<p>&#8212;-1.0</p>
<p>&#8212;&#8212;SDKManifest.xml (the file above)</p>
<p>&#8212;&#8212;References\CommonConfiguration\neutral\SimpleCustomControl.dll</p>
<p>&#8212;&#8212;Redist\CommonConfiguration\neutral\SimpleCustomControl.pri</p>
<p>&#8212;&#8212;Redist\CommonConfiguration\neutral\Themes\generic.xaml</p>
<p>Notice the References and Redist folders.  By placing these in that structure, the project will know what it needs to get type information (References) and then during running/deployment what it needs to package (Redist) and where it puts it (CopyRedistToSubdirectory).  Put this layout in the directory and then when you choose add reference on a project you will see your option:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Add reference dialog" src="http://storage2.timheuer.com/cc-addref.png" /></p>
<p>There are other configuration options for the SDKManifest that you can use and the required reading is the Extension SDK section in this <strong><a href="http://go.microsoft.com/fwlink/?LinkID=235409">MSDN article: How to: Create a Software Development Kit</a></strong>.</p>
<p>The next step for an Extension SDK is to really package it up nicely.  You probably don’t want your users copy directories around all the time…and what about updates as well!  Using the Visual Studio VSIX structure for this really makes it easy to do.</p>
<p>There are tools for Visual Studio to allow you to create a VSIX package.  This requires the <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads#vs-sdk">Visual Studio extensibility SDK</a> to be installed and using Visual Studio professional or higher.  Once you do that you can create a VSIX package and you will see the VSIX manifest designer.  On the Install Targets tab you will choose Extension SDK:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="VSIX Install Targets" src="http://storage2.timheuer.com/cc-vsixtarget.png" /></p>
<p>We then re-create the layout structure in the VSIX project and add the Assets to the manifest.  The result in the IDE looks something like this:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="VSIX Manifest Assets" src="http://storage2.timheuer.com/cc-vsixmanifest.png" /></p>
<p>Now when we build we will get a VSIX installer that we can upload to the Visual Studio Gallery or distribute to our customers.</p>
<p>NOTE: Uploading the to Visual Studio Gallery has benefits in that once installed, any update you put in the gallery will provide notifications to the Visual Studio user than an update exists.  This is done via the unique Product ID value in your manifest, so choose that value accordingly and don’t change it if you want this capability.</p>
<p>When a user gets the VSIX, they double-click it and see the installer:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="VSIX Installer" src="http://storage2.timheuer.com/cc-vsixinstaller.png" /></p>
<p>And then they can use it as normally in Add Reference just like described above.  Additional details on other VSIX deployment configurations can be found here: <strong><a href="http://msdn.microsoft.com/en-us/library/ff363239.aspx">VSIX Deployment</a></strong>.</p>
<p>Once you have your VSIX you can upload to the Visual Studio Gallery and make it discoverable for users from within Visual Studio.  Remember that this method of Extension SDK is machine-wide which is in contrast to the second method described next.</p>
<h2>Package your control as a NuGet Package</h2>
<p>The other option you have is to package up your control via a <a href="http://www.nuget.org">NuGet</a> package.  NuGet packages apply to the <strong>project</strong> and not the machine, but have the flexibility of not having to have anything installed and can travel their dependencies with the project.  NuGet packages are another type of package that has a manifest that describes what the content does.  </p>
<p>For Metro style XAML controls you will have to do a few things differently currently with the NuGet package you create.  NuGet packages are based on nuspec files, which is basically a manifest describing where to get/put things in the package.  You can also use the <a href="http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package">NuGet Package Explorer</a> for a GUI way of reading/creating new packages.  If you are unfamiliar with the nuspec format, using the package explorer will help you get a package created quickly.  </p>
<p>NuGet is one area where there actually are current differences in C++ or managed code.  Right now NuGet only supports managed code projects and not C++.  I’m sure this may change in the future, but as of right now this applies only to managed code.  For our control above here is what my nuspec file looks like:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;?</span><span>xml</span> <span>version</span><span>="1.0"</span>?<span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> <span>&lt;</span><span>package</span> <span>xmlns</span><span>="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>   <span>&lt;</span><span>metadata</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     <span>&lt;</span><span>version</span><span>&gt;</span>1.0.0<span>&lt;/</span><span>version</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     <span>&lt;</span><span>authors</span><span>&gt;</span>Tim Heuer<span>&lt;/</span><span>authors</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     <span>&lt;</span><span>owners</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>&lt;</span><span>id</span><span>&gt;</span>SimpleCustomControl<span>&lt;/</span><span>id</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     <span>&lt;</span><span>title</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>     <span>&lt;</span><span>requireLicenseAcceptance</span><span>&gt;</span>false<span>&lt;/</span><span>requireLicenseAcceptance</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>     <span>&lt;</span><span>description</span><span>&gt;</span>A simple custom control for Metro style apps<span>&lt;/</span><span>description</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>   <span>&lt;/</span><span>metadata</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>   <span>&lt;</span><span>files</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>     <span>&lt;</span><span>file</span> <span>src</span><span>="SimpleCustomControl\bin\Debug\Themes\Generic.xaml"</span> <span>target</span><span>="lib\winrt\SimpleCustomControl\Themes\Generic.xaml"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  14:</span>     <span>&lt;</span><span>file</span> <span>src</span><span>="SimpleCustomControl\bin\Debug\SimpleCustomControl.dll"</span> <span>target</span><span>="lib\winrt\SimpleCustomControl.dll"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  15:</span>     <span>&lt;</span><span>file</span> <span>src</span><span>="SimpleCustomControl\bin\Debug\SimpleCustomControl.pri"</span> <span>target</span><span>="lib\winrt\SimpleCustomControl.pri"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  16:</span>   <span>&lt;/</span><span>files</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  17:</span> <span>&lt;/</span><span>package</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>This assumes that the binaries being referenced here are all relative to the nuspec file.  Notice how all the files go into the lib\winrt folder and that we essentially re-create that SDK layout in our package as well.</p>
<p>Now when I build this with nuget.exe I get a package output.  In Visual Studio (with NuGet installed) I can now right-click on a project and choose <em>Manage NuGet Packages </em>and browse the library of packages.  In testing out my package, I create a custom library (you do this via the Settings option when you are in the Manage NuGet Packages dialog) and just point it to the folder where my nupkg file was created:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Manage NuGet Packages dialog" src="http://storage2.timheuer.com/cc-nugetmanage.png" /></p>
<p>When the package is selected, the reference is added to my project and during build, all the right pieces are put in my APPX package where they need to go.  Once the reference is there I build and run my project and the control renders as expected!</p>
<h2>What about the design-time experience?</h2>
<p>All of the methods above will allow you to view your control on the XAML design surface in Visual Studio as well.  In the Extension SDK method there is actually additional affordances for you to provide additional design-time assemblies/resources to make that experience even better.  Custom control developers for XAML know about this .Design.dll that is created for their projects that can improve the design-time experience for UI controls.  I highly encourage you to do that if you are creating a control that is for wide distribution and not just yourself or your small group of friends.</p>
<h2>Summary</h2>
<p>Wow this felt like a long post…thanks for reading this far!  I think developing custom controls is a great way to encapsulate specific UI and behavior you want in your application.  XAML has a great ecosystem of control vendors and I fully expect them to produce controls for Metro style apps as well.  Hopefully these techniques of packaging them up for distribution will help us all take advantage of them.</p>
<p>I also think that creating an Extension SDK *and* a NuGet package are the best ways of thinking about it as a producer.  This enables your consumers to have the greatest flexibility in how they want to consume your control.  Creating these distribution mechanisms may seem cumbersome at first (and there are some places where Visual Studio can improve the experience of creating/managing these manifests), but once you understand the core layout that is required for a Metro style XAML control and the fact that you now have “loose files” to consider it really becomes pretty streamlined and you can automate the creation of these pretty quickly in your build systems.</p>
<p>Be sure to check out these resources again:</p>
<ul>
<li>Windows SDK: <strong><a href="http://code.msdn.microsoft.com/windowsapps/XAML-user-and-custom-a8a9505e">XAML User and Custom Controls</a></strong> (shows the C++ custom control as well)</li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=235409">Creating a Software Development Kit</a> (refer to Extension SDK section)</li>
<li><a href="http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package">NuGet Packages</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ff363239.aspx">VSIX Deployment</a></li>
</ul>
<p>Here is the solution for the project I walked through above: <a href="http://s3.amazonaws.com:80/storage2.timheuer.com/SimpleCustomControl.zip">SimpleCustomControl.zip</a></p>
<p>Hope this helps!
  </p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/winrt/default.aspx" rel="tag">winrt</a>, <a href="http://timheuer.com/blog/Tags/nuget/default.aspx" rel="tag">nuget</a>, <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/controls/default.aspx" rel="tag">controls</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14829.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/9pi3lPJCv5LM5xMsodde3Lc3ug8/0/da"><img src="http://feedads.g.doubleclick.net/~a/9pi3lPJCv5LM5xMsodde3Lc3ug8/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/9pi3lPJCv5LM5xMsodde3Lc3ug8/1/da"><img src="http://feedads.g.doubleclick.net/~a/9pi3lPJCv5LM5xMsodde3Lc3ug8/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/HjRqwDAP5L4" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/03/09/building-a-deployable-custom-control-for-xaml-metro-style-apps.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Bing Maps in your Windows 8 XAML applications</title>
		<link>http://www.top-silverlight.com/2012/03/07/use-bing-maps-in-your-windows-8-xaml-applications.html</link>
		<comments>http://www.top-silverlight.com/2012/03/07/use-bing-maps-in-your-windows-8-xaml-applications.html#comments</comments>
		<pubDate>Wed, 07 Mar 2012 13:02:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/03/07/use-bing-maps-in-your-windows-8-xaml-applications.html</guid>
		<description><![CDATA[Today the Bing team announced the release of their WinRT Bing Maps control (BETA) for XAML applications.  First the goods: Read their announcement here: Bing Maps for Metro style apps Download the bits: Bing Maps SDK for Metro style apps (VSIX) Read the reference API docs: Bing Maps SDK If you are familiar with the [...]]]></description>
			<content:encoded><![CDATA[<p>Today the Bing team announced the release of their WinRT Bing Maps control (BETA) for XAML applications.  First the goods:</p>
<ul>
<li>Read their announcement here: <a href="http://www.bing.com/community/site_blogs/b/maps/archive/2012/03/06/announcing-bing-maps-for-metro-style-apps.aspx">Bing Maps for Metro style apps</a></li>
<li>Download the bits: <a href="http://go.microsoft.com/fwlink/?LinkId=242709">Bing Maps SDK for Metro style apps</a> (VSIX)</li>
<li>Read the reference API docs: <a href="http://go.microsoft.com/fwlink/?LinkID=242866&amp;clcid=0x409">Bing Maps SDK</a></li>
</ul>
<p>If you are familiar with the <a href="http://silverlight.net">Silverlight</a> control, it is <em>similar</em> in nature to how you would use it in your XAML Metro style app.  Here’s some helpful tips that are in the docs but just wanted to elevate them because we have a tendency not to read docs <img src='http://www.top-silverlight.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<h2>Installing</h2>
<p>Installing is simple for Visual Studio.  Download the VSIX file and double-click it.  If you have both Express and Ultimate installed it will prompt you to install it for both installations.  That’s it…you are done.  If you had VS running while you did this, it would be a good idea to restart VS.</p>
<h2>Creating a .NET XAML application with maps</h2>
<p>Once you restart VS, you can create a new C# Metro style application.  Once you have this, just right click on the project and choose Add Reference and then navigate to the Windows\Extensions section and you will see Bing Maps:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Bing Maps Reference" src="http://storage2.timheuer.com/bingmapref.png" /></p>
<p>When you do this you will also want to add a reference to the VCLibs Extension at this time.  Why?  Well, the Map control is a native control.  Adding the VCLibs dependency at this time will add the necessary information in your app’s package manifest noting the dependency and it will install any required package dependencies from the store when your user’s install it.</p>
<p>If you compile your application immediately you will notice an exception during build:</p>
<div>
<div>
<pre><span>   1:</span> 1&gt;------ Build started: Project: Application17, Configuration: Debug Any CPU ------</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> 1&gt;C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1667,5): error MSB3774: Could not find SDK <span>"Microsoft.VCLibs, Version=11.0"</span>.</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span> 1&gt;C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1667,5): error MSB3778: <span>"APPX"</span> attributes were found <span>in</span> the SDK manifest file however none of the attributes matched the targeted configuration and architecture and no <span>"APPX"</span> attribute without configuration and architecture could be found. If an appx is required then the project will fail at runtime.</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</pre>
<p><!--CRLF--></div>
</div>
<p>This is because by default the managed applications are “AnyCPU” configuration and the native control doesn’t have that configuration.  Change your app to be either x86 or amd64 and your build will succeed.  This means that yes, you will want to create multiple architecture-specific packages for your app.  The good thing is during package creation, the tools in Visual Studio make this easy for you.</p>
<h2>Creating a C++ XAML application with maps</h2>
<p>For C++ the step is to just reference the Bing Maps extension SDK and you are done.  C++ projects are always architecture-specific so you don’t have the AnyCPU situation here.</p>
<h2>Using the Map control</h2>
<p>You’ll need to get set up with an API key, which the <a href="http://msdn.microsoft.com/en-us/library/hh846498.aspx">getting started</a> docs inform you about.  Once you have that you are ready to use the control.  I’m a fan of putting the API key in my App.xaml as a resource:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Application.Resources</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>&lt;</span><span>ResourceDictionary</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>         <span>&lt;</span><span>ResourceDictionary.MergedDictionaries</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>             <span>&lt;</span><span>ResourceDictionary</span> <span>Source</span><span>="Common/StandardStyles.xaml"</span><span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>         <span>&lt;/</span><span>ResourceDictionary.MergedDictionaries</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>         <span>&lt;</span><span>x:String</span> <span>x:Key</span><span>="BingMapsApiKey"</span><span>&gt;</span>YOUR KEY HERE<span>&lt;/</span><span>x:String</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>&lt;/</span><span>ResourceDictionary</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span> <span>&lt;/</span><span>Application.Resources</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>And then in my Map control I can just refer to it:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Page</span></pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>     <span>x:Class</span><span>="Application17.BlankPage"</span></pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>xmlns</span><span>="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span></pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     <span>xmlns:x</span><span>="http://schemas.microsoft.com/winfx/2006/xaml"</span></pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     <span>xmlns:local</span><span>="using:Application17"</span></pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     <span>xmlns:d</span><span>="http://schemas.microsoft.com/expression/blend/2008"</span></pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     <span>xmlns:mc</span><span>="http://schemas.openxmlformats.org/markup-compatibility/2006"</span></pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     <span>xmlns:bing</span><span>="using:Bing.Maps"</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>     <span>mc:Ignorable</span><span>="d"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>     <span>&lt;</span><span>Grid</span> <span>Background</span><span>="{StaticResource ApplicationPageBackgroundBrush}"</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>         <span>&lt;</span><span>bing:Map</span> <span>x:Name</span><span>="MyMap"</span> <span>Width</span><span>="640"</span> <span>Height</span><span>="480"</span> </pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>             <span>Credentials</span><span>="{StaticResource BingMapsApiKey}"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  14:</span>     <span>&lt;/</span><span>Grid</span><span>&gt;</span></pre>
<p><!--CRLF--></p>
<pre><span>  15:</span> <span>&lt;/</span><span>Page</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Once I have those pieces in place, I’m done and can run my app and get full map interactivity.  Notice the xmlns declaration in my Page with the “using:Bing.Maps” notation.  Now when I run:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Bing Maps" src="http://storage2.timheuer.com/bingmaprunning.png" /></p>
<p>I can quickly add location to my app by setting the capability in the Package.appxmanifest and then wiring up the map to center on my current location…</p>
<div>
<div>
<pre><span>   1:</span> async <span>protected</span> <span>override</span> <span>void</span> OnNavigatedTo(NavigationEventArgs e)</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     Geolocator geo = <span>new</span> Geolocator();</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     geo.DesiredAccuracy = PositionAccuracy.Default;</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     var currentPosition = await geo.GetGeopositionAsync();</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     Location loc = <span>new</span> Location() { Latitude = currentPosition.Coordinate.Latitude, </pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>         Longitude = currentPosition.Coordinate.Longitude };</pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>     MyMap.SetView(</pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>         loc, <span>// location</span></pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>         13, <span>// zoom level</span></pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>         <span>true</span>); <span>//show animations)</span></pre>
<p><!--CRLF--></p>
<pre><span>  14:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  15:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>I’m excited about what the Bing team has done here and you should go grab it, read the docs and start incorporating location visualization into your Metro style XAML apps today!</p>
<p>Hope this helps!
  </p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/bing/default.aspx" rel="tag">bing</a>, <a href="http://timheuer.com/blog/Tags/bing+maps/default.aspx" rel="tag">bing maps</a>, <a href="http://timheuer.com/blog/Tags/winrt/default.aspx" rel="tag">winrt</a>, <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/geolocation/default.aspx" rel="tag">geolocation</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14828.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/dqaY7OVlM9nsTU0QjuRZgtUydfk/0/da"><img src="http://feedads.g.doubleclick.net/~a/dqaY7OVlM9nsTU0QjuRZgtUydfk/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/dqaY7OVlM9nsTU0QjuRZgtUydfk/1/da"><img src="http://feedads.g.doubleclick.net/~a/dqaY7OVlM9nsTU0QjuRZgtUydfk/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/BLurzGbUlbU" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/03/07/use-bing-maps-in-your-windows-8-xaml-applications.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a good app settings experience in XAML</title>
		<link>http://www.top-silverlight.com/2012/03/07/building-a-good-app-settings-experience-in-xaml.html</link>
		<comments>http://www.top-silverlight.com/2012/03/07/building-a-good-app-settings-experience-in-xaml.html#comments</comments>
		<pubDate>Wed, 07 Mar 2012 13:02:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/03/07/building-a-good-app-settings-experience-in-xaml.html</guid>
		<description><![CDATA[So you’ve started to kick the tires of the Windows 8 Consumer Preview and now you are building an app.  You’ve read all the UX design guidelines and started looking at some great apps on the store.   Perhaps you’ve also viewed the online documentation and some samples?  And you’ve likely read about the contract implementations [...]]]></description>
			<content:encoded><![CDATA[<p>So you’ve started to kick the tires of the <a href="http://preview.windows.com">Windows 8 Consumer Preview</a> and now you are building an app.  You’ve read all the <a href="http://design.windows.com">UX design guidelines</a> and started looking at some great apps on the store.   Perhaps you’ve also viewed the <a href="http://msdn.microsoft.com/windows">online documentation and some samples</a>?  And you’ve likely read about the contract implementations and other charms items like custom settings.  </p>
<h2>What is Settings?</h2>
<p>When I refer to Settings here I’m referring to that consistent experience in Metro style apps when the user invokes the charms bar and chooses settings.  By default <strong>every</strong> application will respond to that Settings charm.  If you do nothing you will get the default experience that you may have seen:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Default Settings experience" src="http://storage2.timheuer.com/win8-settings-default.png" /></p>
<p>The text items underneath your app title are referred to as commands.  Each application will always get the <em>Permissions</em> command.  When the user clicks this they will get some “about” information on your app (name, version, publisher) as well as the permissions the app has requested.  As an app developer, you have to do nothing to get this experience.  In addition to that the Settings pane shows some OS-level options like volume, Wi-Fi, brightness, etc. that the user can manipulate.  But you, my fellow app developer, can also implement custom settings options in your app.</p>
<h2>The custom SettingsCommand</h2>
<p>The first thing you have to do to customize your experience is implement a custom <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.applicationsettings.settingscommand.aspx#Y0">SettingsCommand</a>.  These are implemented by first listening to when the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.applicationsettings.settingspane.aspx">SettingsPane</a> will request if there are any additional commands for the current view.  Settings can be global if you have something like a “master” page setup in your XAML application, but <strong>can also</strong> be specific to a currently viewed XAML page.  It is not an either/or but a both.  I’ll leave the exercise up to you and your app on when you need which (or both).</p>
<p>First thing you have to do is listen for the event.  You would likely do this in your XAML view’s constructor:</p>
<div>
<div>
<pre><span>   1:</span> <span>public</span> BlankPage()</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>this</span>.InitializeComponent();</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     _windowBounds = Window.Current.Bounds;</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     Window.Current.SizeChanged += OnWindowSizeChanged;</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>     SettingsPane.GetForCurrentView().CommandsRequested += BlankPage_CommandsRequested;</pre>
<p><!--CRLF--></p>
<pre><span>  10:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Notice the <em>SettingsPane.GetForCurrentView().<a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.applicationsettings.settingspane.commandsrequested.aspx">CommandsRequested</a></em> event handler that I am using.  This will get triggered whenever the user invokes the Settings charm while on this view.  It is your opportunity to add more commands to that experience.  In your method for this you would create your new SettingsCommand and add them to the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.applicationsettings.settingspanecommandsrequest.applicationcommands.aspx">ApplicationCommands</a>:</p>
<div>
<div>
<pre><span>   1:</span> <span>void</span> BlankPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     ResourceLoader rl = <span>new</span> ResourceLoader();</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     SettingsCommand cmd = <span>new</span> SettingsCommand(<span>"sample"</span>, </pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>         rl.GetString(<span>"SoundOptionCommandText"</span>), (x) =&gt;</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>         {</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>             <span>// more in a minute</span></pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>         });</pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>     args.Request.ApplicationCommands.Add(cmd);</pre>
<p><!--CRLF--></p>
<pre><span>  12:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>You are able to add the text-based commands to the SettingsPane at this time.  The second argument I provided above will be the text that will display as the menu.  Notice how here I’m using <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.resources.resourceloader.aspx">ResourceLoader</a> to get the string value for the text to be displayed.  This is a best practice to ensure you give your user’s the best experience.  Even though you may not localize now, setting this up in the beginning makes it way easier to just drop in localized strings and not have to change code.  The “SoundOptionCommandText” exists as a key/value pair in a file in my project located at en/Resources.resw.</p>
<p>Now that I have this enabled and my CommandsRequested wired up, when I invoke the charm while my app is running you see my new command:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Custom SettingsCommand" src="http://storage2.timheuer.com/win8-settings-custom-1.png" /></p>
<p>Yippee!  Your custom commands will show before the Permissions one.  The next step is to actually add something valuable to the user when they click on this new command…and that means some UI.</p>
<h2>The custom Settings UI</h2>
<p>When your user clicks your new shiny command you want them to see some shiny, but relevant UI.  If you were using HTML/JS you would use the <a href="http://msdn.microsoft.com/library/windows/apps/Hh701253">WinJS.UI.SettingsFlyout</a> control to do a lot of this for you.  There is a <a href="http://code.msdn.microsoft.com/windowsapps/App-settings-sample-1f762f49">sample of this for comparison located in the Windows 8 developer samples</a>.  In XAML there isn’t the literal ‘SettingsFlyout’ control equivalent, but a set of primitives for you to create the experience.  There are a few pieces you will need in place.</p>
<p>First I create a few member variable helpers to store some items away:</p>
<ul>
<li>_windowBounds – this is the Rect of the current Window size.  I will need this for proper placement </li>
<li>_settingsWidth – The UX guidelines suggest either a 346 or 646 wide settings flyout </li>
<li>_settingsPopup – the Popup that will actually host my settings UI </li>
</ul>
<p>The <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.popup.aspx">Popup</a> is the important piece here.  It is the primitive that provides us with the “light dismiss” behavior that you see a lot in the Windows 8 experience.  This is where you have a menu/dialog and you simply tap away and it dismisses.  <em>Popup.IsLightDismissEnabled</em> gives us that functionality in our control that we will need in XAML.  Now let us go back to where we created our custom SettingsCommand and add back in the creation of our Popup and custom UI:</p>
<div>
<div>
<pre><span>   1:</span> SettingsCommand cmd = <span>new</span> SettingsCommand(<span>"sample"</span>, rl.GetString(<span>"SoundOptionCommandText"</span>), (x) =&gt;</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     _settingsPopup = <span>new</span> Popup();</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     _settingsPopup.Closed += OnPopupClosed;</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     Window.Current.Activated += OnWindowActivated;</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     _settingsPopup.IsLightDismissEnabled = <span>true</span>;</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     _settingsPopup.Width = _settingsWidth;</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     _settingsPopup.Height = _windowBounds.Height;</pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>     <span>// more to come still</span></pre>
<p><!--CRLF--></p>
<pre><span>  11:</span> });</pre>
<p><!--CRLF--></div>
</div>
<p>Notice that we are creating the Popup, setting the width to the value specified in _settingsWidth and the height to whatever the current height of the active Window is at this time.  We are also listening to the Activated event on the Window to ensure that when our Window may be de-activated for something that a user may not have done via touch/mouse interaction (i.e., some other charm invocation, snapping an app, etc.) that we dismiss the Popup correctly.  here is the OnWindowActivated method definition:</p>
<div>
<div>
<pre><span>   1:</span> <span>private</span> <span>void</span> OnWindowActivated(<span>object</span> sender, Windows.UI.Core.WindowActivatedEventArgs e)</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>if</span> (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     {</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>         _settingsPopup.IsOpen = <span>false</span>;</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     }</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span> }</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>   9:</span> <span>void</span> OnPopupClosed(<span>object</span> sender, <span>object</span> e)</pre>
<p><!--CRLF--></p>
<pre><span>  10:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>     Window.Current.Activated -= OnWindowActivated;</pre>
<p><!--CRLF--></p>
<pre><span>  12:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Notice we are also listening for the Popup.Closed event.  This is so that we can remove the OnWindowActivated method to avoid any reference leaks lying around.  Great, now let’s put some UI into our Popup.</p>
<p>For my example here I’m using a UserControl that I created to exhibit my settings needs.  Your use may vary and you may just need some simple things.  As we know in XAML there is more than one way to implement it in this flexible framework and this is just an example.  Going back to our custom SettingsCommand we now create an instance of my UserControl and set it as the Child of the Popup, setting appropriate Width/Height values as well:</p>
<div>
<div>
<pre><span>   1:</span> SettingsCommand cmd = <span>new</span> SettingsCommand(<span>"sample"</span>, rl.GetString(<span>"SoundOptionCommandText"</span>), (x) =&gt;</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     _settingsPopup = <span>new</span> Popup();</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     _settingsPopup.Closed += OnPopupClosed;</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>     Window.Current.Activated += OnWindowActivated;</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     _settingsPopup.IsLightDismissEnabled = <span>true</span>;</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     _settingsPopup.Width = _settingsWidth;</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span>     _settingsPopup.Height = _windowBounds.Height;</pre>
<p><!--CRLF--></p>
<pre><span>   9:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  10:</span>     SimpleSettingsNarrow mypane = <span>new</span> SimpleSettingsNarrow();</pre>
<p><!--CRLF--></p>
<pre><span>  11:</span>     mypane.Width = _settingsWidth;                    </pre>
<p><!--CRLF--></p>
<pre><span>  12:</span>     mypane.Height = _windowBounds.Height;</pre>
<p><!--CRLF--></p>
<pre><span>  13:</span>  </pre>
<p><!--CRLF--></p>
<pre><span>  14:</span>     _settingsPopup.Child = mypane;</pre>
<p><!--CRLF--></p>
<pre><span>  15:</span>     _settingsPopup.SetValue(Canvas.LeftProperty, _windowBounds.Width - _settingsWidth);</pre>
<p><!--CRLF--></p>
<pre><span>  16:</span>     _settingsPopup.SetValue(Canvas.TopProperty, 0);</pre>
<p><!--CRLF--></p>
<pre><span>  17:</span>     _settingsPopup.IsOpen = <span>true</span>;</pre>
<p><!--CRLF--></p>
<pre><span>  18:</span> });</pre>
<p><!--CRLF--></div>
</div>
<p>Now when the user clicks the “Sound Options” they will see my custom UI:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Custom Settings UI" src="http://storage2.timheuer.com/win8-settings-custom-2.png" /></p>
<p>And if the user taps/clicks away from the dialog then it automatically dismisses itself.  You now have the fundamentals on how to create your custom UI for settings.</p>
<h2>Some guiding principles</h2>
<p>While this is simple to implement, there are some key guiding principles that make this key for your user’s experience.  First and foremost, this should be a consistent and predictable experience for your users.  Don’t get crazy with your implementation and stay within the UX design guidelines to ensure your app gives the user confidence when using it.  Additionally, here are some of my other tips.</p>
<p><em>Header Elements</em></p>
<p>You’ll notice above that the header of the custom UI is specific and contains a few elements.  The title should be clear (and again be ideally localized) in what the settings is doing.  The background color would match your app’s branding and likely be the same as the value of BackgroundColor in your app’s package manifest.  Putting your logo (use the same image you use for your SmallLogo setting in your package manifest) helps re-enforce this is the setting only for this app and not for the system.  Additionally providing a “back” button so the user can navigate back to the root SettingsPane and not have to invoke the charm again if they wanted to change other app settings.  In my example, the button simply just calls the SettingsPane APIs again to show it:</p>
<div>
<div>
<pre><span>   1:</span> <span>private</span> <span>void</span> MySettingsBackClicked(<span>object</span> sender, RoutedEventArgs e)</pre>
<p><!--CRLF--></p>
<pre><span>   2:</span> {</pre>
<p><!--CRLF--></p>
<pre><span>   3:</span>     <span>if</span> (<span>this</span>.Parent.GetType() == <span>typeof</span>(Popup))</pre>
<p><!--CRLF--></p>
<pre><span>   4:</span>     {</pre>
<p><!--CRLF--></p>
<pre><span>   5:</span>         ((Popup)<span>this</span>.Parent).IsOpen = <span>false</span>;</pre>
<p><!--CRLF--></p>
<pre><span>   6:</span>     }</pre>
<p><!--CRLF--></p>
<pre><span>   7:</span>     SettingsPane.Show();</pre>
<p><!--CRLF--></p>
<pre><span>   8:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>You may be curious to see the XAML used for my custom UI and I’ve included that in the download at the end here as not to take up viewing area here on the key areas.</p>
<p><em>Immediate Action</em></p>
<p>Unlike some modal dialog experiences, the Settings experience should create immediate change to your application.  Don’t put confirmation/save/cancel buttons in your UI but rather have the changes take effect immediately.  For instance in my sound example, if the user invokes the Settings charm, clicks/taps on my Sound Options and toggles the Sound Effects option on/off, then the sound should immediately turn on/off.  Now implementing this philosophy may change the way you create your custom UI and/or UserControl, but take that into account when designing.</p>
<p><em>Light Dismiss</em></p>
<p>This concept of light dismiss is about honoring the user’s action and not requiring interruption.  This is why we use the Popup.IsLightDismissEnabled option as we get this capability for free.  By using this if the user taps away to another part of the application or Window, then the Popup simply dismisses.  Don’t hang confirmation dialogs in there to block the user from doing what they want, but rather honor the context change for them.</p>
<h2>Summary</h2>
<p>The Windows platform has afforded us developers a lot of great APIs to create very predictable and consistent user experiences for the common things our apps will need.  Settings is one of those simple, yet effective places to create confidence in your application and a consistent Windows experience for your users.  Stick to the principles:</p>
<ul>
<li>Set up custom commands that make sense for the context of the view and/or for the app as a whole </li>
<li>Create and show your UI according to the UX design guidelines </li>
<li>Have your settings immediately affect the application </li>
<li>Ensure that you use the dismiss model </li>
</ul>
<p>Combine all these and you will be set.  Everything I talk about above is supported in XAML and WinRT.  My example is in C# because I’m most proficient in that language.  But this 100% equally applies in C++ as well and should be identical in practice.</p>
<p>You may be saying to yourself <em>wouldn’t this make a great custom control?</em>  Ah, stay tuned and <a href="http://feeds.timheuer.com/timheuer">subscribe here</a> <img src='http://www.top-silverlight.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> !</p>
<p>Hope this helps!</p>
<p>Download Sample: <a href="http://s3.amazonaws.com:80/storage2.timheuer.com/SettingsExample.zip">SettingsExample.zip</a> </p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/winrt/default.aspx" rel="tag">winrt</a>, <a href="http://timheuer.com/blog/Tags/settings/default.aspx" rel="tag">settings</a>, <a href="http://timheuer.com/blog/Tags/appbar/default.aspx" rel="tag">appbar</a>, <a href="http://timheuer.com/blog/Tags/winjs/default.aspx" rel="tag">winjs</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14827.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/lkIw6_MVBNOsqXK6u0S8Au9lbWM/0/da"><img src="http://feedads.g.doubleclick.net/~a/lkIw6_MVBNOsqXK6u0S8Au9lbWM/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/lkIw6_MVBNOsqXK6u0S8Au9lbWM/1/da"><img src="http://feedads.g.doubleclick.net/~a/lkIw6_MVBNOsqXK6u0S8Au9lbWM/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/b2lnSX2Ta0o" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/03/07/building-a-good-app-settings-experience-in-xaml.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XAML AppBar Button Styles for Windows 8</title>
		<link>http://www.top-silverlight.com/2012/03/06/xaml-appbar-button-styles-for-windows-8.html</link>
		<comments>http://www.top-silverlight.com/2012/03/06/xaml-appbar-button-styles-for-windows-8.html#comments</comments>
		<pubDate>Mon, 05 Mar 2012 23:57:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[新闻News]]></category>
		<guid isPermaLink="false">http://www.top-silverlight.com/2012/03/06/xaml-appbar-button-styles-for-windows-8.html</guid>
		<description><![CDATA[An old colleague of mine and now HTML extraordinaire, Adam Kinney, just recently posted on his spelunking of some styling in both WinJS and XAML runtimes with regard to icons/buttons to use in a Metro style app and the AppBar. Adam has two posts: (WinJS) Windows 8 AppBarIcons enumerated and visualized (XAML) Windows 8 AppBarButtonStyles [...]]]></description>
			<content:encoded><![CDATA[<p>An old colleague of mine and now HTML extraordinaire, <a href="http://adamkinney.com/">Adam Kinney</a>, just recently posted on his spelunking of some styling in both WinJS and XAML runtimes with regard to icons/buttons to use in a Metro style app and the AppBar.</p>
<p>Adam has two posts:</p>
<ul>
<li>(WinJS) <a href="http://adamkinney.com/blog/2012/03/04/windows-8-appbaricons-enumerated-and-visualized/">Windows 8 AppBarIcons enumerated and visualized</a> </li>
<li>(XAML) <a href="http://adamkinney.com/blog/2012/03/05/windows-8-appbarbuttonstyles-enumerated-and-visualized/">Windows 8 AppBarButtonStyles enumerated and visualized</a> </li>
</ul>
<p>Basically what these do is define a set of styles, both in CSS and XAML, that map back to unicode values in the Segoe UI Symbol font.  This contains a set of glyphs that are well-suited for use within an AppBar.  As an example in WinJS you would use:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>button</span> <span>data-win-control</span><span>="WinJS.UI.AppBarCommand"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>         <span>data-win-options</span><span>="{icon:'back', label:'Back'}"</span><span>&gt;&lt;</span><span>button</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>And in XAML you would use:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>Button</span> <span>Style</span><span>="{StaticResource PreviousAppBarButtonStyle}"</span> <span>/&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>One thing that Adam points out is that WinJS includes definitions for a LOT of styles while the included StandardStyles.xaml file (provided for you when you create a new project in Visual Studio) defines a much smaller subset.  When determining what styles to include in the XAML set, we opted for choosing the most common rather than to bloat the ResourceDictionary with things you may not use.</p>
<blockquote>
<p><strong>NOTE</strong>: Even within the provided one, you should always make it a best practice to REMOVE styles/templates that you aren’t using so the parser doesn’t have to worry about them.</p>
</blockquote>
<p>Adam also notes that he likes the style of defining the WinJS ones a bit better as he mentions the XAML syntax feels heavy.  I commented on his blog that WinJS is doing a lot of work for him here that has already defined the style.  If WinJS didn’t exist, surely it would be ‘heavy’ in defining them.  I’m still not sure why the XAML one feels heavy (once you just assume that a definition has been made for you in the ResourceDictionary provided – especially when I look above, they basically both look the same…but I digress.</p>
<p>One thing that I wanted to point out was how the tools, Visual Studio and Blend, help make it way easy to choose and quickly visualize these styles on the design surface.  For HTML/JS apps you need to use Blend for this as VS doesn’t support this feature at this time.  When in Blend in your HTML/JS app you can open up the control palette and see a helper for AppBar Command Button:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Blend and AppBar Command Button" src="http://storage2.timheuer.com/hblend-appbarcommand.png" /></p>
<p>And this produces a generic button definition much like above:</p>
<div>
<div>
<pre><span>   1:</span> <span>&lt;</span><span>button</span> <span>data-win-control</span><span>="WinJS.UI.AppBarCommand"</span> </pre>
<p><!--CRLF--></p>
<pre><span>   2:</span>         <span>data-win-options</span><span>="{label:'Button', type:'button'}"</span><span>&gt;&lt;/</span><span>button</span><span>&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>What you can’t do from now (that I could see) is quickly <strong>pick</strong> from a set of those data-win-options to choose which one you want…so you still have to know what the definition is that you want for the icon/label.  Let’s contrast that with the XAML experience with strongly-defined styles.  In VS or Blend I can use the resource picker to pick from a set of styles that apply to my control type, in this case button:</p>
<p><img style="float: none;margin-left: auto;margin-right: auto" alt="Blend for XAML AppBar Resources" src="http://storage2.timheuer.com/xblend-appbarcommand.png" /></p>
<p>I can quickly change and see the option on the design surface.  Now again, if you don’t need all these styles, then please delete what you aren’t using from your ResourceDictionary.</p>
<p>It is great that we have design-time implementations of these styles and of course I’m partial to the XAML one as more familiar to me.  Adam pointed out the discrepancy of not having all the styles defined.  As I note, you shouldn’t have defined what you don’t need, but in the spirit of adding value, here’s an <a href="http://storage2.timheuer.com/StandardStyles.zip">updated StandardStyles.zip</a> with all the 150 icons defined.</p>
<p>Hope this helps!
  </p>
<div><span>tags: <a href="http://timheuer.com/blog/Tags/windows+8/default.aspx" rel="tag">windows 8</a>, <a href="http://timheuer.com/blog/Tags/windows/default.aspx" rel="tag">windows</a>, <a href="http://timheuer.com/blog/Tags/xaml/default.aspx" rel="tag">xaml</a>, <a href="http://timheuer.com/blog/Tags/winrt/default.aspx" rel="tag">winrt</a>, <a href="http://timheuer.com/blog/Tags/winjs/default.aspx" rel="tag">winjs</a>, <a href="http://timheuer.com/blog/Tags/appbar/default.aspx" rel="tag">appbar</a></span></div>
<div>
<hr />
<div>This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution By license.</a></div>
</div>
<p><img src="http://timheuer.com/blog/aggbug/14826.aspx" width="1" height="1" /></p>
<p><a href="http://feedads.g.doubleclick.net/~a/tUy54UO-nxRGzluyI5MEgFz_yE8/0/da"><img src="http://feedads.g.doubleclick.net/~a/tUy54UO-nxRGzluyI5MEgFz_yE8/0/di" border="0"></img></a><br />
<a href="http://feedads.g.doubleclick.net/~a/tUy54UO-nxRGzluyI5MEgFz_yE8/1/da"><img src="http://feedads.g.doubleclick.net/~a/tUy54UO-nxRGzluyI5MEgFz_yE8/1/di" border="0"></img></a></p>
<p><img src="http://feeds.feedburner.com/~r/timheuer/~4/o6Biof6ldHQ" height="1" width="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.top-silverlight.com/2012/03/06/xaml-appbar-button-styles-for-windows-8.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

