Compiled Experience Windows Platform Development http://compiledexperience.com en Thu, 31 Jul 2014 00:37:55 +0000 Thu, 31 Jul 2014 00:37:55 +0000 Spinkit.Xaml now supports Universal apps. <p>A few months ago I showed off <a href="https://github.com/nigel-sampson/spinkit-xaml">Spinkit.Xaml</a> a set of styles for Windows 8 Progress Ring to make your project look a little more interesting.</p> <p>I&#39;ve just pushed a new version to <a href="https://www.nuget.org/packages/SpinKit.Xaml/">Nuget</a> (1.1.0.0) that supports Windows Phone 8.1 which means you can use the styles in univeral projects.</p> <p>Check it out and have a play, if you&#39;re uising it in a project then let me know.</p> Wed, 30 Jul 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/spinkit-xaml-universal http://compiledexperience.com/blog/posts/spinkit-xaml-universal nigel.sampson@compiledexperience.com (Nigel Sampson) App state and Caliburn.Micro <p>As well as posting here a lot of things relating to Caliburn.Micro will be on the new official website. The first is the start of a <a href="http://caliburnmicro.com/announcements/application-state-part-1/">discussion of application state</a>.</p> Wed, 23 Jul 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/caliburn-state-1 http://compiledexperience.com/blog/posts/caliburn-state-1 nigel.sampson@compiledexperience.com (Nigel Sampson) Brand new website <p>Some of you may have noticed but I&#39;ve rebuilt the website / blog. Previously it was sitting as a custom Asp.Net MVC app running on <a href="http://azure.microsoft.com/en-us/">Azure websites</a> using SQL Azure as a back end.</p> <p>In an effort to try new things this new website is using <a href="http://jekyllrb.com/">Jekyll</a> and <a href="https://pages.github.com/">GitHub pages</a>. While setting up the new website was a piece of cake most of the work went into preserving as many existing uri&#39;s as possible.</p> <p>If I have missed any I&#39;d love to hear about them.</p> Mon, 14 Jul 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/new-website http://compiledexperience.com/blog/posts/new-website nigel.sampson@compiledexperience.com (Nigel Sampson) Building a colour palette for your app <p>When creating your app on both the phone and tablet almost all <a href="http://msdn.microsoft.com/library/windows/apps/dn439319.aspx">guidelines</a> will tell you create a consistent colour palette. There&#39;s a lot of tools out there to help you design your palette, <a href="https://kuler.adobe.com/">Kuler</a> from Adobe is a good example. But what&#39;s the best way to use our palette in your app?</p> <p>There&#39;s a couple of goals here, the first is we only want to have to define our colours once for the entire app. This way if we need to tweak them or do a wholesale replacement we&#39;re not spending hours hunting for every instance of that colour.</p> <p>The second is to provide an easy way to override existing theme resources.</p> <p>What I tend to do is create a separate resource dictionary for the palette, this is because it&#39;s usually imported into other dictionaries and I want to keep the repetition low. The other resource dictionary I&#39;ll create at this point is a theme overrides one, this contains all the redefinition of the built in resources using the new palette of colours.</p> <p>In our palette dictionary we&#39;ll want to define the colours and brushes separately, this is because despite most of the time we&#39;ll be using the brush there will be times the colour is required. Naturally the brush definition refers to the colour so we&#39;re sticking with our goals. Typically a colour / brush definition will look like:</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;Color</span> <span class="na">x:Key=</span><span class="s">&quot;MajorAccentColor&quot;</span><span class="nt">&gt;</span>#FF2980B9<span class="nt">&lt;/Color&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;MajorAccentBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource MajorAccentColor}&quot;</span><span class="nt">/&gt;</span> </code></pre></div> <p>Sometimes your designs may make use of the same colour but with different alpha (or opacity) values. For me if this brush is going to be used through the app I&#39;ll define it within the palette like so:</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;Color</span> <span class="na">x:Key=</span><span class="s">&quot;MinorAccentColor&quot;</span><span class="nt">&gt;</span>#FF80B929<span class="nt">&lt;/Color&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;MinorAccentBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource MinorAccentColor}&quot;</span><span class="nt">/&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;MinorAccentOverlayBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource MinorAccentColor}&quot;</span> <span class="na">Opacity=</span><span class="s">&quot;0.5&quot;</span><span class="nt">/&gt;</span> </code></pre></div> <p>However if it&#39;s a one off I&#39;ll probably define the brush as inline XAML referring back to our colour resource.</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;controls:Sidebar</span> <span class="na">x:Name=</span><span class="s">&quot;Sidebar&quot;</span> <span class="na">IsExpandedChanged=</span><span class="s">&quot;OnIsExpandedChanged&quot;</span><span class="nt">&gt;</span> <span class="nt">&lt;controls:Sidebar.Background&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource SidebarBackgroundColor}&quot;</span> <span class="na">Opacity=</span><span class="s">&quot;0.5&quot;</span><span class="nt">/&gt;</span> <span class="nt">&lt;/controls:Sidebar.Background&gt;</span> </code></pre></div> <p>I try to name the colour / brush pairs in generic names more along the lines of their usage than what they look like colour wise. This is because they&#39;ll often be tweaked and it can look rather silly to have a resource named &quot;RedColour&quot; that&#39;s actually blue.</p> <p>Now our palette is defined let&#39;s make use of it, the first thing I go through and do is redefine quite a few of the out of the box theme resources to make the controls more in line with the rest of my app. It&#39;s these little bits that really polish an app, I die a little on the inside when I see the default purple in combo boxes and progress rings. I swear Microsoft chose that colour so people would be forced to deal with it but a lot don&#39;t.</p> <p>In my theme overrides resource dictionary I import the palette and start to define styles for the controls in terms of colours from the palette. We don&#39;t need to redefine every single resource, typically only the ones that add the accent colour. For instance with the ComboBox control the overrides are:</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;ResourceDictionary.MergedDictionaries&gt;</span> <span class="nt">&lt;ResourceDictionary</span> <span class="na">Source=</span><span class="s">&quot;/Resources/Palette.xaml&quot;</span><span class="nt">/&gt;</span> <span class="nt">&lt;/ResourceDictionary.MergedDictionaries&gt;</span> </code></pre></div><div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;ComboBoxItemSelectedBackgroundThemeBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource MinorAccentColor}&quot;</span> <span class="nt">/&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;ComboBoxItemSelectedPointerOverBackgroundThemeBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource LightMinorAccentColor}&quot;</span> <span class="nt">/&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;ComboBoxSelectedBackgroundThemeBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource MinorAccentColor}&quot;</span> <span class="nt">/&gt;</span> <span class="nt">&lt;SolidColorBrush</span> <span class="na">x:Key=</span><span class="s">&quot;ComboBoxSelectedPointerOverBackgroundThemeBrush&quot;</span> <span class="na">Color=</span><span class="s">&quot;{StaticResource LightMinorAccentColor}&quot;</span> <span class="nt">/&gt;</span> </code></pre></div> <p>That&#39;s pretty much it, a nice easy way to define your colour scheme realistically in any XAML app and reuse it well. </p> Thu, 10 Apr 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/colour-palette http://compiledexperience.com/blog/posts/colour-palette nigel.sampson@compiledexperience.com (Nigel Sampson) Caliburn.Micro and Universal Apps <p>There’s been a lot of announcements here at <a href="http://www.buildwindows.com/">Build</a> today, including the availability of the Windows Phone 8.1 SDK. This release brings a common Xaml UI framework between Windows Phone and Windows and some tooling support to enable you to easily share C# and Xaml between the two platforms called <a href="http://blogs.windows.com/windows/b/buildingapps/archive/2014/04/02/windows-store-universal-windows-app-opportunity.aspx">Universal Windows apps</a>.</p> <p>I’m also really pleased to say I’ve recently pushed the code to enable you to use <a href="https://github.com/BlueSpire/Caliburn.Micro">Caliburn.Micro</a> on the new frameworks. It’s available on <a href="https://github.com/BlueSpire/Caliburn.Micro">GitHub</a> and on <a href="http://www.nuget.org/packages/Caliburn.Micro/2.0.0-beta2">Nuget</a> under version 2.0.0-beta2, this version adds the new Windows Phone 8.1 platform to the Portable core assembly and appropriate Platform assembly.</p> <p>Because the new Windows Phone platform is closely aligned with the Windows platform you’ll notice that we build the app like it’s a Windows 8.1 app. For CM this means a few changes from Windows Phone 8, such as using CaliburnApplication rather than Bootstrapper, but for the most part most of the tutorials for using CM on Windows 8.1 will apply to Windows Phone 8.1. </p> <p>If you still want to build using the Windows Phone 8 Silverlight platform then WP8 version is still available from the same package and works just as it did before.</p> <p>To show off how powerful it is now the repository has a <a href="https://github.com/BlueSpire/Caliburn.Micro/tree/master/samples/CM.HelloUniversal">sample Universal app</a> where we share views and view models across both platforms, but still enable us to have custom views for shared view models. This coupled with Portable class libraries enables a variety of strategies to share code over many number of platforms. I’ll hopefully be covering a lot of these in the near future.</p> <p>As we get to grips with some of the stuff still to be announced over the coming days there should be more to add to this.</p> <p>On a related note I just want to thank <a href="http://www.markermetro.com">Marker Metro</a>, I wouldn’t have been able to get this release ready so quickly without their support.</p> Thu, 03 Apr 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/caliburn-micro-universal http://compiledexperience.com/blog/posts/caliburn-micro-universal nigel.sampson@compiledexperience.com (Nigel Sampson) DVLUP available in New Zealand <p>It&#39;s been a long time coming but I&#39;m really happy to say the Nokia developer reward program <a href="http://www.dvlup.com">DVLUP</a> is now available in New Zealand. We at <a href="http://www.markermetro.com">Marker Metro</a> have been working with Nokia to set up a launch here in Auckland. Come along to find out more about it and get a recap of the news and announcements from Build. <a href="www.dvlup.com/nigel.sampson/invite">RSVP here</a>.</p> <p>If you already want to sign up then use <a href="www.dvlup.com/nigel.sampson/invite">this link</a> and score me some bonus XP.</p> Tue, 01 Apr 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/dvlup-nz http://compiledexperience.com/blog/posts/dvlup-nz nigel.sampson@compiledexperience.com (Nigel Sampson) Using value converters by convention <p>The application of a convention in <a href="https://github.com/BlueSpire/Caliburn.Micro">Caliburn.Micro</a> is a bit of a pipeline with multiple steps, almost all of them we can modify, let&#39;s look at bringing value converters into the equation.</p> <p>Most of the time the default conventions tend to bring like-minded types together. That&#39;s natural in that conventions should be reasonably intuitive, like a string property on the view model being bound to the Text property of the TextBox.</p> <p>Sometimes these types don&#39;t always line up, which is where value converters typically come in. The most common of these being converting between boolean and visibility properties.</p> <p>Caliburn.Micro does a little bit of work here already, if a convention calls for properties of the two above types (boolean and visibility) then it automatically adds a BooleanToVisibilityConverter to the Binding.</p> <p>We can extend this through the modification of the <a href="https://github.com/BlueSpire/Caliburn.Micro/blob/master/src/Caliburn.Micro.Platform/ConventionManager.cs">ConventionManager.ApplyValueConverters</a> method, but why would we do this? In an app I&#39;m currently working on I want to use relative dates through the app, I&#39;m using a value converter that leverages the <a href="https://github.com/MehdiK/Humanizer">Humanizer</a> library (check it out if you haven&#39;t already) to do the conversion. This means everywhere I want to out put the date I need to dispense with the normal convention using x:Name and set up the binding with the value converter. A bit of a pain and there&#39;s always a chance I could miss one.</p> <p>What we need to do is modify Caliburn such that when it applies a convention between a DateTime (or DateTimeOffset) property and a TextBlock&#39;s Text when add the converter to the process.</p> <p>The code is pretty simple, the only weird part is taking a reference to the default implementation first so that we can keep the default behavior as well.</p> <div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="kt">var</span> <span class="n">baseApplyValueConverter</span> <span class="p">=</span> <span class="n">ConventionManager</span><span class="p">.</span><span class="n">ApplyValueConverter</span><span class="p">;</span> <span class="n">ConventionManager</span><span class="p">.</span><span class="n">ApplyValueConverter</span> <span class="p">=</span> <span class="p">(</span><span class="n">binding</span><span class="p">,</span> <span class="n">bindableProperty</span><span class="p">,</span> <span class="n">property</span><span class="p">)</span> <span class="p">=&gt;</span> <span class="p">{</span> <span class="n">baseApplyValueConverter</span><span class="p">(</span><span class="n">binding</span><span class="p">,</span> <span class="n">bindableProperty</span><span class="p">,</span> <span class="n">property</span><span class="p">);</span> <span class="k">if</span> <span class="p">(</span><span class="n">bindableProperty</span> <span class="p">==</span> <span class="n">TextBlock</span><span class="p">.</span><span class="n">TextProperty</span> <span class="p">&amp;&amp;</span> <span class="k">typeof</span><span class="p">(</span><span class="n">DateTime</span><span class="p">).</span><span class="n">IsAssignableFrom</span><span class="p">(</span><span class="n">property</span><span class="p">.</span><span class="n">PropertyType</span><span class="p">))</span> <span class="n">binding</span><span class="p">.</span><span class="n">Converter</span> <span class="p">=</span> <span class="k">new</span> <span class="n">RelativeDateTimeConverter</span><span class="p">();</span> <span class="k">if</span> <span class="p">(</span><span class="n">bindableProperty</span> <span class="p">==</span> <span class="n">TextBlock</span><span class="p">.</span><span class="n">TextProperty</span> <span class="p">&amp;&amp;</span> <span class="k">typeof</span><span class="p">(</span><span class="n">DateTimeOffset</span><span class="p">).</span><span class="n">IsAssignableFrom</span><span class="p">(</span><span class="n">property</span><span class="p">.</span><span class="n">PropertyType</span><span class="p">))</span> <span class="n">binding</span><span class="p">.</span><span class="n">Converter</span> <span class="p">=</span> <span class="k">new</span> <span class="n">RelativeDateTimeConverter</span><span class="p">();</span> <span class="p">};</span> </code></pre></div> <p>Now whenever a convention on a TextBlock is wired to a DateTime it will display a relative date time. We can remove all our bindings and converters from code and go back to simple x:Name conventions.</p> Thu, 27 Mar 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/value-converters-by-convention http://compiledexperience.com/blog/posts/value-converters-by-convention nigel.sampson@compiledexperience.com (Nigel Sampson) Some thoughts about custom Uri Protocols <p>I&#39;ve seen a lot of content around lately discussing the use of <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206987(v=vs.105).aspx">custom uri protocols in your Windows Tablet and Phone apps</a>. They&#39;re a great way to have other apps launch your app in a deep link kind of way, however I don&#39;t think developers are really using them to their full potential.</p> <p><a href="http://blog.mrlacey.co.uk/2014/03/325-windows-phone-apps-you-can-launch.html">Matt Lacey</a> has a great post listing some of the 300 or so apps that implement custom uri protocols and their protocol name. Looking through the list a couple of things jump out at me.</p> <p>The first is that there&#39;s no documentation about the protocol itself, even with the protocol name from the list I have no real idea about how to use it. Some developers like <a href="http://lazywormapps.com/">Lazyworm Apps</a> have <a href="http://lazywormapps.com/metrotube-uri-schema.html">documented their metrotube protocol</a> but the amount that have are few and far between. There needs to be a central resource for this list including documentation.</p> <p>My second observation is that almost all the protocols are completely unique to that app, usually derived from the app name. This means that any other app is limited to launch that and only that app. The end user also doesn&#39;t have a choice of which app they want to use to handle that protocol.</p> <p>This problem is caused by a lack of global protocols besides the usual suspects of http, mailto etc. There are no established protocols for things like &quot;watch a youtube video&quot; leaving all the protocols as their own little islands.</p> <p>What I&#39;d love to see is the whole app protocol thing expanded so we can have a rich ecosystem of apps plugging into to fill different parts of a workflow, probably not going to happen but a guy can dream right?</p> Thu, 20 Mar 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/uri-protocols http://compiledexperience.com/blog/posts/uri-protocols nigel.sampson@compiledexperience.com (Nigel Sampson) Scaling with a PathIcon <p>The new <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.appbarbutton.aspx">AppBarButton</a> control in Windows 8.1 is incredibly useful, the ability to use symbols, gylphs, images or paths as an icon within the button makes it a lot easier to customise that in 8.0. There&#39;s just one slight problem. </p> <p><a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.pathicon.aspx">Path Icon</a> doesn&#39;t scale the Path geometry to fit within the button, it renders just as the Path geometry is specified which is kind of awkward. </p> <p>We could try and re-template PathIcon but that&#39;s probably overkill. The easiest thing to do is to rescale the Path, tools like <a href="http://www.inkscape.org/en/">Inkscape</a> would be one way to do it. Thankfully Christian Mosers has created a really simple tool to transform Path geometry down to the appropriate scale. It&#39;s called <a href="http://wpftutorial.net/GeometryTransformer.html">Geometry Transformer</a> and is available on his <a href="http://wpftutorial.net/GeometryTransformer.html">website</a>. </p> Thu, 13 Mar 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/scaling-pathicon http://compiledexperience.com/blog/posts/scaling-pathicon nigel.sampson@compiledexperience.com (Nigel Sampson) Custom Special Values in Caliburn.Micro <p><a href="https://github.com/BlueSpire/Caliburn.Micro">Caliburn.Micro</a> has features to allow you bind methods to actions with parameters. Check out the Action Parameters section of the <a href="https://caliburnmicro.codeplex.com/wikipage?title=All%20About%20Actions&amp;referringTitle=Documentation">documentation</a>. Part of this set of features includes &quot;special values&quot; such as $eventArgs or $dataContext, these allow an easy to access information contextual to the action. How can we use them?</p> <p>I use these special values in a number of different ways. When binding a list of values the item template may contain a button with the following:</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;Button</span> <span class="na">Style=</span><span class="s">&quot;{StaticResource ContentButton}&quot;</span> <span class="na">cm:Message.Attach=</span><span class="s">&quot;ViewSection($dataContext)&quot;</span><span class="nt">&gt;</span> </code></pre></div> <p>This action bubbles up to the root model passing the item in the list the button was pressed for.</p> <div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="k">public</span> <span class="k">void</span> <span class="nf">ViewSection</span><span class="p">(</span><span class="n">RepositorySection</span> <span class="k">group</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span> </code></pre></div> <p>Another is making use of the ItemClick functionality on GridView and ListView in Windows 8. This provides similar functionality without requiring buttons in your item templates. The difference is that clicked item is in the event args so I&#39;d use syntax something similar to:</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;ListView</span> <span class="na">cm:Message.Attach=</span><span class="s">&quot;[Event ItemClick] = [SelectItem($eventArgs)]&quot;</span> <span class="na">IsItemClickEnabled=</span><span class="s">&quot;True&quot;</span><span class="nt">&gt;</span> </code></pre></div><div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="k">public</span> <span class="k">void</span> <span class="nf">SelectItem</span><span class="p">(</span><span class="n">ItemClickEventArgs</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span> </code></pre></div> <p>Another example is around pinning tiles in Windows 8, for better user experience we want to pass an invocation point to SecondaryTile.RequestCreateAsync to ensure the popup is near the element that invoked it. You can get access to element using $source or the $executionContext.</p> <div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="k">public</span> <span class="k">async</span> <span class="k">void</span> <span class="nf">ToggleTile</span><span class="p">(</span><span class="n">ActionExecutionContext</span> <span class="n">context</span><span class="p">)</span> <span class="p">{</span> <span class="kt">var</span> <span class="n">transform</span> <span class="p">=</span> <span class="n">context</span><span class="p">.</span><span class="n">Source</span><span class="p">.</span><span class="n">TransformToVisual</span><span class="p">(</span><span class="k">null</span><span class="p">);</span> <span class="kt">var</span> <span class="n">invocationPoint</span> <span class="p">=</span> <span class="n">transform</span><span class="p">.</span><span class="n">TransformPoint</span><span class="p">(</span><span class="k">new</span> <span class="n">Point</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0</span><span class="p">));</span> <span class="p">...</span> <span class="p">}</span> </code></pre></div> <p>While all these solutions solve the problem at hand they do make the code messier than I&#39;d ideally like. The ItemClick example forces you view model to depend on a xaml event args object with an internal constructor. While the invocation point sample forces the view model to start dealing with UI elements and their layout on the screen.</p> <p>So how do we solve these problems? We can actually create custom special values, this removes the weird dependencies on the view model and increases code reuse as the special values are only dealt with once. For the above examples we&#39;d have the following code in our bootstrapper (or application) depending platform.</p> <div class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="n">MessageBinder</span><span class="p">.</span><span class="n">SpecialValues</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="s">&quot;$invocationpoint&quot;</span><span class="p">,</span> <span class="n">c</span> <span class="p">=&gt;</span> <span class="n">c</span><span class="p">.</span><span class="n">Source</span><span class="p">.</span><span class="n">TransformToVisual</span><span class="p">(</span><span class="k">null</span><span class="p">).</span><span class="n">TransformPoint</span><span class="p">(</span><span class="k">new</span> <span class="n">Point</span><span class="p">()));</span> <span class="n">MessageBinder</span><span class="p">.</span><span class="n">SpecialValues</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span><span class="s">&quot;$clickeditem&quot;</span><span class="p">,</span> <span class="n">c</span> <span class="p">=&gt;</span> <span class="p">((</span><span class="n">ItemClickEventArgs</span><span class="p">)</span><span class="n">c</span><span class="p">.</span><span class="n">EventArgs</span><span class="p">).</span><span class="n">ClickedItem</span><span class="p">);</span> </code></pre></div> <p>Important points to note is that the key&#39;s must start with $ and be lowercase (they don&#39;t need to be in the xaml though). We can now change our xaml for our examples to the following.</p> <div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;ListView</span> <span class="na">cm:Message.Attach=</span><span class="s">&quot;[Event ItemClick] = [SelectIssue($clickedItem)]&quot;</span> <span class="nt">/&gt;</span> </code></pre></div><div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;AppBarButton</span> <span class="na">cm:Message.Attach=</span><span class="s">&quot;TogglePin($invocationPoint)&quot;</span> <span class="nt">/&gt;</span> </code></pre></div> <p>There&#39;s a myriad of ways this trick could possibly be put to use. I&#39;m going back through old projects and looking where I&#39;m depending on special values and seeing if they can be simplified. </p> Sun, 02 Mar 2014 00:00:00 +0000 http://compiledexperience.com/blog/posts/special-values http://compiledexperience.com/blog/posts/special-values nigel.sampson@compiledexperience.com (Nigel Sampson)