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

<channel>
	<title>Scott Logic</title>
	<atom:link href="http://www.scottlogic.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scottlogic.co.uk</link>
	<description>Financial Software Development</description>
	<lastBuildDate>Thu, 17 May 2012 11:28:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Engagement Manager</title>
		<link>http://www.scottlogic.co.uk/2012/05/engagement-manager/</link>
		<comments>http://www.scottlogic.co.uk/2012/05/engagement-manager/#comments</comments>
		<pubDate>Thu, 03 May 2012 12:59:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Vacancies]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=150051</guid>
		<description><![CDATA[Very competitive salary + bonus + benefits; Newcastle Upon Tyne 

]]></description>
			<content:encoded><![CDATA[<p>Scott Logic is a growing software consultancy which provides the very best in bespoke financial software for leading financial institutions. Our clients demand that we stay at the cutting-edge: we design complex business-critical systems, ranging from sophisticated graphical research analysis tools through to back-office settlement platforms. </p>
<p>As part of our growth strategy we are recruiting an Engagement Manager to join our team of highly-skilled professionals. This role is a hybrid delivery, stakeholder engagement and account management role and ideal candidates will have worked in a senior IT capacity. As Engagement Manager you will lend your expertise in relationship management to develop and delivering successful engagement strategies. Whilst not a pure sales role, the role will nurture on-going client relationships and the creation of new business and opportunities will form part of that activity.</p>
<p>Key Responsibilities:</p>
<ul>
<li>Drive the prospecting and sales process and manage the handoff between the sales and delivery process.</li>
<li>Drive initial project scoping and start-up needs, identify/assess risks and develop risk mitigation strategies.</li>
<li>Oversee all client delivery and act as the “voice of the customer” by ensuring client expectations are met by the Scott Logic team throughout the delivery process.</li>
<li>Ensure any issues escalated by the Scott Logic team are addressed.</li>
<li>Manage project reporting and other vital communication with the client and project teams.</li>
<li>Manage the production of project commercials and PR material, e.g. terms and conditions and work orders, case studies and website material.</li>
<li>Expand contacts with key client executives and maintain strong post-engagement relationships, introducing new opportunities accordingly.</li>
<li>Identify needs the client may not recognize and ensure that proposed solutions are linked to client objectives and future needs.</li>
</ul>
<p>The successful candidate will essentially display the following skillset:</p>
<ul>
<li>Strong and proven stakeholder engagement and relationship management skills within an IT environment. Evidence of having managed and influenced a variety of business and IT stakeholders at a senior level.</li>
<li>Proven commercial and financial awareness skills – negotiation and experience of creating and managing commercial contracts.</li>
<li>Outstanding verbal and written skills as well as proven ability to develop and deliver well-written documents and presentations.</li>
<li>A high level of resilience, flexibility and a proven ability to handle the requirements of demanding clients.</li>
<li>At least 3 years in a role with accountability for client engagement and/or delivery of IT projects.</li>
</ul>
<p>Whilst we have provide a list of our “most wanted” skills, we would like to hear from you if you have a project or programme management background, especially if you have managed one or more software development teams. Also we are keen to hear from IT professionals who have had overall accountability of a key customer relationship either internally or as a supplier: managing issues, problem solving etc.  If you have financial experience that would be an added bonus as is an interest in developing leads within a “soft” sales environment.<br />
Scott Logic offers a highly competitive salary and benefits package, including:</p>
<ul>
<li>Performance and profit related bonus scheme</li>
<li>25 days holiday per year, growing with length of service up to 30 days</li>
<li>Life assurance</li>
<li>Contributory pension scheme</li>
<li>Referral programme – payable to anyone who refers a successful candidate.</li>
</ul>
<p>A CV and covering letter specifying your areas of expertise and interest, along with your salary expectations, should be sent to <a href="mailto:applications@scottlogic.co.uk">applications@scottlogic.co.uk</a> quoting reference number ENGMGR01. The closing date for applications is 21st May, 2012.</p>
<p>Direct applicants only please.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2012/05/engagement-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping in WPF, Silverlight and WP7</title>
		<link>http://www.scottlogic.co.uk/2012/05/mapping-in-wpf-silverlight-and-wp7/</link>
		<comments>http://www.scottlogic.co.uk/2012/05/mapping-in-wpf-silverlight-and-wp7/#comments</comments>
		<pubDate>Wed, 02 May 2012 08:10:23 +0000</pubDate>
		<dc:creator>Nicholas Wolverson</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=144978</guid>
		<description><![CDATA[In this article I show a simple example of integrating Bing and Google mapping into in WPF, Silverlight, and Windows Phone applications. I was inspired to investigate how easy it is to get up and running with maps on these platforms when I saw how similar the Bing APIs are in each case. While Google [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I show a simple example of integrating Bing and Google mapping into in WPF, Silverlight, and Windows Phone applications. I was inspired to investigate how easy it is to get up and running with maps on these platforms when I saw how similar the Bing APIs are in each case. While Google does not provide specific mapping controls for Silverlight/WPF, it’s still quite straightforward to integrate the browser version, once you know where to start.</p>
<p><span id="more-144978"></span></p>
<h3>Overview</h3>
<div>
<table rules="all">
<tbody>
<tr>
<td></td>
<td>WPF</td>
<td>Silverlight</td>
<td>WP7</td>
<td>Metro</td>
</tr>
<tr>
<td>Bing</td>
<td><a href="http://msdn.microsoft.com/en-us/library/hh750210.aspx">Bing Maps WPF Control</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/ee681884.aspx">Bing Maps Silverlight Control</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/ff941096(v=VS.92).aspx">Bing Maps Silverlight Control for Windows Phone</a></td>
<td><a href="http://msdn.microsoft.com/en-us/library/hh846481.aspx">Bing Maps for Metro Style Apps (Beta)</a></td>
</tr>
<tr>
<td>Google</td>
<td><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.aspx">WebBrowser</a> +<br />
<a href="http://code.google.com/apis/maps/documentation/javascript/">Maps JavaScript API</a><br />
<br />(or <a href="http://code.google.com/apis/maps/documentation/flash/">Maps API for Flash</a>)</td>
<td><a href="http://code.google.com/apis/maps/documentation/javascript/">Maps JavaScript API</a> + <br />
OOB:<br />
<a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser(v=vs.95).aspx">WebBrowser</a><br />
<br />
In Browser:<br />
HTML overlay (windowless)</td>
<td><a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.webbrowser(v=vs.92).aspx">WebBrowser</a> + <a href="http://code.google.com/apis/maps/documentation/javascript/">Maps JavaScript API</a></td>
<td>WebView + JavaScript API?</td>
</tr>
</tbody>
</table>
</div>
<p>Microsoft provide Bing mapping controls for Silverlight, Windows Phone 7, WPF, with a very similar API (and by very similar I mean in most cases there is just a different namespace). There is also an AJAX version, but there’s no real reason to use that here.</p>
<p>Google provide a JavaScript API which can be used by hosting in a browser control, which works well in WPF, WP7 and Silverlight out-of-browser; in Silverlight in the browser, hosting HTML content is not possible, so I’ll demonstrate overlaying HTML on top of the Silverlight app. For WPF (or WinForms) applications there’s also the option of embedding the Google Maps Flash control, but I’ll stick with the web version as it spans these different platforms.</p>
<p>In both cases there are &#8220;reasonable use&#8221; limits for free use of the service, which seem to me quite&#8230; reasonable. In the case of Google Maps there is a restriction around using the service for free if your app is not also free, and it&#8217;s not clear to me exactly what this means, while Bing does not impose such a restriction, which might be relevant if you&#8217;re publishing a WP7 app.</p>
<h3>Data</h3>
<p>As a data source I’ll import data in the GPX format (an XML format for exchange of GPS data). I’ll just pull out a sequence of locations from this, which we can then plot on the map. GPX files contain two types of locations, “track points” (part of a “track” which is meant to be logged GPS data), and “way points” (which are more meant to be part of a plotted course or significant locations), here we’ll just play dumb and extract everything in a flattened format.</p>
<p>I&#8217;m just embedding a few GPX files in the app resources for this example. I&#8217;ve chosen a few running routes which you can see in the examples below, no prizes will be awarded for guessing which one I logged myself.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> LoadTrack<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> track<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>var streamReader <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StreamReader<span style="color: #008000;">&#40;</span>StreamForTrack<span style="color: #008000;">&#40;</span>track<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        XDocument doc <span style="color: #008000;">=</span> XDocument<span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>streamReader<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadToEnd</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        var ns <span style="color: #008000;">=</span> doc<span style="color: #008000;">.</span><span style="color: #0000FF;">Root</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetDefaultNamespace</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        Locations  <span style="color: #008000;">=</span> doc<span style="color: #008000;">.</span><span style="color: #0000FF;">Descendants</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>el <span style="color: #008000;">=&gt;</span> el<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">==</span> ns <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;wpt&quot;</span> <span style="color: #008000;">||</span> el<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">==</span> ns <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;trkpt&quot;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Select</span><span style="color: #008000;">&#40;</span>trkpt <span style="color: #008000;">=&gt;</span>
                <span style="color: #008000;">new</span> Location
                <span style="color: #008000;">&#123;</span>
                    Latitude <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">double</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>trkpt<span style="color: #008000;">.</span><span style="color: #0000FF;">Attribute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;lat&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span>,
                    Longitude <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">double</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>trkpt<span style="color: #008000;">.</span><span style="color: #0000FF;">Attribute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;lon&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">.</span><span style="color: #0000FF;">ToLocationCollection</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">/// Work around annoying LocationCollection - which contains no AddRange method or collection constructor</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> LocationCollection ToLocationCollection<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> IEnumerable<span style="color: #008000;">&lt;</span>Location<span style="color: #008000;">&gt;</span> locations<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var locs <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> LocationCollection<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var loc <span style="color: #0600FF; font-weight: bold;">in</span> locations<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
       locs<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>loc<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> locs<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Lastly I’ll expose the available tracks as a property <code>AllTracks</code> and the selected track as <code>Track</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> _track<span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Track
<span style="color: #008000;">&#123;</span>
    get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _track<span style="color: #008000;">;</span><span style="color: #008000;">&#125;</span>
    set
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>value <span style="color: #008000;">==</span> _track<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
        _track <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        LoadTrack<span style="color: #008000;">&#40;</span>_track<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        OnPropertyChanged<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Track&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<h3>Bing &#8211; Silverlight</h3>
<p>It’s refreshingly simple to create a map to display our route. Setting the DataContext to the class described above, the following XAML displays a map of the route:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--Need to set CredentialsProvider=...--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid.DataContext<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;local:GpxPath</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid.DataContext<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:Map</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;Map&quot;</span> <span style="color: #000066;">Mode</span>=<span style="color: #ff0000;">&quot;Aerial&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:MapPolyline</span> <span style="color: #000066;">Locations</span>=<span style="color: #ff0000;">&quot;{Binding Locations}&quot;</span>  <span style="color: #000066;">Stroke</span>=<span style="color: #ff0000;">&quot;Red&quot;</span> <span style="color: #000066;">StrokeThickness</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bing:Map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>On top of this it’s nice to actually show the relevant part of the map, so lets set the view based on the bounding rectangle of the given locations. I wanted to do this in XAML, but unfortunately this is a method on the Map class. First step, wrap this in an attached property:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> Mapping
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// ...</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">readonly</span> DependencyProperty ViewProperty <span style="color: #008000;">=</span>
        DependencyProperty<span style="color: #008000;">.</span><span style="color: #0000FF;">RegisterAttached</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;View&quot;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>LocationRect<span style="color: #008000;">&#41;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>Mapping<span style="color: #008000;">&#41;</span>, <span style="color: #008000;">new</span> PropertyMetadata<span style="color: #008000;">&#40;</span>OnViewPropertyChanged<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnViewPropertyChanged<span style="color: #008000;">&#40;</span>DependencyObject d, DependencyPropertyChangedEventArgs e<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Map map <span style="color: #008000;">=</span> d <span style="color: #0600FF; font-weight: bold;">as</span> Map<span style="color: #008000;">;</span>
        var rect <span style="color: #008000;">=</span> e<span style="color: #008000;">.</span><span style="color: #0000FF;">NewValue</span> <span style="color: #0600FF; font-weight: bold;">as</span> LocationRect<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>map <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> rect <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            map<span style="color: #008000;">.</span><span style="color: #0000FF;">SetView</span><span style="color: #008000;">&#40;</span>rect<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Then we can make a converter to get the bounding LocationRect of our Locations collection:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> LocationsViewConverter <span style="color: #008000;">:</span> IValueConverter
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">object</span> Convert<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> value, Type targetType, <span style="color: #6666cc; font-weight: bold;">object</span> parameter, <span style="color: #000000;">System.<span style="color: #0000FF;">Globalization</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">CultureInfo</span> culture<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var locs <span style="color: #008000;">=</span> value <span style="color: #0600FF; font-weight: bold;">as</span> IEnumerable<span style="color: #008000;">&lt;</span>Location<span style="color: #008000;">&gt;;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>locs <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">||</span> <span style="color: #008000;">!</span>locs<span style="color: #008000;">.</span><span style="color: #0000FF;">Any</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">new</span> LocationRect<span style="color: #008000;">&#40;</span>locs<span style="color: #008000;">.</span><span style="color: #0000FF;">Max</span><span style="color: #008000;">&#40;</span>l <span style="color: #008000;">=&gt;</span> l<span style="color: #008000;">.</span><span style="color: #0000FF;">Latitude</span><span style="color: #008000;">&#41;</span>, locs<span style="color: #008000;">.</span><span style="color: #0000FF;">Min</span><span style="color: #008000;">&#40;</span>l <span style="color: #008000;">=&gt;</span> l<span style="color: #008000;">.</span><span style="color: #0000FF;">Longitude</span><span style="color: #008000;">&#41;</span>,  <span style="color: #008080; font-style: italic;">// N, W</span>
                                locs<span style="color: #008000;">.</span><span style="color: #0000FF;">Min</span><span style="color: #008000;">&#40;</span>l <span style="color: #008000;">=&gt;</span> l<span style="color: #008000;">.</span><span style="color: #0000FF;">Latitude</span><span style="color: #008000;">&#41;</span>, locs<span style="color: #008000;">.</span><span style="color: #0000FF;">Max</span><span style="color: #008000;">&#40;</span>l <span style="color: #008000;">=&gt;</span> l<span style="color: #008000;">.</span><span style="color: #0000FF;">Longitude</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// S, E</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">// ...</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>It’s quite nice to see pushpins for the route start/end, so lets add them. Just as MapPolyline is analogous to Polyline, MapItemsControl is to ItemsControl. So I can add pushpins by binding to the appropriate collection. Add a property and update it when loading a new track:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> IEnumerable<span style="color: #008000;">&lt;</span>Location<span style="color: #008000;">&gt;</span> PushPins <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span> <span style="color: #008080; font-style: italic;">// Really add property changed notification </span>
<span style="color: #008080; font-style: italic;">// ...</span>
    PushPins <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>Location<span style="color: #008000;">&gt;</span> <span style="color: #008000;">&#123;</span> locations<span style="color: #008000;">.</span><span style="color: #0000FF;">First</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, locations<span style="color: #008000;">.</span><span style="color: #0000FF;">Last</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span></pre></div></div>

<p> Here&#8217;s the updated XAML with the view setting and push pins:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:Map</span> <span style="color: #000066;">Mode</span>=<span style="color: #ff0000;">&quot;Aerial&quot;</span> </span>
<span style="color: #009900;">          <span style="color: #000066;">local:Mapping.View</span>=<span style="color: #ff0000;">&quot;{Binding Locations, Converter={StaticResource LocationsViewConverter}}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:MapLayer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:MapPolyline</span> <span style="color: #000066;">Locations</span>=<span style="color: #ff0000;">&quot;{Binding Locations}&quot;</span>  <span style="color: #000066;">Stroke</span>=<span style="color: #ff0000;">&quot;Red&quot;</span> <span style="color: #000066;">StrokeThickness</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bing:MapLayer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:MapItemsControl</span> <span style="color: #000066;">ItemsSource</span>=<span style="color: #ff0000;">&quot;{Binding PushPins}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:MapItemsControl.ItemTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DataTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bing:Pushpin</span> <span style="color: #000066;">Location</span>=<span style="color: #ff0000;">&quot;{Binding}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DataTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bing:MapItemsControl.ItemTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bing:MapItemsControl<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bing:Map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And the end result:<br />
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="400" height="400"><param name="source" value="http://www.scottlogic.co.uk/wp-content/uploads/2012/03/MapsDemo.Bing_.SL_.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="4.0.60310.0" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=4.0.50826.0" style="text-decoration:none"><br />
        <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/><br />
    </a><br />
</object></p>
<h3>Bing &#8211; WPF</h3>
<p>The WPF Bing control follows the Silverlight control API very closely, and other than the namespace there’s little difference. Some options are different for the surrounding UI, but the main API is the same. It literally is as simple as using the same code files with:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080;">#if SILVERLIGHT</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Maps.MapControl</span><span style="color: #008000;">;</span>
<span style="color: #008080;">#else</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Maps.MapControl.WPF</span><span style="color: #008000;">;</span>
<span style="color: #008080;">#endif</span></pre></div></div>

<p>The XAML is very similar &#8211; see the project at the end of the post for other details.</p>
<p><a href="http://www.scottlogic.co.uk/wp-content/uploads/2012/02/WPF-Bing.png"><img src="http://www.scottlogic.co.uk/wp-content/uploads/2012/02/WPF-Bing.png" alt="" title="WPF-Bing" width="436" height="352" class="alignright size-full wp-image-145167" /></a></p>
<h3>Bing &#8211; WP7</h3>
<p>Again the WP7 API is similar, although in this case there are some differences. An obvious one is the Location class is supplemented with the Geolocation class &#8211; for example LocationCollection is now an ObservableCollection&lt;Geolocation&gt;. In fact there are implicit conversions between Location and Geolocation, so in most cases we can again get away with the same C# code with some careful use of types &#8211; other than some conditional includes:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080;">#if WINDOWS_PHONE</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Phone.Controls.Maps</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Phone.Controls.Maps.Platform</span><span style="color: #008000;">;</span>
<span style="color: #008080;">#elif SILVERLIGHT</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Maps.MapControl</span><span style="color: #008000;">;</span>
<span style="color: #008080;">#else</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Maps.MapControl.WPF</span><span style="color: #008000;">;</span>
<span style="color: #008080;">#endif</span></pre></div></div>

<p>Of course the end result looks somewhat different:<br />
<a href="http://www.scottlogic.co.uk/wp-content/uploads/2012/02/WP7-Bing.png"><img src="http://www.scottlogic.co.uk/wp-content/uploads/2012/02/WP7-Bing-158x300.png" alt="" title="WP7-Bing" width="158" height="300" class="alignright size-medium wp-image-145438" /></a></p>
<h3>And finally</h3>
<p>The various projects with the above code can be <a href="http://www.scottlogic.co.uk/wp-content/uploads/2012/03/MapsDemo.Bing.zip">downloaded here</a>. If I was going to create the same thing again I&#8217;d keep references to Bing namespaces entirely out of the common code with some more aggressive use of converters, rather than dancing around the differences, but as an exploration of the APIs I found it interesting to see how little had to change.</p>
<p>I&#8217;m going to pause for there and show the Google Maps version in another installment. There there will be some more interesting issues to consider.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2012/05/mapping-in-wpf-silverlight-and-wp7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing the jQuery Mobile Metro Theme</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2012/04/introducing-the-jquery-mobile-metro-theme/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2012/04/introducing-the-jquery-mobile-metro-theme/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 08:03:11 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2114</guid>
		<description><![CDATA[This blog post introduces the new jQuery Mobile Metro theme and demonstrates how to create a web UI that detects the device it is being viewed on, to render a Metro UI on WP7 and iOS on other devices: Colin Eberhardt is a Scott Logic technical Evangelist and a Technical Architect for Visiblox, suppliers of [...]]]></description>
			<content:encoded><![CDATA[
<p>This blog post introduces the new jQuery Mobile Metro theme and demonstrates how to create a web UI that detects the device it is being viewed on, to render a Metro UI on WP7 and iOS on other devices:</p>
<div style="float:right; width:130px; margin:10px; padding:10px; border: solid 1px #aaa; font-size:0.8em;">
<img src="http://0.gravatar.com/avatar/458f2e0d08d4114f8b323798cfea141d?s=64&#038;d=http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=64&%23038;r=G" style="float:left; margin:5px;"><br />
Colin Eberhardt is a Scott Logic technical Evangelist and a Technical Architect for Visiblox, suppliers of <a href="http://www.visiblox.com">high-performance WPF and Silverlight charts</a>.<br />
<a href="http://www.visiblox.com"><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/visiblox-white.png"/></a>
</div>
<p><iframe width="460" height="264" src="http://www.youtube.com/embed/tB6UFcvRMrY" frameborder="0" allowfullscreen></iframe></p>
<p><em>Apologies for the terrible video quality, I really am going to have to work out how to do this properly one day!</em></p>
<p>You can view the mobile web site shown above <a href="http://colineberhardt.github.com/jqm/index.html">on your own device from here</a>. Note, on a WP7 device, set your IE to render the &#8216;mobile version&#8217; of websites to see the Metro theme.</p>
<h2>Introduction</h2>
<p>A couple of weeks ago Microsoft announced the formation of <a href="http://blogs.msdn.com/b/interoperability/archive/2012/04/12/announcing-one-more-way-microsoft-will-engage-with-the-open-source-and-standards-communities.aspx">Microsoft Open Technologies Inc.</a> which will contribute to open source projects, standards and interoperability. For Windows Phone 7 developers, where the mobile OS market is highly fragmented, any efforts to push standards and interoperability are a very good thing. The first project backed by the Open Tech interop team was Apache Cordova (PhoneGap) allowing you to run HTML5 applications on your WP7, as covered in <a href="http://www.scottlogic.co.uk/blog/colin/2011/09/developing-windows-phone-7-html5-apps-with-phonegap/">one of my previous blog posts</a>. A few days ago, the team announced another release, jQuery Mobile (jQM) Metro. In this blog post we’ll take a look at what jQM is and how it helps you build HTML5-based mobile applications.</p>
<p>HTML5 is becoming an increasingly popular technology for the creation of mobile applications, allowing developers to leverage their existing JavaScript and CSS skills, regardless of the native language requirements of the mobile platform being targeted (WP7, iOS, Android etc …). One of the greatest challenges for developers of HTML5-based mobile applications is the creation of user-interfaces that mimic the native look and feel. This is where technologies like <a href="http://jquerymobile.com/">jQuery Mobile</a> come in handy, this framework provides a standard set of styles and markup for creating a wide range of mobile layouts, controls and transitions.</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/jquery-mobile-devices-beta.png" alt="" title="jquery-mobile-devices-beta" width="380" height="377" class="aligncenter size-full wp-image-2116" /></p>
<p>If you look at the jQM website you will find that the interface quite closely mimics the iOS look and feel. A couple of months ago <a href="http://jquerymobile.com/blog/2011/03/31/jquery-mobile-alpha-4-released/">the jQM team announced WP7 support</a>, however, this release simply allowed the iOS-style interface to render on a WP7 device. </p>
<p>The more recent release from MS Open Tech allows you to <a href="http://blogs.msdn.com/b/interoperability/archive/2012/04/26/more-news-from-ms-open-tech-announcing-the-open-source-metro-style-theme.aspx">use jQM to produce Metro interfaces using HTML5</a>. This makes use of the pre-existing jQM theme support, and as a result, you can use the same markup for both iOS and Metro themed UIs, with only a change in stylesheet being required.</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/jQM-Metro.png" alt="" title="jQM-Metro" width="600" height="287" class="aligncenter size-full wp-image-2115" /></p>
<p>The jQM Metro Theme is not an official part of jQM yet and is currently <a href="http://sgrebnov.github.com/jqmobile-metro-theme/">available via its own github page</a>. I anticipate that it will make its way into the core jQM shortly. In the current release you will also see quite a few references to Apache Cordova (previously called PhoneGap), it is worth mentioning that Cordova and jQM are quite independent frameworks. Cordova provides a mechanism for deploying HTML5 applications within a native wrapper (see <a href="http://www.scottlogic.co.uk/blog/colin/2011/09/developing-windows-phone-7-html5-apps-with-phonegap/" title="Developing Windows Phone 7 HTML5 apps with PhoneGap">my previous blog post</a>), and does not require you to use jQM &#8211; in fact you can use any UI framework your please (or roll your own).</p>
<p>This blog post will provide a brief introduction to jQM, demonstrating how you can create a mobile website that detects the mobile browser being used, delivering a Metro UI to WP7 devices and iOS to others. I will not be using Cordova for this example, just to keep it simple!</p>
<h2>Introducing jQuery Mobile</h2>
<p>The easiest way to understand jQM is via a simple example, a page with a heading and one line of text:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>My Page<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;width=device-width, initial-scale=1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;themes/default/jquery.mobile.css&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;default&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;lib/jquery.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;lib/jquery.mobile-1.0.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;page&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jQM<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      Hello from jQuery Mobile!
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;button</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;button&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>I am a button<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>You can see in the above HTML the following elements:</p>
<ul>
<li>The jQM CSS file</li>
<li>Two JavaScript files, jQuery and jQueryMobile</li>
<li>Some HTML content that is ‘annotated’ using data-role attributes.</li>
</ul>
<p>Loading this into the browser (and shrinking it to a mobile-esque size) yields the following:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/one.png" alt="" title="one" width="350" height="427" class="aligncenter size-full wp-image-2117" /></p>
<p>Which is a pretty decent replica of a native iOS UI, complete with gradients, button states and other chrome.</p>
<p>Considering that jQM is all about styling, why do we have JavaScript files as well as CSS files in our project? If you look at the source of the rendered page, you will see why. The simple button in our source HTML is now the following:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> data-theme<span style="color: #ff0000;">&quot;c&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn ui-btn-corner-all ui-shadow ui-btn-up-c&quot;</span> <span style="color: #000066;">aria-disabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-inner ui-btn-corner-all&quot;</span> <span style="color: #000066;">aria-hidden</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>I am a button<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;button</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-hidden ui-btn ui-btn-corner-all ui-shadow ui-btn-up-c&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">aria-disabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">data-theme</span>=<span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-inner ui-btn-corner-all&quot;</span> <span style="color: #000066;">aria-hidden</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-btn-text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>I am a button<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>That’s quite a lot of extra HTML! What’s all this extra junk doing in my page?</p>
<p>Unfortunately CSS isn’t quite powerful enough to radically transform the way which the standard HTML elements are rendered. When the page is loaded the jQM JavaScript runs through the page, looking for the various data-role attributes, adding in the structural HTML required to support the described style.</p>
<p>This is a bit of a shame really. The way that jQM ‘enhances’ your HTML can cause problems when trying to integrate with other frameworks such as KnockoutJS which dynamically insert elements into the DOM. </p>
<p>To be fair, the jQM JavaScript isn’t only required to give CSS a helping hand. It also does clever things such as load pages that the user clicks on using AJAX (yuck – I <em>hate</em> that term!) so that it can be rendered off screen then slid into view, mimicking the slick iOS page transitions. </p>
<p>jQM has a wide range of built in styles covering all the common mobile controls. For creating mobile UIs, jQM is a massive time saver. I really wouldn’t want to write (and test) all this CSS myself!</p>
<h2>Go Metro!</h2>
<p>We’ve seen how to build a simple iOS style mobile UI, but what about this new Metro theme? To use it, simply change the CSS to reference the Metro theme:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;themes/metro/jquery.mobile.metro.theme.css&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;default&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>I’ve also explicitly targeted the ‘dark’ theme by adding the following attribute to the page:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;page&quot;</span> <span style="color: #000066;">data-theme</span>=<span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>(Without this, the UI doesn’t quite look right, I think this is a bug … I’ll raise a ticket on github shortly). </p>
<p>With this simple change our UI is now Metro:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/two.png" alt="" title="two" width="350" height="399" class="aligncenter size-full wp-image-2121" /></p>
<p>The above page uses the WP7 Segoe font, has a lower caps title, is authentically digital, favours content over chrome … etc … isn&#8217;t it lovely?</p>
<p>Building UIs with jQM is really quite simple, your markup is simple and clean, annotated with the various <code>data-</code> attributes. The jQM framework is really quite expansive, providing pretty much everything you might need for a standard mobile application.</p>
<p>For the rest of this article we’ll look at building a more complex example, that dynamically picks the theme based on the device viewing it.</p>
<h2>SandwichFlow</h2>
<p>I’ll re-use the data I collected for my <a href="http://www.scottlogic.co.uk/blog/colin/2011/05/metro-in-motion-5-sandwichflow/" title="Metro In Motion #5 – SandwichFlow">SandwichFlow</a> application to create a HTML5-based webpage where you can browse sandwich recipes. The index page is simply a list of sandwiches, sorted alphabetically:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #808080; font-style: italic;">&lt;!-- CSS and JS files included as above --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;page&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Sandwich Flow<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;listview&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;list-divider&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-index&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>C<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;1.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Chargrilled salmon open sandwich<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;2.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Chicken, pesto and rocket sandwich<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;3.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Christmas club sandwich<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;4.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Cream cheese and cucumber sandwiches<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;list-divider&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-index&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>D<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;5.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Duck breast with mushroom and onion sandwich, puree of leeks
          and orange and balsamic sauce<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li</span> <span style="color: #000066;">data-role</span>=<span style="color: #ff0000;">&quot;list-divider&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ui-index&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>E<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;6.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Egg and cress finger sandwiches<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        ...
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The above code uses a list-divider, which renders as follows with the iOS theme:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/three.png" alt="" title="three" width="300" height="443" class="aligncenter size-full wp-image-2120" /></p>
<p>Whereas, with the metro theme, it gives the appearance of a jump list:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/four.png" alt="" title="four" width="300" height="444" class="aligncenter size-full wp-image-2123" /></p>
<p>Sadly the list isn’t a real jump list, those buttons aren’t clickable. Perhaps the jQM Metro team might be interested in <a href="http://www.codeproject.com/Articles/219370/From-Silverlight-To-HTML5">the HTML5 jump list I wrote a while back</a>?</p>
<h2>Automatically Choosing a Theme</h2>
<p>What I’d like to do is deliver an interface that is appropriate for the device it is being viewed on, so this means the Metro theme on a WP7 device and the iOS theme on others (sorry Android!). We can detect a WP7 device via the user agent string:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> isWindowsPhone <span style="color: #339933;">=</span> navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Windows Phone OS 7.5&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span></pre></div></div>

<p>The web page will include both CSS files, with the Metro theme being included as an alternate:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;themes/default/jquery.mobile.css&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;default&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;alternate stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;themes/metro/jquery.mobile.metro.theme.css&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;metro&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Then if a WP7 device is detected, we use a bit of JavaScript to activate our metro theme (courtesy of <a href="http://www.alistapart.com/articles/alternate/">a list apart</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isWindowsPhone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  setActiveStyleSheet<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;metro&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> setActiveStyleSheet<span style="color: #009900;">&#40;</span>title<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> a<span style="color: #339933;">,</span> main<span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;link&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rel&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;style&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">&amp;&amp;</span> a.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      a.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> title<span style="color: #009900;">&#41;</span> a.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>The Recipes</h2>
<p>My previous SandwichFlow application was written using Silverlight and contained an XML file with the various recipes. To re-use this within a jQM application I need to turn each recipe into an individual HTML file. Now, I am not keen on doing this sort of thing manually, so I wrote a T4 template that reads this XML file, and spits out an HTML file for each recipe:</p>
<pre>
&lt;#@ template language="C#" hostSpecific="true" debug="true" #&gt;

&lt;#@ template language="C#v3.5" #&gt;

&lt;#@ include file="Util.tt" #&gt;
&lt;#@ include file="EnvDTE.tt" #&gt;
&lt;#

var project = FindProjectHost();

int lastSlash = project.FileName.LastIndexOf(@"\");
string projectPath = project.FileName.Substring(0,lastSlash);

XDocument xmlFile = XDocument.Load(projectPath + "\\CodeGen\\sandwiches.xml");

int index=1;
var sarnies = xmlFile.Descendants("sandwich")
                     .OrderBy(sarnie =&gt; sarnie.Attribute("title").Value);
foreach(var sarnie in sarnies)
{
  GenerateSandwichFile(sarnie, project,
    projectPath + "\\www\\" + index.ToString() + ".html", xmlFile);
  index++;
}
#&gt;
&lt;#+

private void GenerateSandwichFile(XElement sarnie, Project project, string filename, XDocument xmlFile)
{
#&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;My Page&lt;/title&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;

  &lt;link rel="stylesheet" href="themes/default/jquery.mobile.css" title="default" /&gt;
  &lt;link rel="stylesheet" href="style-other.css" title="default" /&gt;

  &lt;link rel="alternate stylesheet" href="themes/metro/jquery.mobile.metro.theme.css"
    title="metro" /&gt;
  &lt;link rel="alternate stylesheet" href="style-metro.css" title="metro" /&gt;

  &lt;script type="text/javascript" charset="utf-8" src="lib/jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" charset="utf-8" src="lib/jquery.mobile-1.0.js"&gt;&lt;/script&gt;
  &lt;!--&lt;script type="text/javascript" charset="utf-8" src="lib/cordova-1.5.0.js"&gt;&lt;/script&gt;--&gt;
  &lt;script type="text/javascript" charset="utf-8" src="app.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div data-role="page"&gt;
    &lt;div data-role="header"&gt;
      &lt;a href="index.html" data-icon="back" data-rel="back"&gt;Back&lt;/a&gt;
      &lt;h1&gt;Recipe&lt;/h1&gt;
    &lt;/div&gt;
    &lt;div data-role="content" class="recipe"&gt;
      &lt;h3&gt;&lt;#= sarnie.Attribute("title").Value #&gt;&lt;/h3&gt;
      &lt;#+
      var keyword = sarnie.Descendants("keyword").First().Value;
      var key = xmlFile.Descendants("keywordDefs")
                       .Descendants("keyword")
                       .Where(s =&gt; s.Value == keyword)
                       .SingleOrDefault();
      var img = "food/images/food_16x9_608/recipes/ovenbakedsweetmisoma_73596_16x9.jpg";
      if (key!=null)
      {
        img = key.Attribute("url").Value;
      }
      #&gt;
      &lt;img class="yummyFood"
            src='http://www.bbc.co.uk&lt;#= img #&gt;' /&gt;
      &lt;h4&gt;Ingredients&lt;/h4&gt;
      &lt;ul&gt;
      &lt;#+
      foreach(var ingredient in sarnie.Descendants("ingredient"))
      {
        #&gt;&lt;li&gt;&lt;#= ingredient.Value #&gt;&lt;/li&gt;
        &lt;#+
      }
      #&gt;
      &lt;/ul&gt;
      &lt;h4&gt;Instructions&lt;/h4&gt;
      &lt;ul&gt;
      &lt;#+
      foreach(var instruction in sarnie.Descendants("instruction"))
      {
        #&gt;&lt;li&gt;&lt;#= instruction.Value #&gt;&lt;/li&gt;
        &lt;#+
      }
      #&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;#+
  SaveOutput(filename, project);
}
#>
</pre>
<p>The above code uses a few T4 ‘tricks’ <a href="http://www.codeproject.com/Articles/184031/Declarative-Codesnippet-Automation-with-T4-Templat">I developed in an earlier article</a>, including code that creates multiple output files from the T4 template and also automatically adds these files to the Visual Studio project.</p>
<p>An example recipe is shown below:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/five.png" alt="" title="five" width="400" height="569" class="aligncenter size-full wp-image-2122" /></p>
<p>Now there isn’t really a suitable jQM UI for the ingredients list, so I styled these directly:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/fiveAndABit.png" alt="" title="fiveAndABit" width="400" height="569" class="aligncenter size-full wp-image-2124" /></p>
<p>You’ll also notice that this page has a back-button. This is required because iPhones do not have a hardware back button. However, if we re-use this same UI in our WP7 version, even with a Metro theme, it will look quite wrong. A simple bit of jQuery is all that is required to remove these buttons when viewing with a WP7:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div[data-role='page']&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pagecreate'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isWindowsPhone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a[data-rel='back']&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above code isn’t quite as simple as you might expect. Firstly, as mentioned previously jQM uses AJAX to load pages, so a jQuery <code>live()</code> function is used to match new DOM elements as they are added. We are handling the jQM <code>pagecreate </code>event which fires when the AJAXed page is initially added to the DOM but before the additional structure has been added, the code that is executed simply removes back linking anchor tags.</p>
<p>The resulting WP7 UI is as follows:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/six.png" alt="" title="six" width="400" height="569" class="aligncenter size-full wp-image-2119" /></p>
<h2>Conclusions</h2>
<p>It’s great to see that Microsoft are not only backing HTML5 for their browsers (on the desktop and WP7) but are also working with the open source community on projects that make cross-browser and cross-platform development easier.</p>
<p>I am still in two minds about jQM, on the plus side, it does remove the need to write and test bucketloads of CSS and is very simple to use. However, there are some negatives …</p>
<p>The jQM UI looks almost identical to the native iOS on static screenshots, but the dynamic behaviour is nowhere near the native experience. For example, the iOS slide transition is surprisingly complex, with at least five separate animation components <a href="http://watchingapple.com/2009/11/a-closer-look-at-iphone-transition-animations/">as described in this interesting blogpost</a>. The jQM Metro theme is also lacking in the fluid aspects of the WP7 UI, this is most likely due to the lack of touch events and 3D CSS transforms on WP7. Ironically, iOS and Android phones are actually more capable of mimicking the Metro theme as demonstrated by <a href="http://m.microsoft.com/windowsphone/en-us/demo/index.html">Microsoft’s HTML5-based Metro demo for iOS and Android owners</a>. Also, other key controls which define the Metro UI, such as Pivot and Panorama are absent from jQM Metro. These controls do lend themselves to HTML5 implementations, as demonstrated by <a href="http://www.jqmetro.com/Pages/Pivot.aspx">jq-metro</a> &#8211; hopefully this sort fo control will also find its way into jQM Metro. Finally, I couldn’t finish an article on HTML5-based WP7 applications without mentioning the <a href="http://stackoverflow.com/questions/6378008/windows-phone-7-browser-turn-off-the-gray-shading-when-links-are-clicked">‘gray shading’ of clicked links</a> which spoils jQM Metro just as much as it has all my previous HTML5 based applications <img src='http://www.scottlogic.co.uk/blog/colin/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p>Ending on a positive note, I am sure that these issues will be resolved in time, and I do like the simplicity of jQM. If you want to rapidly create a simple mobile website or HTML5 mobile application that looks great, jQM is an excellent choice.</p>
<p>You can download the HTML / JS for this article here: <a href='http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/SandwichFlowjQM.zip'>SandwichFlowjQM.zip</a></p>
<p>Regards, Colin E.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2012/04/introducing-the-jquery-mobile-metro-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UX London 2012</title>
		<link>http://www.scottlogic.co.uk/blog/graham/2012/04/ux-london-2012-3/</link>
		<comments>http://www.scottlogic.co.uk/blog/graham/2012/04/ux-london-2012-3/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 14:32:23 +0000</pubDate>
		<dc:creator>Graham Odds</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[visualisation]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/graham/?p=683</guid>
		<description><![CDATA[Last week I attended the UX London 2012 conference. This was my first public foray into the world of User Experience and it proved to be both educational and thought-provoking. Having read his book, Sketching User Experiences, I had high expectations of the opening presentation from Bill Buxton (@wasbuxton) and he didn&#8217;t disappoint. He introduced [...]]]></description>
			<content:encoded><![CDATA[
<p>Last week I attended the <a href="http://2012.uxlondon.com/" >UX London 2012</a> conference.  This was my first public foray into the world of User Experience and it proved to be both educational and thought-provoking.</p>
<p>Having read his book, <a href="http://www.amazon.co.uk/Sketching-User-Experiences-Interactive-Technologies/dp/0123740371/ref=sr_1_1?ie=UTF8&#038;qid=1335198076&%23038;sr=8-1" >Sketching User Experiences</a>, I had high expectations of the opening presentation from <a href="http://billbuxton.com/" >Bill Buxton</a> (<a href="http://twitter.com/#!/wasbuxton" >@wasbuxton</a>) and he didn&#8217;t disappoint.  He introduced the Long Nose Of Innovation: the observation that it takes roughly 20 years for a technology to go from invention to billion dollar industry, with most of that time spent &#8220;under the radar&#8221;.  Taking this further, he highlighted how this means we can easily predict the near future by looking at the recent past.  He backed this up with various examples, most with the added side-note that the the first patent for a concept often wasn&#8217;t the original invention.  Who knew Xerox didn&#8217;t invent the mouse, and that in-line skates originate from the early 19th century?!</p>
<p><img src="http://www.scottlogic.co.uk/blog/graham/wp-content/uploads/2012/04/uxlondon1.png" alt="" title="UX London 2012" width="700" height="289" class="aligncenter size-full wp-image-686" /></p>
<p><a href="http://www.andersramsay.com/" >Anders Ramsay</a> (<a href="http://twitter.com/#!/andersramsay" >@andersramsay</a>) had the unenviable task of following Bill Buxton on stage, but his discussion of Agile UX using an interesting rugby analogy went down a treat.  His slides are available <a href="http://www.slideshare.net/andersr/learning-to-play-ux-rugby-extended" >here</a> and are well worth a look for anyone working in an Agile development environment.</p>
<p><a href="http://www.lukew.com/" >Luke Wroblewski</a> (<a href="http://twitter.com/#!/lukew" >@lukew</a>) was up next and rammed home the point that not only should we be thinking mobile-first when designing websites, but that our mindset should also be &#8220;content first, navigation second&#8221;.  He went on to detail his current thoughts on <a href="http://www.lukew.com/ff/entry.asp?1514" >responsive layouts</a> and responsive navigation patterns.  <a href="http://www.lukew.com/" >His website</a> is a treasure trove of information on designing for mobile devices and I highly recommend everyone has a dig around in it.</p>
<p><a href="http://www.braintraffic.com/" >Kristina Halvorson</a> (<a href="http://twitter.com/#!/halvorson" >@halvorson</a>)  focused her 45 minutes on the importance and practicalities of content strategy in user experience design.  It is obvious that substance and structure should be connected to workflow and governance, and that all content should support and tie to a single core message, but there is clear evidence around us that this is ignored or forgotten in many projects.  </p>
<p>The inimitable <a href="http://www.uie.com/about/consultants/" >Jared Spool</a> (<a href="http://twitter.com/#!/JMSPOOL" >@jmspool</a>) outlined what he considers to be the four major forces that make good design so important these days, or as he puts it, The Perfect Storm:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Sturgeon's_Law" >Sturgeon&#8217;s Law</a> &#8211; &#8220;90% of everything is crap&#8221; &#8211; is as applicable as ever, with Jared   supporting this by showing a number of mobile-centric experiences from big brands, such as scanning a QR code, that result in the user going to websites that are not optimized for mobile or, at worst, outright broken on mobile (by using Flash&#8230;).</li>
<li>There is a recurring market maturity cycle: we start with some technology that fills a void, onto which companies start heaping features, before experiences become the key.  Clearly this cycle should be broken and companies should just focus on experience straight away.</li>
<li>The difference between activities and experiences is huge.  Jared&#8217;s comparison of how the <a href="http://www.sixflags.com/national/index.aspx" >Six Flags</a> and <a href="http://disneyworld.disney.go.com/" >Disney</a> theme parks differ emphasised how much value a lot of extra thought and a little extra money can make.  <em>&#8220;Experience is about filling in all the gaps between the activities&#8221;</em></li>
<li>The <a href="http://en.wikipedia.org/wiki/Kano_model" >Kano Model</a> provides a powerful insight into user expectations, and where investment should be in order to satisfy them.</li>
</ul>
<p>We were then given some shorter, case-study based presentations by <a href="http://www.90percentofeverything.com/" >Harry Brignull</a> (<a href="http://twitter.com/#!/harrybr" >@harrybr</a>), <a href="http://www.pushclicktouch.com/" >Bill DeRouchey</a> (<a href="http://twitter.com/#!/billder" >@billder</a>) and <a href="http://www.optimalusability.com/staffbiopost/leif-roy/" >Leif Roy</a>.  What stood out the most to me from these presentations was Bill DeRouchey&#8217;s view that we should let opinions shine through our products because opinions provoke engagement.</p>
<p><a href="http://www.scottlogic.co.uk/blog/graham/2012/04/ux-london-2012-3/" >Jon Kolko</a> (<a href="http://twitter.com/#!/jkolko" >@jkolko</a>) was rounded off the day with an impassioned presentation imploring us to apply our design skills to problems that are genuinely worth solving (rather than another Toilet Finder app!).  It was inspirational, bigger picture stuff and drove home a rather important point.  His slides are available <a href="http://www.jonkolko.com/projectFiles/preso/kolko_2012_04_designForImpact.pdf" >here</a>.</p>
<p><img src="http://www.scottlogic.co.uk/blog/graham/wp-content/uploads/2012/04/toilet_apps1.png" alt="" title="Toilet Finder Apps" width="480" height="360" class="aligncenter size-full wp-image-685" /><br />
<small style="padding-left: 200px;">Yes, there are more than one toilet finder apps&#8230; (from <a href="http://www.jonkolko.com/projectFiles/preso/kolko_2012_04_designForImpact.pdf" >Jon Kolko</a>).</small></p>
<p>The second and third days of the conference consisted of half-day workshops, the first of which was <a href="http://ugleah.tumblr.com/" >Leah Buley</a>&#8216;s (<a href="http://twitter.com/#!/ugleah" >@ugleah</a>) UX Team Of One Bootcamp.  Much as the name suggests, the workshop centred on practicalities of the common situation where you are the lone UX designer on a project or in an organisation.  Leah emphasised that whatever the exact activities are you choose to undertake, the key aspects of your approach should be:</p>
<ul>
<li>lowest fidelity possible</li>
<li>inclusive and participatory</li>
<li>focused on prioritization</li>
<li>not rigidly sequential</li>
<li>bite-sized and with a purpose</li>
</ul>
<p>The discussion following a subsequent group exercise involving the creation of a project plan for a hypothetical highlighted two important aspects we have a tendency to forget: a buy vs build analysis; and, the question of whether it is the software or people we should be aiming to redesign.  Focus then shifted towards  the difficulties around communication in the lone UX designer situation, such as explaining to people what you actually do and how to sell the business case for UX.</p>
<p>In the afternoon I opted to indulge myself and opted for <a href="http://www.poetpainter.com/" >Stephen Anderson</a>&#8216;s (<a href="http://twitter.com/#!/stephenanderson" >@stephenanderson</a>) wonderfully example-heavy workshop entitled The Quest For Emotional Engagement: Information Visualization.  First, Stephen outlined what he sees as a common UI problem that visualisation can solve, namely that we too readily and lazily reach for four often ineffective UI design patterns: spreadsheets, lists, grid views and dashboards.  Their common shortcoming is their inability to present relationships in the information such as processes, proportions and changes over time.  With the problems identified, we moved to a very detailed walk through Stephen&#8217;s 5-step process for information visualisation: identify opportunity &rarr; frame problem to be solved &rarr; identify nodes of information &rarr; explore ways to put that together &rarr; clean up, test, and iterate!</p>
<p><img src="http://www.scottlogic.co.uk/blog/graham/wp-content/uploads/2012/04/speedboat1.png" alt="" title="Speed Boat Innovation Game" width="646" height="345" class="aligncenter size-full wp-image-684" /><br />
<small style="padding-left: 200px;">The <a href="http://innovationgames.com/speed-boat/" >speed boat innovation game</a>, from <a href="http://www.andersramsay.com/" >Anders Ramsay</a>.</small></p>
<p>After being impressed by his presentation on Agile UX on the opening day, I started the final day of the conference with <a href="http://www.andersramsay.com/" >Anders Ramsay</a>&#8216;s workshop around the same subject.  In this very hands-on session, Anders introduced <a href="http://en.wikipedia.org/wiki/User_story" >user stories</a> as a means by which design can integrate with and support development in an agile (<a href="http://en.wikipedia.org/wiki/Scrum_(development)" >Scrum</a>) environment.  He showed (and we experienced) how product discovery through UX activities such as <a href="http://innovationgames.com/speed-boat/" >speed boat innovation game</a> can be used to generate what he terms experience stories &#8211; user stories focusing more on why than what.  By combining those experience stories with feature stories, the design of the user interface can iteratively take place.  In the case of our workshop we did this using a design studio activity.  &#8220;Standard&#8221; development stories can then be extracted from the design to feed into your developers&#8217; product and sprint backlogs.  As Anders reiterated throughout, for the best results designer and developers should be working collaboratively throughout.  After all, <em>&#8220;those who need a document should participate in creating it&#8221;</em>.</p>
<p>Unfortunately, what started off as a really promising workshop from <a href="http://www.disambiguity.com/" >Leisa Reichelt</a> (<a href="http://twitter.com/#!/leisa" >@leisa</a> about adding user experience as a strategic aspect of an organisation ended up becoming something of a confusing muddle by descending into a lecture heavy on business jargon with few practical examples (not helped by it being a Friday afternoon at the end of a 3-day conference).  Based on what I&#8217;ve picked up from her blog, her more sweary, ranty style might have better suited the material and audience.</p>
<p>Also, sponsors <a href="http://www.red-gate.com/" >Red Gate</a> put <a href="http://www.hasbro.com/nerf/en_GB/" >Nerf guns</a> in the conference goodybag so get a free shout-out for knowing what all nerds want!</p>

]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/graham/2012/04/ux-london-2012-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF Charting Performance Comparisons (the Battle Continues)</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2012/04/wpf-charting-performance-comparisons-the-battle-continues/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2012/04/wpf-charting-performance-comparisons-the-battle-continues/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 09:24:35 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[codeproject]]></category>
		<category><![CDATA[visiblox]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2099</guid>
		<description><![CDATA[This blog post presents a thorough analysis of the performance of various WPF Charting components. The results show that a new class of charting solutions, which use raster-based graphics as opposed to retained mode vector graphics, provide a considerable performance advantage. Introduction Readers of my blog will know that charting and performance are two things [...]]]></description>
			<content:encoded><![CDATA[
<p>This blog post presents a thorough analysis of the performance of various WPF Charting components. The results show that a new class of charting solutions, which use raster-based graphics as opposed to retained mode vector graphics, provide a considerable performance advantage.</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/LineSeriesFrameRate.png" alt="" title="LineSeriesFrameRate" width="650" height="361" class="aligncenter size-full wp-image-2104" /></p>
<h2>Introduction</h2>
<p>Readers of my blog will know that charting and performance are two things that interest me greatly. One of the first things I did back in 2009 when I started working with WPF and Silverlight was have a go with the Microsoft ‘toolkit’ charts. Unfortunately I found these charts, and the various third party competitors, to be painfully slow when rendering just a few hundred datapoints. As a result of these findings I set about creating a high performance chart for Silverlight and WPF, which eventually became <a href="http://www.visiblox.com">Visiblox charts</a>.</p>
<p>In December 2010 I <a href="http://www.scottlogic.co.uk/blog/colin/2010/11/visiblox-charts-vs-silverlight-toolkit-charts-a-test-of-performance-2/">published a performance comparison</a> that demonstrated that Visiblox was approximately 50-100 times faster than the Toolkit charts and 10 times faster than Visifire charts. At the time the only charts which came close were those developed as part of Microsoft’s <a href="http://dynamicdatadisplay.codeplex.com/">now abandoned Dynamic Data Display project</a>. Since publishing these figures, a number of the WPF and Silverlight charting vendors have started to take performance much more seriously, with <a href="http://www.visifire.com/blog/2011/12/02/fast-silverlight-charts/">Visifire</a> more than doubling performance amid claims of being the fastest chart, <a href="http://devblog.ailon.org/devblog/post/2010/12/17/amCharts-Quick-Charts-in-e2809cVisiblox-Performance-Teste2809d.aspx">amCharts</a> have also publishing some very good performance figures as have <a href="http://blogs.telerik.com/blogs/posts/10-02-23/how-fast-is-your-chart.aspx">Telerik</a>.</p>
<p>Much has changed in the year and a half since my original performance blog post and I thought it would be a good idea to repeat the tests. However, this time I wanted to be more thorough, including a few different types of tests and also using WPF instead of Silverlight, due to the number of email requests I have had for a WPF charting comparison. </p>
<h2>The Test Suite</h2>
<p>In order to allow me to collect performance data for a range of WPF charts across a range of tests, I have written an automated performance test suite. The application uses <a href="http://mef.codeplex.com/">MEF</a> in order to allow me to easily slot in new tests and new charting providers. If you want a copy of the code, please get in touch.</p>
<p>The suite executes the following tests:</p>
<ol>
<li><strong>Line Series Frame Rate</strong> – this test initially renders a ‘streaming’ line series which a fixed number of datapoints. New data is added to the chart as quickly as possible, and each time a new point is added to the front and old point is removed in order to keep a fixed number of points in view. The chart axes are auto-scaled (API permitting). The test initially starts with 50 datapoints, with each test run doubling this number.</li>
<li><strong>Scatter Series Frame Rate</strong> – a number of points are added to the chart. The location of these points is then animated in a manner that emulates Brownian motion. The test initially starts with 50 datapoints, with each test run doubling this number.</li>
<li><strong>Scatter Series Memory Usage</strong> – the above test is re-run, but this time rather than measuring render frame rate, the memory consumed as a result of adding the datapoints is recorded.</li>
</ol>
<p>Initially I used a timer to measure framerate, followed by an attempt to measure via <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.compositiontarget.rendering.aspx">CompositionTarget.Rendering</a>. However, I found that neither method gave an accurate frame rate measure, indeed the WPF team report that the <a href="http://stackoverflow.com/questions/5812384/why-is-frame-rate-in-wpf-irregular-and-not-limited-to-monitor-refresh">CompositionTarget.Rendering can fire multiple times per frame</a>. Instead, I opted for a more manual measurement using the <a href="http://windowsclient.net/wpf/perf/wpf-perf-tool.aspx">WpfPerf tool</a>, which makes use of the <a href="http://windowsclient.net/wpf/white-papers/event-tracing-wpf.aspx">ETW events emitted by WPF</a>.</p>
<h2>Line Series Results</h2>
<p>The results of the line series framerate tests are shown below:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/LineSeriesFrameRateLogLog.png" alt="" title="LineSeriesFrameRateLogLog" width="650" height="359" class="aligncenter size-full wp-image-2103" /></p>
<p>NOTE: I am using a <a href="http://en.wikipedia.org/wiki/Logarithmic_scale">log-log scale</a> for the above chart in order to make it easier to see the shape of the various curves.</p>
<p>Regarding which charting vendors I used for comparison, I tried to include all established and well known vendors in my comparison. For those which have already published performance figures or comments relating to Visiblox, I have included their names. For the others I have simply given them a token name ‘Vendor X’, in order to comply with the trial licencing terms which typically prohibit the publishing of performance figures.</p>
<p>One thing worth noting is that some charting vendors use sampling in order to improve framerates. I found that Vendor A (not included above) uses sampling without providing a mechanism for turning it off. Whereas most vendors that do support sampling allow you to turn it on or off and configure the sampling algorithm used. In order to provide a fair comparison, sampling was turned off on all the charts.</p>
<p>The chart above reveals some interesting patterns, due to the two very different classes of chart under test.</p>
<p><strong>Vector based charts</strong> – WPF UIs are rendered via <a href="http://en.wikipedia.org/wiki/Retained_mode">retained mode vector graphics</a>. Whilst this approach is what has given rise to the very rich UI framework that WPF applications enjoy, it has been found that this approach just doesn’t perform as well as the bitmap-based approach used by Windows Forms when faced with complex UIs. This has led some people to <a href="http://codefornothing.wordpress.com/2011/05/07/and-the-best-wpf-chart-is/">use WinForms charts within their WPF applications</a>! We can see that the faster vector charts from Microsoft Toolkit, Vendor B, the updated Visifire and Visiblox charts are all close to the limit of what is possible with this style of rendering.</p>
<blockquote><p>“ … the major ‘partners’ cannot create a WPF chart that renders 2000 floating points of data in less that 5 seconds. I have tried them all and they are slow so we have had to regress to a WinForms version that renders the same data in milliseconds.” &#8211; from the <a href="http://channel9.msdn.com/Forums/Coffeehouse/it-looks-like-the-WPF-team-still-exists-after-all/c451791f0eb7467d9cd29e1800912559">channel 9 forums</a>. </p></blockquote>
<p><strong>Raster based charts</strong> – Because of the limits of the WPF rendering system the two fastest charts in this test, Visiblox (via the new raster series type as part of the Ultimate Editition) and SciChart (a newcomer that exclusively uses this approach) both use a <a href="http://en.wikipedia.org/wiki/Raster_graphics">raster / bitmap graphics</a> approach, which the WPF and Silverlight frameworks both have support for via the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx">WriteableBitmap class</a>. This approach yields results which are more than 100 times faster than what is possible with vector graphics.</p>
<p>One of the other common complaints made about WPF charts is the initial render time, with charts containing just a few thousands datapoints taking seconds to show on screen. Whilst this test focusses in framerates, it is also gives a good indication of the initial render times, with raster based charts appearing almost instantly when loaded with tens of thousands of points.</p>
<h2>Scatter Series Results</h2>
<p>The results of the Scatter series tests are shown below:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/ScatterRenderFrameRate.png" alt="" title="ScatterRenderFrameRate" width="650" height="431" class="aligncenter size-full wp-image-2105" /></p>
<p>Again, the same pattern emerges, with the raster based approach yielding a significant increase in frame rate over the vector based.</p>
<h2>Scatter Series Memory Usage</h2>
<p>The final test looks at the memory consumption of the various charting providers:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/ScatterMemUsage.png" alt="" title="ScatterMemUsage" width="650" height="384" class="aligncenter size-full wp-image-2102" /></p>
<p>The above shows that the memory consumption is directly related to the number of datapoints present in the chart, however, the scale of this relationship is very different for the charts under test. I have a feeling that the Toolkit charts have a memory leak which contributes to the poor performance in this test.</p>
<h2>Conclusions</h2>
<p>The overall performance of the charting solutions available to WPF (and Silverlight) developers is improving. However, the performance of the WPF rendering system appears to create an upper limit which constrains what can be achieved. The raster-based approach is not subject to these same constraints and as a result provides a considerable improvement in performance.</p>
<p>If you want to have access to the code I used to make these tests, please get in touch. Also, if you are a charting vendor and think you might be Vendor A, B or C in these tests, and wish to be named, let me know.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2012/04/wpf-charting-performance-comparisons-the-battle-continues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everything you wanted to know about databinding in WPF, Silverlight and WP7 (Part Two)</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2012/04/everything-you-wanted-to-know-about-databinding-in-wpf-silverlight-and-wp7-part-two/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2012/04/everything-you-wanted-to-know-about-databinding-in-wpf-silverlight-and-wp7-part-two/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 14:33:17 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2085</guid>
		<description><![CDATA[Introduction This is the second post in my series about databinding in Silverlight and WPF. In the first post I looked at how you wire-up UI controls to a model in the absence of a databinding framework. I showed how databindings can be created in code-behind, removing the need for the various event handlers that [...]]]></description>
			<content:encoded><![CDATA[
<h2>Introduction</h2>
<p>This is the second post in my series about databinding in Silverlight and WPF. In <a href="http://www.scottlogic.co.uk/blog/colin/2012/04/everything-you-wanted-to-know-about-databinding-in-wpf-silverlight-and-wp7-part-one/">the first post</a> I looked at how you wire-up UI controls to a model in the absence of a databinding framework. I showed how databindings can be created in code-behind, removing the need for the various event handlers that the manual method requires, resulting in more readable code, where the connection between a UI control and a model property is all in one place. In this blog post I’ll look at how bindings can be defined in XAML, providing a more concise and flexible method of wiring model objects to your view.</p>
<p>The rough outline for this series is as follows:</p>
<ul>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2012/04/everything-you-wanted-to-know-about-databinding-in-wpf-silverlight-and-wp7-part-one/">Part One</a> – Life before binding, <code>INotifyPropertyChanged </code>and creating bindings in code-behind
<li>Part Two <strong>(this one)</strong> – The binding markup extensions, the <code>DataContext </code>and path syntax
<li>Part Three – Other binding sources, <code>ElementName</code>, <code>TemplatedParent</code>, <code>TemplateBinding</code>
<li>Part Four – Value converters
<li>Part Five – List binding
<li>&#8230;
</ul>
<h2>Code-behind binding: a re-cap</h2>
<p>The previous blog post worked through the creation of a very simple application which creates a model object that represents an event (<code>INotifyPropertyChanged</code> implementation omitted for clarity)</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// A simple model object that represents an event</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> EventModel <span style="color: #008000;">:</span> INotifyPropertyChanged
<span style="color: #008000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">/// Gets / sets the event title</span>
  <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Title <span style="color: #008000;">&#123;</span> <span style="color: #008000;">...</span>  <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
  <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
  <span style="color: #008080; font-style: italic;">/// Gets / sets the date of this event</span>
  <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
  <span style="color: #0600FF; font-weight: bold;">public</span> DateTime Date   <span style="color: #008000;">&#123;</span> <span style="color: #008000;">...</span>  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>And render it with the following UI:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/figOne.png" alt="" title="figOne" width="250" height="155" class="aligncenter size-full wp-image-2073" /></p>
<p>The XAML for the UI is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Name:&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;EventTitle&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Grid.Column</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Date:&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sdk:DatePicker</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;EventDate&quot;</span></span>
<span style="color: #009900;">                  <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">Grid.Column</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The previous blog post wired up the above UI by creating bindings in code-behind:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> MainPage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  InitializeComponent<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// create a model object</span>
  _event <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> EventModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    Date <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DateTime<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2011</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>,
    Title <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Silverlight User Group&quot;</span>
  <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// bind the Date to the UI</span>
  EventDate<span style="color: #008000;">.</span><span style="color: #0000FF;">SetBinding</span><span style="color: #008000;">&#40;</span>DatePicker<span style="color: #008000;">.</span><span style="color: #0000FF;">SelectedDateProperty</span>, <span style="color: #008000;">new</span> Binding<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Date&quot;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    Source <span style="color: #008000;">=</span> _event,
    Mode <span style="color: #008000;">=</span> BindingMode<span style="color: #008000;">.</span><span style="color: #0000FF;">TwoWay</span>
  <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// bind the Title to the UI</span>
  EventTitle<span style="color: #008000;">.</span><span style="color: #0000FF;">SetBinding</span><span style="color: #008000;">&#40;</span>TextBox<span style="color: #008000;">.</span><span style="color: #0000FF;">TextProperty</span>, <span style="color: #008000;">new</span> Binding<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Title&quot;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    Source <span style="color: #008000;">=</span> _event,
    Mode <span style="color: #008000;">=</span> BindingMode<span style="color: #008000;">.</span><span style="color: #0000FF;">TwoWay</span>
  <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Most applications create bindings within the XAML markup … and that is exactly what we shall do next!</p>
<h2>Binding Markup Extension</h2>
<p>It is quite unusual to see code which creates bindings in C# (code behind), this is because there is a simpler, more elegant way. Firstly, we’ll change the code above to remove all of the bindings, and instead set the <code>DataContext </code>of the page to the event that we wish to edit:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> MainPage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  InitializeComponent<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// create a model object</span>
  _event <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> EventModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    Date <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DateTime<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2011</span>, <span style="color: #FF0000;">7</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>,
    Title <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Silverlight User Group&quot;</span>
  <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// bind the Date to the UI</span>
  <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DataContext</span> <span style="color: #008000;">=</span> _event<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Next we’ll update the XAML, removing the names of the controls used to edit this event (we only named them so that they were accessible form code-behind), and adding bindings as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;LayoutRoot&quot;</span> <span style="color: #000066;">Background</span>=<span style="color: #ff0000;">&quot;White&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  ...
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Name:&quot;</span></span>
<span style="color: #009900;">              <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=Title, Mode=TwoWay}&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">Grid.Column</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Date:&quot;</span></span>
<span style="color: #009900;">              <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sdk:DatePicker</span> <span style="color: #000066;">SelectedDate</span>=<span style="color: #ff0000;">&quot;{Binding Path=Date, Mode=TwoWay}&quot;</span></span>
<span style="color: #009900;">                  <span style="color: #000066;">Grid.Row</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">Grid.Column</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Compiling and running this modified version of our code yields exactly the same result. The UI displays the initial values of the event, and the bindings take care of updating the UI if the model changes and updating the model based on user interactions with the controls. So let’s take a closer look at how these binding work.</p>
<p>Within XAML, any attribute value that is surrounded in curly braces <code>{…}</code> is a markup extension. Whilst most of your XAML markup is simply used to construct controls and panels in order to assemble the visual tree of your application, markup extension inject extra functionality into the XAML parser. The <a href="http://msdn.microsoft.com/en-us/library/ms750413.aspx">Binding Markup Extension</a> constructs a binding and associates it with the <code>UIElement</code> or <code>FrameworkElement </code>that the property belongs to.</p>
<p>As you might recall from the previous blog post, all bindings have a source object, source property, target object and target property:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/binding.png" alt="" title="binding" width="600" height="111" class="aligncenter size-full wp-image-2075" /></p>
<p>How do these map to our XAML binding? Let’s look at the various components of our markup:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/BindingMarkup.png" alt="" title="BindingMarkup" width="500" height="183" class="aligncenter size-full wp-image-2086" /></p>
<p>The <strong>target object</strong> is the object that owns the property which we are binding to, i.e. the UI control rendering our data. The <strong>target property</strong> is the property that has been set via the markup extension, and the <strong>source property</strong> is the path of the binding.</p>
<p>However, there is something missing? Where is the <strong>source object</strong>? In our example above, where is the object that owns this <code>Title </code>property we are binding to the UI? If you recall earlier we set the <code>DataContext </code>property of our <code>MainPage</code> to the event class which is being edited &#8230; <em>this </em>is our <strong>source object</strong>. The <code>DataContext </code>is a rather special property for a couple of reasons:</p>
<ol>
<li><strong>Inheritence </strong>– The <code>DataContext </code>value is inherited down the visual tree from one control to the next. Even though we set the <code>DataContext </code>of <code>MainPage </code>to our model object, if you set a breakpoint in the code and inspect the <code>DataContext </code>of the above <code>TextBox </code>you will also find that it is set to the same event object.</li>
<li><strong>Default source</strong> – Any bindings that are defined without the source object being specified (via the <code>Binding.Source</code> property), will take the <code>DataContext</code> of the target object as the source. In the case illustrated above this is the <code>DataContext</code> of the <code>TextBox</code>, which has been inherited from <code>MainPage</code>.</li>
</ol>
<p>These two properties of <code>DataContext </code>and the binding framework result in a concise and elegant way to wire up your applications user-interface.</p>
<h2>The Property Path Syntax</h2>
<p>We’ll explore a few other features of the binding framework via a more complex example, this time we have a model object, <code>PersonModel</code>, that has a relationship to another model object, <code>AddressModel</code>. A summary of these classes is show below (<code>INotifyPropertyChanged </code>implementation omitted for clarity):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> PersonModel <span style="color: #008000;">:</span> INotifyPropertyChanged
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Forename <span style="color: #008000;">&#123;</span> <span style="color: #008000;">...</span>  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Surname <span style="color: #008000;">&#123;</span> <span style="color: #008000;">...</span>  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> AddressModel WorkAddress <span style="color: #008000;">&#123;</span> <span style="color: #008000;">...</span>  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> AddressModel <span style="color: #008000;">:</span> INotifyPropertyChanged
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Street <span style="color: #008000;">&#123;</span> <span style="color: #008000;">...</span>  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> City <span style="color: #008000;">&#123;</span> <span style="color: #008000;">...</span>  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Again, we create an instance of this class and set it as the <code>DataContext</code> of our user control:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">_model <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> PersonModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  Surname <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Eberhardt&quot;</span>,
  Forename <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Colin&quot;</span>,
  WorkAddress <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> AddressModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    Street <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;6 Charlotte Square&quot;</span>,
    City <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Newcastle&quot;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
&nbsp;
<span style="color: #008080; font-style: italic;">// bind the Date to the UI</span>
<span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DataContext</span> <span style="color: #008000;">=</span> _model<span style="color: #008000;">;</span></pre></div></div>

<p>(Aren’t <a href="http://msdn.microsoft.com/en-us/library/bb384062.aspx">C# object initializers</a> just great!)</p>
<p>Binding the <code>Surname </code>and <code>Forename </code>to the UI is straightforward, but how about the <code>WorkAddress</code>? The <code>Path</code> property of a <code>Binding</code> supports a special <a href="http://msdn.microsoft.com/en-us/library/cc645024(VS.95).aspx">property path-syntax</a> which has a dot notation for navigating relationships. We can bind our UI to the various properties of the Address as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Street:&quot;</span>  ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=WorkAddress.Street, Mode=TwoWay}&quot;</span> ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;City:&quot;</span> ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=WorkAddress.City, Mode=TwoWay}&quot;</span> ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Which yields the following UI:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/PersonUI.png" alt="" title="PersonUI" width="300" height="228" class="aligncenter size-full wp-image-2087" /></p>
<p>Now because Address implements <code>INotifyPropertyChanged</code>, if we change the <code>Street</code> or <code>City </code>of the object bound to the UI, the binding framework will take care of pushing this change to the binding targets (i.e. the TextBox instances). But, what if we replace the <code>Address</code> instance entirely? For example …</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Button_Click<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, RoutedEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  _model<span style="color: #008000;">.</span><span style="color: #0000FF;">WorkAddress</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> AddressModel<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
      Street <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;62 Arcacia Ave.&quot;</span>,
      City <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Bananaville&quot;</span>
    <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Again, the binding framework updates the UI. The binding framework not only detects changes in the source property, it is able to detect changes at any point in the chain of property relationships from the <code>DataContext</code>. That’s pretty smart!</p>
<p>The property-path syntax supports binding to arrays and dictionaries via indexers, for example:</p>
<pre>
{Binding Path=ArrayOfThings[0]}
</pre>
<p>and</p>
<pre>
{Binding Path=DictionaryOfStuff["foo"]}
</pre>
<p>I’m not going to give examples of all the various bindings that are possible, <a href="http://msdn.microsoft.com/en-us/library/cc645024(VS.95).aspx">MSDN has a good reference for these</a>.</p>
<h2>Creating Binding ‘Islands’</h2>
<p>In the previous example we had two bindings that navigated the relationship from Person to <code>Address </code>to bind to properties of the <code>Address </code>object. Instead of repeatedly navigating the same relationship, we can bind a ‘region’ of our UI to the <code>WorkAddress</code> property.</p>
<p>If you recall, the <code>DataContext </code>is inherited throughout the visual tree and is the default source for bindings. If we change the <code>DataContext </code>of a common root element of our various Address bindings to the <code>Person.WorkAddress</code>, we can simplify our bindings. We could set the <code>DataContext </code>in code-behind, but there is a more elegant way:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Forename:&quot;</span>  ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=Forename, Mode=TwoWay}&quot;</span>  ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Border</span> <span style="color: #000066;">DataContext</span>=<span style="color: #ff0000;">&quot;{Binding WorkAddress}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid</span> <span style="color: #000066;">util:GridUtils.RowDefinitions</span>=<span style="color: #ff0000;">&quot;,,&quot;</span> <span style="color: #000066;">util:GridUtils.ColumnDefinitions</span>=<span style="color: #ff0000;">&quot;,&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;Street:&quot;</span>  ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=Street, Mode=TwoWay}&quot;</span>  ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBlock</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;City:&quot;</span>  ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=City, Mode=TwoWay}&quot;</span>  ... <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Border<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>In the above XAML we are binding the <code>DataContext </code>of the <code>Border</code> element to the <code>WorkAddress </code>property of the Person instance (which was set as the <code>DataContext</code> of our UI in code-behind). As a result, all the children of the <code>Border</code> have the <code>Address </code>instance as their <code>DataContext</code>, so we can bind to the properties directly. This creates an ‘island’ within our UI that is bound to <code>Address </code>as shown graphically below:</p>
<p><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/BindingIslands.png" alt="" title="BindingIslands" width="550" height="210" class="aligncenter size-full wp-image-2088" /></p>
<h2>Binding Shorthand and Longhand</h2>
<p>We’ll wrap up part two of the series on databinding by looking at a couple of variations in the binding syntax, the first is a ‘longhand’ version of the binding. Instead of using the binding markup extension, it is possible to create the binding instance in XAML, for example, the simple binding to <code>Forename</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=Forename}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Can be expressed as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox.Text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Binding</span> <span style="color: #000066;">Path</span>=<span style="color: #ff0000;">&quot;Forename&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextBox.Text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextBox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This yields exactly the same result. What’s the point in the longhand version? Good question, I have only used it occasionally myself, typically within multi-bindings, or where validation rules are being added.</p>
<p>If instead we want to make our bindings simpler, we can omit the Path and simply express the binding as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Forename}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Now there are some instances where you do not want to bind to a property of your source (i.e. <code>DataContext</code>), rather you want to bind to the source itself. The syntax for this is a single ‘dot’:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding Path=.}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Or, in this case, we can use the very-very short:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextBox</span> <span style="color: #000066;">Text</span>=<span style="color: #ff0000;">&quot;{Binding}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>We’ll see some instances of when this might be useful in a future part of this blog series on binding when we look at collection-binding.</p>
<h2>Summary</h2>
<p>In this blog post we have looked at the binding markup extension and how this provides a concise mechanism for creating bindings. We have also seen how the <code>DataContext</code>, which is the default source for our bindings, plays a pivotal role in the Silverlight and WPF binding frameworks. Finally, we have seen how we can use bindings to ‘switch’ the <code>DataContext </code>in order to create binding ‘islands’ within out UI.</p>
<p>In the next instalment we’ll look at some of the other ways we can specify the binding source and when you might use them, but now we’ll take a well-earned break … see you next time.</p>
<p>You can download the sourcecode for the examples described in this blogpost: <a href='http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2012/04/DatabindingExamplesPartTwo.zip'>DatabindingExamplesPartTwo.zip</a></p>
<p>Regards, Colin E.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2012/04/everything-you-wanted-to-know-about-databinding-in-wpf-silverlight-and-wp7-part-two/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving to the Web 2: Dark Territory</title>
		<link>http://www.scottlogic.co.uk/2012/04/moving-to-the-web-2-dark-territory/</link>
		<comments>http://www.scottlogic.co.uk/2012/04/moving-to-the-web-2-dark-territory/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 13:25:26 +0000</pubDate>
		<dc:creator>Chris Price</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=147409</guid>
		<description><![CDATA[This series of posts (part 1) are attempting to do the impossible, to try and give desktop developers a brief introduction to developing on the web. I say impossible because the web is such a vast topic. On one side sits stacks of bizarre and nuanced APIs, but on the other mountains of really useful [...]]]></description>
			<content:encoded><![CDATA[<p><a style="float: right; margin-left: 16px;" href="http://www.scottlogic.co.uk/blog/chris/"><img class="aligncenter size-full wp-image-145833" style="border: 1px solid black;" title="Chris Price" src="http://www.scottlogic.co.uk/wp-content/uploads/2012/03/me1.png" alt="" /></a><em>This series of posts (<a href="http://www.scottlogic.co.uk/2012/03/moving-to-the-web/">part 1</a>) are attempting to do the impossible, to try and give desktop developers a brief introduction to developing on the web. I say impossible because the web is such a vast topic. On one side sits stacks of bizarre and nuanced APIs, but on the other mountains of really useful resources and frameworks that help smooth over the cracks. I can&#8217;t hope to cover even a small fraction of what exists, so I apologise now if your framework/resource of choice is missing. I&#8217;ve simply tried to give an ordered list of concepts to work through, in a way that I think I would find useful if I was first starting out on the web.<br />
</em></p>
<h2 style="clear: both;">Debugging</h2>
<p>If you&#8217;ve had any experience of JavaScript development before it&#8217;s likely that along the way you&#8217;ve used the window method alert to aid your debugging. It&#8217;s a blocking call which shows a dialog box containing some static text and an OK button which the user must click. The blocking nature of the call is as much a blessing as a curse depending on what you were trying to debug, and being restricted to static text at some point invariably means writing a custom object formatter. But by far the biggest annoyance of this method is if you accidentally leave one in a loop!</p>
<pre style="font-size: 48px; font-weight: bold; text-align: center;">alert("alerts suck!")</pre>
<p>Luckily, all the major browsers now either ship with, or provide an extension offering, the kind of debugger you&#8217;ll be used to seeing in a standard IDE. As well as this they also provide some common functionality which is much more useful than alert -<br />
<a style="float: right; margin: 16px 0 0 16px;" href="http://code.google.com/chrome/devtools/docs/overview.html"><img class="aligncenter size-full wp-image-145781" src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/Capture.png" alt="" width="266" height="354" /></a></p>
<ul>
<li>debugger &#8211; a <a href="https://developer.mozilla.org/en/JavaScript/Reference/Statements/debugger">JavaScript statement</a> which causes an attached debugger to break. This is useful when you want to replicate the blocking behavior of the alert statement but for whatever reason can&#8217;t place a break-point manually.</li>
<li>console.log &#8211; a <a href="http://getfirebug.com/wiki/index.php/Console_API">JavaScript method</a> which accepts n arguments and logs the values to the debugger console. In most of the developer tools when the logged values are displayed in the console they are fully interactive, so no need for formatter methods. Also, because the values are appended to a console, there&#8217;s no endless clicking of the OK button.</li>
</ul>
<p>Chrome, Firefox and Safari all offer quite a bit more besides, so I&#8217;d recommend reading through the Firebug documentation of the <a href="http://getfirebug.com/wiki/index.php/Console_API">console API</a> and the <a href="http://getfirebug.com/wiki/index.php/Command_Line_API">command line API</a> as most of it applies to all three.</p>
<h4>Tools</h4>
<p>A quick rundown of the developer tools for the major browsers -</p>
<ul>
<li>Google Chrome &#8211; built-in very fully featured <a href="http://code.google.com/chrome/devtools/docs/overview.html">developer tools</a></li>
<li>Mozilla Firefox &#8211; the <a href="http://getfirebug.com/">Firebug </a>extension.</li>
<li>Internet Exlorer &#8211; built-in <a href="http://msdn.microsoft.com/en-us/library/hh772704(VS.85).aspx">F12 developer tools</a> from version 8, previous versions require a <a href="http://www.microsoft.com/download/en/details.aspx?id=18359">plug-in</a> (it is also possible to use Visual Studio for JavaScript debugging but you still need to go back to the F12 tools to get the DOM/CSS inspector).</li>
<li>Apple Safari &#8211; built-in <a href="https://developer.apple.com/technologies/safari/developer-tools.html">developer tools</a> (almost identical to Chrome because the tools are actually part of WebKit on which both Chrome and Safari are built).</li>
</ul>
<p><em> Also worthy of a mention is a tool I&#8217;ve found useful in the past for debugging performance problems in IE old - <a href="http://ajax.dynatrace.com/ajax/en/">dynaTrace AJAX edition</a>.</em></p>
<h2 style="clear: both;">The DOM</h2>
<p>The DOM is the interface against which you write your JavaScript, basically the browser global object (window). To be clear, that&#8217;s not what it originally meant, but it is what I believe it has come to mean, the catch-all name for the browser APIs.</p>
<pre style="font-size: 48px; font-weight: bold; text-align: center;">JavaScript != the DOM</pre>
<p><a style="float: left; margin: 16px 16px 16px 0;" href="https://developer.mozilla.org/en-US/"><img class="aligncenter size-full wp-image-145781" title="mdn-logo" src="http://www.scottlogic.co.uk/wp-content/uploads/2012/03/mdn-logo.png" alt="" width="128" height="146" /></a></p>
<p>The main reason for introducing it as a topic separate from JavaScript is to make that point clear. Whilst there are a few minor inconsistencies between the JavaScript engines in the different browsers (e.g. trailing commas in array definitions), the number of differences between the DOM implementations is in another league! Therefore whereas with JavaScript I recommended learning the language, for the DOM I recommend picking an abstraction so you don&#8217;t have to deal with the inconsistencies.</p>
<p>If you do find yourself in need of a DOM reference, again I recommend you avoid w3schools, its DOM reference hasn&#8217;t been updated in years and some of the linked topics are just plain wrong. Instead I personally use <a href="https://developer.mozilla.org/en-US/">Mozilla Developer Network</a>, it has a well maintained, advert-free <a href="https://developer.mozilla.org/en/DOM">DOM wiki</a> which is full of useful and up-to-date reference material.</p>
<h2 style="clear: both;">DOM Abstraction Libraries/jQuery</h2>
<p>DOM abstraction is the staple of JavaScript libraries, almost all include some form of it. While there is a modern trend trend for building smaller more focused libraries (e.g. Knockout, Backbone.js, etc.), generally this is still true (e.g. YUI, Closure, Ext.js).</p>
<p><a style="float: left; margin: 16px 16px 16px 0;" href="http://www.jquery.com/"><img class="aligncenter size-full wp-image-145781" title="mdn-logo" src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/jquery.png" alt="" width="215" height="53" /></a></p>
<p><a href="http://www.jquery.com/">jQuery</a> is probably the most widely-known and used such library on the web these days. It provides a very fluid and expressive <a href="http://api.jquery.com/">API</a> for manipulating/measuring DOM elements, managing event handlers, running simple animations and making AJAX requests. </p>
<p>However, a very important point to note is that it isn&#8217;t much more than that. To put that statement in context I&#8217;m going to quote a <a href="http://www.scottlogic.co.uk/blog/colin/2011/05/flex-silverlight-html5-time-to-decide/">whitepaper</a> Graham and myself helped Colin write a year ago -</p>
<p style="text-align: center; padding: 0 20px;"><em>In order to differentiate between different web sites and applications we will start by looking at a single metric: complexity. The most basic, least complex web sites are comprised of largely <strong>static</strong> content, they may have complex server-side logic generating and maintaining this content, but once it reaches the browser it does not change, resembling the pages of a book. As the complexity increases, web sites become more <strong>dynamic</strong>, with user interactions resulting in small changes to the page currently being displayed. Further increases in complexity result in truly <strong>interactive</strong>, or immersive web sites where there is no longer the concept of a page. Finally, at the most complex end of the spectrum we have <strong>applications</strong>, which perform complex and useful business functions and often feel somewhat disconnected from the web.</em></p>
<p>At the time we used the spectrum to show where the plugins of the time (Flex/Silverlight) could most appropriately be used. I&#8217;ve always argued that the web could adequately provide for each type of site and with hindsight (i.e. <a href="http://www.scottlogic.co.uk/blog/colin/2011/11/the-untimely-demise-of-the-plugin-and-how-lob-developments-will-suffer/">the death of the plugin technologies timely or otherwise</a>) it seems I was correct!</p>
<p><a style="float: right; margin-left: 16px;" href="http://knockoutjs.com/"><img class="aligncenter size-full wp-image-145781" src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/icon.png" alt="" width="130" height="130" /></a></p>
<p>I still think the spectrum is a relevant guide for picking out an appropriate framework to use for a site. In the case of jQuery, it&#8217;s not a library that&#8217;s going to provide much benefit once you hit the top end of dynamic. That&#8217;s because it doesn&#8217;t provide a framework for MV* style patterns. For top-end dynamic, interactive or applications other libraries will be a better choice -</p>
<ul>
<li><a href="http://knockoutjs.com/">Knockout </a>which sits on top of jQuery and provides data-binding and templating. It isn&#8217;t the only appropriate library, far from it, but I give it a special mention because of the <a href="http://learn.knockoutjs.com/">interactive tutorials</a>. I think they are a great idea implemented very cleanly, which can really help someone new to web development get a feel for how it should be done.</li>
<li><a href="http://addyosmani.github.com/todomvc/">TodoMVC</a> allows you to get a flavor of many of the other frameworks that are available. It&#8217;s a site (and <a href="http://github.com/addyosmani/todomvc/">github repository</a>) full of examples of using different frameworks to produce the same todo list application. You can use it to evaluate whether an alternative framework may be more appropriate for the complexity of the site you&#8217;re developing and your preferred coding style.</li>
</ul>
<h2 style="clear: both;">You&#8217;re not a cook</h2>
<p><img style="float: left; margin-right: 16px;" src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/vandamme460-300x180.jpg" alt="" title="I didn't say that but I do eat snakes for breakfast" width="300" height="180" class="alignnone size-medium wp-image-148972" /><br />
Yea well&#8230; I also cook.</p>
<p>Hopefully that&#8217;s given you a taste for web development, or at the least given you a couple of links you&#8217;ve not seen before. I had hoped to cover the advantages/disadvantages of using Google&#8217;s development frameworks (Closure/GWT) when building various complexity applications, but that&#8217;s a vast topic in itself so I&#8217;ll save that one for a separate post.</p>
<h2 style="clear: both;"></h2>
<p><a href="https://twitter.com/share" class="twitter-share-button" data-via="100pxls">Tweet</a><br />
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script><br />
<g:plusone size="medium"></g:plusone><br />
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2012/04/moving-to-the-web-2-dark-territory/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Junior Systems Administrator</title>
		<link>http://www.scottlogic.co.uk/2012/04/junior-systems-administrator/</link>
		<comments>http://www.scottlogic.co.uk/2012/04/junior-systems-administrator/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 08:36:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Press Releases]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=148727</guid>
		<description><![CDATA[Very competitive salary + bonus + benefits; Newcastle Upon Tyne]]></description>
			<content:encoded><![CDATA[<p><strong>Very competitive salary + bonus + benefits; Newcastle Upon Tyne</strong></p>
<p>Scott Logic is a growing software consultancy which provides the very best in bespoke financial software for leading financial institutions.</p>
<p>As part of our growth, we are seeking to recruit a Junior Systems Administrator to work alongside the existing Systems Administrator.</p>
<p>This is a new position which involves the maintenance and management of the company&#8217;s networks, servers and workstations at all three of the company&#8217;s offices.  The role is based at the main office in Newcastle but will involve occasional visits to the Bristol and Edinburgh offices.  The company will soon be moving to a new office in central Newcastle and the role will also involve taking an active part in the move.</p>
<p>Key Accountabilities:</p>
<ul>
<li>Monitoring and maintaining internet connections, firewalls and switches and administration of Windows domain controllers and user accounts</li>
<li>Administration of Microsoft Exchange servers</li>
<li>Maintenance of several Linux development, web and application servers  and maintenance of the Asterisk VOIP system</li>
<li>Maintenance of records of systems, software, services and support contracts</li>
</ul>
<p>Essential Skills:</p>
<ul>
<li>Experience of Linux and Windows server administration</li>
<li>Experience of networking, routing and firewalling technologies</li>
<li>Experience of supporting software development systems</li>
</ul>
<p>Desirable Skills:</p>
<ul>
<li>Experience with Cisco switches</li>
<li>Experience with Elastix / Asterisk VOIP platform</li>
<li>Experience with Java build systems and application servers (Maven, Continuum, JBoss etc)</li>
<li>Detailed knowledge of Windows Active Directory</li>
<li>Knowledge of Bacula backup software</li>
<li>Knowledge of BGP</li>
</ul>
<p>We offer a highly competitive salary and benefits package, including:</p>
<ul>
<li>Performance and profit related bonus scheme</li>
<li>25 days holiday per year, growing with length of service up to 30 days</li>
<li>Life assurance</li>
<li>Referral programme – payable to anyone who refers a successful candidate</li>
</ul>
<p>To apply, email your latest CV and a brief cover note to <a href="mailto:applications@scottlogic.co.uk">applications@scottlogic.co.uk</a> quoting reference number SYSAD01. The closing date for applications is 30th April, 2012.</p>
<p>Direct applicants only please.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2012/04/junior-systems-administrator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KnockoutJS vs. Silverlight – a new CodeProject article</title>
		<link>http://www.scottlogic.co.uk/blog/colin/2012/04/knockoutjs-vs-silverlight-a-new-codeproject-article/</link>
		<comments>http://www.scottlogic.co.uk/blog/colin/2012/04/knockoutjs-vs-silverlight-a-new-codeproject-article/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 14:50:22 +0000</pubDate>
		<dc:creator>Colin Eberhardt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[codeproject]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/blog/colin/?p=2083</guid>
		<description><![CDATA[
I have just published a new article over on CodeProject called &#8220;KnockoutJS vs. Silverlight&#8221;. It demonstrates the implementation of the same application using both frameworks, and seeks to answer the question &#8220;Which is better, Silverl...]]></description>
			<content:encoded><![CDATA[
<p>I have just published a new article over on CodeProject called <a href="http://www.codeproject.com/Articles/365120/KnockoutJS-vs-Silverlight">&#8220;KnockoutJS vs. Silverlight&#8221;</a>. It demonstrates the implementation of the same application using both frameworks, and seeks to answer the question <em>&#8220;Which is better, Silverlight or Knockout?&#8221;</em></p>
<p><a href="http://www.codeproject.com/KB/scripting/365120/SilverlightQuiz.jpg"><img alt="" src="http://www.codeproject.com/KB/scripting/365120/SilverlightQuiz.jpg" class="alignnone" width="424" height="376" /></a></p>
<p>It&#8217;s a bit of an epic (6,500 words). I hope people find it useful!</p>
<p><a href="http://www.codeproject.com/Articles/365120/KnockoutJS-vs-Silverlight"><img src="http://www.scottlogic.co.uk/blog/colin/wp-content/uploads/2009/04/codeproject.gif" alt="" title="codeproject" width="225" height="72" class="aligncenter size-full wp-image-283" /></a></p>
<p>Regards, Colin E.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/blog/colin/2012/04/knockoutjs-vs-silverlight-a-new-codeproject-article/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blood, Sweat and Beers</title>
		<link>http://www.scottlogic.co.uk/2012/04/blood-sweat-and-beers/</link>
		<comments>http://www.scottlogic.co.uk/2012/04/blood-sweat-and-beers/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 15:41:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Latest News Widget]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.scottlogic.co.uk/?p=148510</guid>
		<description><![CDATA[Scott Logic narrowly missed out on a victory at their first attempt at the Hedley Barrel Race.]]></description>
			<content:encoded><![CDATA[<p>Despite two-thirds of the team being first across the line, Scott Logic narrowly missed out on a victory at their first attempt at the Hedley Barrel Race, organised by the <a href="http://www.thefeathers.net/index.php">Feathers Inn</a> in aid of <a href="http://www.northoftynesearchandrescue.org.uk/">Northumberland Search and Rescue</a>.</p>
<p>Three plucky Scott Logic employees (two seasoned veterans with scores of races under their belts, and one relative newcomer to the world of competitive running) made the journey to Hedley-on-the-Hill on Easter Monday.</p>
<p><a href="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel31.jpg"><img src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel31.jpg" alt="" title="barrel3" width="450" height="338" class="aligncenter size-full wp-image-148518" /></a></p>
<p>The name of the village is something of a clue to what was in store for them. An initial recce of the race route revealed a steep climb through a field of long grass, leading to a flat tarmac sprint along the road to the finish line outside the pub. Unfortunately, a lack of local knowledge meant that the team didn&#8217;t realise that there was not just one, but three fields to ascend between the start line and the finishing straight, something which became very clear as all the competitors headed downhill (and down, and down again) to the start line where the empty barrels were waiting for them. Much discussion of tactics ensued:  was it better to find a slightly lighter barrel, or use one that was easier to hold?</p>
<p><a href="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel5.jpg"><img src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel5.jpg" alt="" title="barrel5" width="450" height="326" class="aligncenter size-full wp-image-148520" /></a></p>
<p>After a tense few minutes on the start line waiting for the last of the junior teams to arrive, it was time for the off. Paul and Stuart started off carrying the barrel between them, with Sam ready to take one of their places when fatigue set in. Another team took the initial lead by taking an alternative route onto the track at the side of the field where running was slightly easier, but the Scott Logic boys soon caught and overhauled them.</p>
<p>Reaching the top of the first field, Paul found that he was having trouble catching his breath due to a lingering case of man-flu, so Sam took a spell at carrying one end of the barrel while Paul got his second wind then came back for another go. Through the difficult scrub and hedges at the top of the first field, the Scott Logic team were starting to establish a clear lead, which they managed to maintain across the heavily-rutted second field despite taking a slight detour when they headed for the corner of the field instead of the gap in the hedge.</p>
<p><a href="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel71.jpg"><img src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel71.jpg" alt="" title="barrel7" width="433" height="485" class="aligncenter size-full wp-image-148526" /></a></p>
<p>After negotiating the narrow gap into the final field, the team started hearing the cheers of the crowd, along with some gasps of disbelief at the lead they had established. By this stage the intense effort was starting to take its toll, but Stuart put in a super-human effort to carry the barrel single-handed up part of the field while Paul did his best to keep up. Unfortunately, Sam&#8217;s lack of experience was beginning to show, and he started being overhauled by the following team.</p>
<p>As Paul and Stuart reached the top of the final ascent, it was clear that they had a massive lead over the rest of the competition, but equally clear that Sam was some way behind. The sight of flat tarmac leading to the finish line was very welcome, and after a short sprint the barrel was taken over the finish line where Paul and Stuart had plenty of time to wonder where everyone had got to. Their initial delight at being first over the line soon turned to disappointment as the evenly-matched second team came in together in fine style for a well-deserved victory; quite closely followed by Sam, who&#8217;d put in a brave effort that wasn&#8217;t quite enough.</p>
<p><a href="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel6.jpg"><img src="http://www.scottlogic.co.uk/wp-content/uploads/2012/04/barrel6.jpg" alt="" title="barrel6" width="361" height="456" class="aligncenter size-full wp-image-148522" /></a></p>
<p>The traditional post-race refreshment was soon obtained and enjoyed. Unfortunately the team had to make do with a pint or two each, instead of the nine gallons that they&#8217;d have got had they won. Maybe next year, and perhaps there&#8217;ll be more than one Scott Logic team&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scottlogic.co.uk/2012/04/blood-sweat-and-beers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

