<?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>Ben Dewey - Web, XAML, and Cloud &#187; Blog</title>
	<atom:link href="http://www.bendewey.com/index.php/category/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bendewey.com</link>
	<description>Father, Developer, Microsoft MVP, Speaker, and Author</description>
	<lastBuildDate>Sat, 22 Mar 2025 05:04:02 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.8.41</generator>
	<item>
		<title>Creating Responsive Apps with JavaScript and Bootstrap at Atlanta Code Camp</title>
		<link>http://www.bendewey.com/index.php/546/creating-responsive-apps-with-javascript-and-bootstrap-at-atlanta-code-camp</link>
		<comments>http://www.bendewey.com/index.php/546/creating-responsive-apps-with-javascript-and-bootstrap-at-atlanta-code-camp#comments</comments>
		<pubDate>Sat, 24 Oct 2015 19:40:37 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=546</guid>
		<description><![CDATA[I had two sessions at the Atlanta Code Camp. Here are the slides for my second presentation on Creating Responsive Apps with Javascript and Bootstrap..]]></description>
				<content:encoded><![CDATA[<p>I had two sessions at the <a href="http://atlantacodecamp.com/2015/">Atlanta Code Camp</a>.  Here are the slides for my second presentation on Creating Responsive Apps with Javascript and Bootstrap.  All the code is available online at <a href="https://github.com/bendewey/BootstrapDemo">https://github.com/bendewey/BootstrapDemo</a>.</p>
<p><iframe src="https://onedrive.live.com/embed?cid=473151CB8AFE66BA&#038;resid=473151CB8AFE66BA%21245693&#038;authkey=AA_uImE-lwQ7foc&#038;em=2" width="402" height="327" frameborder="0" scrolling="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/546/creating-responsive-apps-with-javascript-and-bootstrap-at-atlanta-code-camp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Unit Testing at Atlanta Code Camp</title>
		<link>http://www.bendewey.com/index.php/541/javascript-unit-testing-at-atlanta-code-camp</link>
		<comments>http://www.bendewey.com/index.php/541/javascript-unit-testing-at-atlanta-code-camp#comments</comments>
		<pubDate>Sat, 24 Oct 2015 14:54:13 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=541</guid>
		<description><![CDATA[It was great to visit Atlanta and speak at the Atlanta Code Camp. As promised, here are the slides for the presentation. All the code.]]></description>
				<content:encoded><![CDATA[<p>It was great to visit Atlanta and speak at the <a href="http://atlantacodecamp.com/2015/">Atlanta Code Camp</a>.  As promised, here are the slides for the presentation.  All the code is available online at <a href="http://github.com/bendewey/jstesting-demo">http://github.com/bendewey/jstesting-demo</a>.</p>
<p><iframe src="https://onedrive.live.com/embed?cid=473151CB8AFE66BA&#038;resid=473151CB8AFE66BA%21245694&#038;authkey=AHVknRH5Ns4fNZ4&#038;em=2" width="402" height="327" frameborder="0" scrolling="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/541/javascript-unit-testing-at-atlanta-code-camp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adaptive UIs for Windows Apps at Raliegh Code Camp</title>
		<link>http://www.bendewey.com/index.php/539/adaptive-uis-for-windows-apps-at-raliegh-code-camp</link>
		<comments>http://www.bendewey.com/index.php/539/adaptive-uis-for-windows-apps-at-raliegh-code-camp#comments</comments>
		<pubDate>Sat, 17 Oct 2015 14:53:45 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=539</guid>
		<description><![CDATA[It was a joy to visit Raleigh and speak at Raleigh Code Camp. As promised, here are the slides for the presentation. All the code.]]></description>
				<content:encoded><![CDATA[<p>It was a joy to visit Raleigh and speak at <a href="http://www.codecamp.org/Raleigh">Raleigh Code Camp</a>.  As promised, here are the slides for the presentation.  All the code is available online at <a href="https://github.com/bendewey/WindowsAdaptiveUiDemos">https://github.com/bendewey/WindowsAdaptiveUiDemos</a>.</p>
<p><iframe src="https://onedrive.live.com/embed?cid=473151CB8AFE66BA&#038;resid=473151CB8AFE66BA%21242985&#038;authkey=AIK3QP40wCoMKic&#038;em=2" width="402" height="327" frameborder="0" scrolling="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/539/adaptive-uis-for-windows-apps-at-raliegh-code-camp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Compiled Binding (x:Bind) with a ViewModel</title>
		<link>http://www.bendewey.com/index.php/533/using-compiled-binding-xbind-with-a-viewmodel</link>
		<comments>http://www.bendewey.com/index.php/533/using-compiled-binding-xbind-with-a-viewmodel#comments</comments>
		<pubDate>Fri, 21 Aug 2015 16:16:08 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Windows10]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=533</guid>
		<description><![CDATA[The new compiled binding or x:Bind functionality in Universal Windows Platform (UWP) Apps for Windows 10 offers some real performance improvements over the classic binding.]]></description>
				<content:encoded><![CDATA[<p>The new compiled binding or x:Bind functionality in Universal Windows Platform (UWP) Apps for Windows 10 offers some real performance improvements over the classic binding approach.  In most cases implementing this new feature is as simple as changing your Binding statements to x:Bind.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- Change this --&gt;
&lt;TextBox Header=&quot;Username&quot; Text=&quot;{Binding Username, Mode=TwoWay}&quot;/&gt;

&lt;!-- to this --&gt;
&lt;TextBox Header=&quot;Username&quot; Text=&quot;{x:Bind Username, Mode=TwoWay}&quot;/&gt;
</pre>
<p>In my case I was using MVVM to bind properties to my view via a ViewModel.  Because the property Username is on my MainPageViewModel and not my MainPage code behind class, the compiler wasn&#8217;t able to find the property Username.<br />
In this case I received an error message at compile time stating &#8220;Invalid binding path &#8216;Username&#8217; : Property &#8216;Username&#8217; can&#8217;t be found on type &#8216;MainPage&#8217;&#8221;.  This is because the compiled binding gets evaluated at compile-time and it cannot find any property on the partial class MainPage to match.</p>
<p>In module 4 of Jerry Nixon and Andy Wigley&#8217;s MVA Course, <a href="http://www.microsoftvirtualacademy.com/training-courses/a-developers-guide-to-windows-10">A Developers Guide to Windows 10</a>, Andy mentioned a technique to automatically bind a strongly-typed property called ViewModel on the Page code-behind like this.</p>
<pre class="brush: csharp; title: ; notranslate">
public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
        DataContextChanged += (s, e) =&gt;
        {
            ViewModel = DataContext as MainPageViewModel;
        };
    }

    public MainPageViewModel ViewModel { get; set; }
}
</pre>
<p>Now every time the DataContext changes, the ViewModel property gets updated.  You also have to change the Binding to point to the new strongly typed ViewModel property (note the new &#8220;ViewModel.&#8221; in the binding expression).</p>
<pre class="brush: xml; title: ; notranslate">
Text=&quot;{x:Bind ViewModel.Username}&quot;
</pre>
<p>This fixed my problem, but I wanted a solution that I could apply to a base class and leverage across all pages.  In order to maintain the strongly typed nature of the base class I had specify the ViewModel type somewhere in the code behind.  I couldn&#8217;t see any way around that.  At the same time, I wanted to minimize the occurences where this type had to be specified.  After a couple <a href="https://github.com/bendewey/ViewModelCompiledBinding/blob/UsingLamdaExpressions/ViewModelCompiledBinding/ViewModelCompiledBinding/BasePage.cs">variation</a> using Lambdas and Expressions, which ultimately led to reflection of some type.  I opted for full reflection approach based on convention.  The convention I settled on required a property called ViewModel on the concrete page.  Then on the BasePage I just look for this type and set it whenever the DataContext changes.</p>
<pre class="brush: csharp; title: ; notranslate">
public sealed partial class MainPage : BasePage
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    public MainPageViewModel ViewModel { get; set; }
}
</pre>
<p>In order to achieve this, the BasePage logic needs to be a bit more complex, as it&#8217;s dealing with Reflection.</p>
<pre class="brush: csharp; title: ; notranslate">
public class BasePage : Page
{
    private const string ViewModelPropertyName = &quot;ViewModel&quot;;

    public BasePage()
    {
        DataContextChanged += (s, e) =&gt;
        {
            SyncVmWithDataContext();
        };
    }

    public void SyncVmWithDataContext()
    {
        var vmProperty = this.GetType().GetProperty(ViewModelPropertyName);
        if (vmProperty != null)
        {
            vmProperty.SetMethod.Invoke(this, new[] { DataContext });
        }
    }
}
</pre>
<p>Another alternative is to make ViewModelPropertyName a public property that can be set in the XAML and use that property name to override the convention.</p>
<p>I hope you like this approach.  All the code can be found on my github page at <a href="http://github.com/bendewey/ViewModelCompiledBinding">http://github.com/bendewey/ViewModelCompiledBinding</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/533/using-compiled-binding-xbind-with-a-viewmodel/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing JavaScript Apps at SparkConf</title>
		<link>http://www.bendewey.com/index.php/528/unit-testing-javascript-apps-at-sparkconf</link>
		<comments>http://www.bendewey.com/index.php/528/unit-testing-javascript-apps-at-sparkconf#comments</comments>
		<pubDate>Sat, 06 Jun 2015 15:13:39 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Presentations]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=528</guid>
		<description><![CDATA[It was a joy to visit charlotte and speak at SparkConf. As promised, here are the slides for the presentation. All the code is available.]]></description>
				<content:encoded><![CDATA[<p>It was a joy to visit charlotte and speak at <a href="http://sparkconf.org/">SparkConf</a>.  As promised, here are the slides for the presentation.  All the code is available online at <a href="http://github.com/bendewey/jstesting-demo">http://github.com/bendewey/jstesting-demo</a>.</p>
<p><iframe src="https://onedrive.live.com/embed?cid=473151CB8AFE66BA&#038;resid=473151cb8afe66ba%21204982&#038;authkey=ALZIOKbNzT3wEhw&#038;em=2" width="402" height="327" frameborder="0" scrolling="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/528/unit-testing-javascript-apps-at-sparkconf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alternating Row Color in Windows Store ListView</title>
		<link>http://www.bendewey.com/index.php/523/alternating-row-color-in-windows-store-listview</link>
		<comments>http://www.bendewey.com/index.php/523/alternating-row-color-in-windows-store-listview#comments</comments>
		<pubDate>Wed, 22 Oct 2014 15:08:50 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Controls]]></category>
		<category><![CDATA[Windows8]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=523</guid>
		<description><![CDATA[I&#8217;ve always been drawn to XAML for its powerful ability to customize design to any extent. On a recent Windows Store project I found it.]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve always been drawn to XAML for its powerful ability to customize design to any extent.  On a recent Windows Store project I found it difficult to create the alternating row color, or zebra striping, effect on a ListView control, something that&#8217;s proven to be easy with CSS3.  I decided to write this post in hopes that others would find this technique useful.</p>
<p>I search online and found a technique that included adding an index property to the model in question and then adding a converter to the DataTemplate.  This wasn&#8217;t ideal because it only changed the contents of the list item, so depending on padding and content alignment you&#8217;d see gaps around the row background.  I also didn&#8217;t like the code smell of modifying my data model objects with UI code.</p>
<p>What I wanted was to override the ListViewItem control&#8217;s Background property.  You could use the ListView.ItemContainerStyle property and set the background using a style, but unfortunately the style&#8217;s context wouldn&#8217;t have any way of knowing the index of the item relative to the full source collection.</p>
<p>The option I used was to override a ListView control and create an AlternatingRowListView.  Then by overriding the PrepareContainerForItemOverride, which is responsible for the setting up the ListViewItem control after it&#8217;s be created, you could modify the background color.</p>
<pre class="brush: csharp; title: ; notranslate">
public class AlternatingRowListView : ListView
{

    protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
    {
        base.PrepareContainerForItemOverride(element, item);
        var listViewItem = element as ListViewItem;
        if (listViewItem != null)
        {
            var index = IndexFromContainer(element);

            if ((index + 1) % 2 == 1)
            {
                listViewItem.Background = new SolidColorBrush(Colors.White);
            }
            else
            {
                listViewItem.Background = new SolidColorBrush(Colors.Gray);
            }
        }
        
    }
}
</pre>
<p>This code uses a method on the ListView base class called ItemFromContainer(), which simply gives you the index of the item relative to the ListView&#8217;s source collection.  With that index you can set the ListViewItem&#8217;s Background color based on a modulus of 2.  Although, using hard coded colors for the background doesn&#8217;t make it very usable across other designs.  This is where dependency properties come into play.  They allow the control to expose properties to XAML, where you can set them to any Brush or Resource you&#8217;d like.  To do this you have to specify them as they are below and update your overridden method from before with these new properties.</p>
<pre class="brush: csharp; title: ; notranslate">
public class AlternatingRowListView : ListView
{
	public static readonly DependencyProperty OddRowBackgroundProperty =
		DependencyProperty.Register(&quot;OddRowBackground&quot;, typeof(Brush), typeof(AlternatingRowListView), null);
	public Brush OddRowBackground
	{
		get { return (Brush)GetValue(OddRowBackgroundProperty); }
		set { SetValue(OddRowBackgroundProperty, (Brush)value); }
	}
	
	public static readonly DependencyProperty EvenRowBackgroundProperty =
		DependencyProperty.Register(&quot;EvenRowBackground&quot;, typeof(Brush), typeof(AlternatingRowListView), null);
	public Brush EvenRowBackground
	{
		get { return (Brush)GetValue(EvenRowBackgroundProperty); }
		set { SetValue(EvenRowBackgroundProperty, (Brush)value); }
	}

    protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
    {
        base.PrepareContainerForItemOverride(element, item);
        var listViewItem = element as ListViewItem;
        if (listViewItem != null)
        {
            var index = IndexFromContainer(element);

            if ((index + 1) % 2 == 1)
            {
                listViewItem.Background = OddRowBackground;
            }
            else
            {
                listViewItem.Background = EvenRowBackground;
            }
        }
        
    }
}
</pre>
<p>After this, you can put it all together by using your new control in place of a ListView.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;Page
    x:Name=&quot;pageRoot&quot;
    x:Class=&quot;ZebraStripedListView.ItemsPage&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:controls=&quot;using:ZebraStripedListView.Controls&quot;&gt;

	&lt;controls:AlternatingRowListView 
			ItemsSource=&quot;{Binding Source={StaticResource itemsViewSource}}&quot;
			OddRowBackground=&quot;{ThemeResource GridOddRowBackgroundBrush}&quot; EvenRowBackground=&quot;{ThemeResource GridEvenRowBackgroundBrush}&quot;&gt;
		&lt;controls:AlternatingRowListView.ItemTemplate&gt;
			&lt;DataTemplate&gt;
				&lt;Grid&gt;
					&lt;Grid.ColumnDefinitions&gt;
						&lt;ColumnDefinition Width=&quot;300&quot; /&gt;
						&lt;ColumnDefinition Width=&quot;*&quot; /&gt;
					&lt;/Grid.ColumnDefinitions&gt;
					&lt;TextBlock Text=&quot;{Binding Title}&quot; Grid.Column=&quot;0&quot; /&gt;
					&lt;TextBlock Text=&quot;{Binding Subtitle}&quot; Grid.Column=&quot;1&quot; /&gt;
				&lt;/Grid&gt;
			&lt;/DataTemplate&gt;
		&lt;/controls:AlternatingRowListView.ItemTemplate&gt;
	&lt;/controls:AlternatingRowListView&gt;
&lt;/Page&gt;
</pre>
<p>This is what the final result looks like for my sample code.</p>
<a href="http://www.bendewey.com/wp-content/uploads/2014/10/screenshot_10222014_104159.png"><img src="http://www.bendewey.com/wp-content/uploads/2014/10/screenshot_10222014_104159-1024x575.png" alt="Zerbra Striped ListView" width="700" height="393" class="aligncenter size-large wp-image-524" /></a>
<p>I&#8217;ve uploaded the full code to my GitHub account at <a href="http://github.com/bendewey/ZebraStripedListView">http://github.com/bendewey/ZebraStripedListView</a>.  I hope this is useful to other who encounter a similar scenario.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/523/alternating-row-color-in-windows-store-listview/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hallway Converstations Podcast Posted</title>
		<link>http://www.bendewey.com/index.php/513/hallway-converstations-podcast-posted</link>
		<comments>http://www.bendewey.com/index.php/513/hallway-converstations-podcast-posted#comments</comments>
		<pubDate>Tue, 09 Sep 2014 21:07:19 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=513</guid>
		<description><![CDATA[At VSLive in Redmond Washington back in August, Phil Japiske and myself had a great conversation about Windows 8 in the Enterprise. Please feel free.]]></description>
				<content:encoded><![CDATA[<p>At VSLive in Redmond Washington back in August, Phil Japiske and myself had a great conversation about Windows 8 in the Enterprise.   Please feel free to check it out online at <a href="http://hallwayconversations.com/podcast/episode-025-windows8-in-the-enterprise-with-ben-dewey/" title="http://hallwayconversations.com/podcast/episode-025-windows8-in-the-enterprise-with-ben-dewey/">http://hallwayconversations.com/podcast/episode-025-windows8-in-the-enterprise-with-ben-dewey/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/513/hallway-converstations-podcast-posted/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XAML AntiPatterns</title>
		<link>http://www.bendewey.com/index.php/518/xaml-antipatterns</link>
		<comments>http://www.bendewey.com/index.php/518/xaml-antipatterns#comments</comments>
		<pubDate>Tue, 06 May 2014 16:42:08 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=518</guid>
		<description><![CDATA[Another great day at VSLive in Chicago. Today was a really fun talk for me laying out the Seven Deadly Sins of XAML Development. As.]]></description>
				<content:encoded><![CDATA[<p>Another great day at VSLive in Chicago. Today was a really fun talk for me laying out the Seven Deadly Sins of XAML Development.</p>
<p>As with all my demos here at VSLive the all the code is available on GitHub at <a href="https://github.com/bendewey/XamlAntiPatterns">https://github.com/bendewey/XamlAntiPatterns</a>, you can also see all my slides here.</p>
<p><iframe src="https://onedrive.live.com/embed?cid=473151CB8AFE66BA&#038;resid=473151CB8AFE66BA%2114527&#038;authkey=ABGP7OkqB70gNHQ&#038;em=2" width="402" height="327" frameborder="0" scrolling="no"></iframe></p>
<p>Thanks again to anyone who came out. I’d love to hear from you if you have any comments about my session or if you are writing apps. Feel free to add a comment here or reach out to me directly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/518/xaml-antipatterns/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build 2014</title>
		<link>http://www.bendewey.com/index.php/508/build-2014</link>
		<comments>http://www.bendewey.com/index.php/508/build-2014#comments</comments>
		<pubDate>Wed, 09 Apr 2014 02:39:55 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Windows8]]></category>
		<category><![CDATA[WinRT]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=508</guid>
		<description><![CDATA[//build was a great event this year. Given that I&#8217;m the mobile guy I&#8217;m particularly excited that they started the day 1 keynote with Windows.]]></description>
				<content:encoded><![CDATA[<p>//build was a great event this year.  Given that I&#8217;m the mobile guy I&#8217;m particularly excited that they started the <a href="http://channel9.msdn.com/Events/Build/2014/KEY01">day 1 keynote</a> with Windows Phone and Windows 8 announcements.</p>
<h3>Windows Phone 8.1</h3>
<p>Microsoft announced their latest version of Windows Phone, version 8.1, this new version is due out this summer and is compatible with all existing Windows Phone 8.0 devices.  In addition manufacturers, such as Nokia, are coming out with new devices tailored to Windows Phone 8.1.</p>
<p><span id="more-508"></span></p>
<p>Regarding Windows Phone 8.1 the new features include Cortana, a new Notification Center, Enterprise VPN and Workplace features, among many new apps and app updates.  Cortana looks really cool, she&#8217;s far more than &#8216;Siri for the Windows Phone&#8217; as she&#8217;s been called.  I like how she mimics a personal assistant and offers something unique in this world of privacy concerns, where she opens her &#8216;notebook&#8217; and provides transparency about what information she&#8217;s tracking about you, such as likes, favorite places, and favorite people, which she calls your inner circle.  You can also modify any of this information if it&#8217;s incorrect.</p>
<p>The Notification center is huge, it allows apps of your choice to provide a higher level of feedback to the user regarding content.  I&#8217;m also excited about the Workplace features because it makes Windows Phone an enterprise ready device, not that it wasn&#8217;t already, but the new features, such as VPN, cover many more use cases that come up in larger organizations.  Windows Phone has also been updated with all the power of Internet Explorer (IE) 11, including in-private browsing on the phone.</p>
<p>While Windows Phone 8.0 runs on the Windows Runtime (WinRT), there were many APIs, suchs as the camera APIs which were different between Windows and Windows Phone.  Windows Phone 8.1 includes developer changes to make the APIs consistent and created a new style of WinRT apps for Windows Phone called Universal Apps.</p>
<h3>Windows 8.1 Update</h3>
<p>Windows 8.1 also received an update, which is already available on MSDN.  This update includes visual updates, such as a Windows Store apps surfacing on the task bar, better mouse and keyboard support within Windows Store apps, and the addition of a power and search button on the start screen.</p>
<p>There is also new pricing around enterprise side loading of apps which makes it more economical to deploy internal Windows 8 apps.  The final feature they announces was a feature called Enterprise mode within IE 11, which enables legacy functionality so those internal sites can still be compatible.</p>
<p>I&#8217;ve always loved the Windows platform and these updates make it that much more compelling.  I really encourage people to take a non-biased look at Windows 8 if they haven&#8217;t done so already.  They also leaked some secrets about unreleased features like a desktop Start Menu, yes menu, not Start Screen, and Windows Store apps running on the desktop in resizable windows.  It&#8217;s nice to see Microsoft showing their hand to the community and being transparent.</p>
<h3>Universal Apps</h3>
<p>It&#8217;s been rumored that Microsoft was converging Windows Phone and Windows Store apps.  At //build they announce a new app development template that makes this much easier.  These new templates work for both .NET and JavaScript for new apps and, as they showed in the keynote, existing apps.</p>
<p>With the convergence of the Windows Phone APIs and Windows Runtime APIs Universal apps for Windows Phone and Store can share basically all of your app code and view code.  But, it doesn&#8217;t stop there.  Microsoft is using this Universal app template with the help of Xamarin to create apps with shared .NET code for iOS and Andriod as well.</p>
<p>While day 1 came many highly anticipated announcements about Mobile and Windows, I was expecting most of them because I follow that space so closely.  The <a href="http://channel9.msdn.com/Events/Build/2014/KEY02">day 2 keynote</a> offered new announcements that I wasn&#8217;t expecting.</p>
<h3>Azure</h3>
<p>There are so many updates around Azure that it&#8217;s hard to keep up.  It&#8217;s hard not to be compelled by all the amazing Platform as a Service (PaaS) tools that are available for Azure.  The big announcement for Azure was a preview version of a <a href="http://portal.azure.com">brand new portal</a>, which surfaces pricing and monitoring right up front.  Additionally, we have new .NET support for Mobile Services, a new traffic manager, and Web Jobs for Azure websites, some of which have been in preview mode and announced earlier.  Brady Gaster and Joe Levy also <a href="http://www.bradygaster.com/post/announcing-the-general-availability-of-the-microsoft-azure-management-libraries-for-net">announced</a>, in their <a href="http://channel9.msdn.com/Events/Build/2014/3-621">session</a>, the deployment of a new Microsoft Azure Management Libraries (MAML) which provide a simplified .NET wrapper over the REST management services for Azure.</p>
<h3>VS 2013 Update 2 RC</h3>
<p>Visual Studio 2013 also received an update, currently in RC.  This update comes with numerous Azure integration improvements to the Server Explorer toolbox, like the ability to create a VM directly from Visual Studio, or create an Azure website directly from the file new website wizard.  Visual Studio 2013 Update 2 also adds all the juicy new Windows Phone 8.1 and Universal App Templates.  Finally a really cool feature, which they also showed in the keynote, is the ability to sync your development environment with the F12 debugger tools of your browser (not just IE).  This feature is powered by BrowserLink.  Scott Hanselman and Scott Hunter have a great <a href="http://channel9.msdn.com/Events/Build/2014/3-602">session</a> describing these new features.</p>
<h3>TypeScript</h3>
<p>While TypeScript wasn&#8217;t really mentioned in either keynote, Anders Hejlsberg announced the version 1.0 release of Typescript in his <a href="http://channel9.msdn.com/Events/Build/2014/3-576">session</a>.  Unfortunately I haven&#8217;t had a chance to use TypeScript much, but I&#8217;m following it closely and looking forward to an opportunity use it.</p>
<h3>Roslyn</h3>
<p>You can&#8217;t mention Anders Hejlsberg without mentioning C#, and the big announcement during the day 2 keynote was the open sourcing of the Rosyln project and the creation of the .NET Foundation.  The C# compiler has been around for quite some time and, as you can imagine, the codebase has some technical debt that has made some new features extremely complex.  Additionally most compilers to date are black boxes.  For these reasons, they decided to re-write the C# compiler as a service with an open API.  This makes the numerous syntax features from the backlog super easy, but also enables third party and even in house creation of <a href="http://channel9.msdn.com/Events/Build/2014/2-577">custom refactorings and behaviors extremely easy to write</a>.</p>
<p>While Roslyn itself it awesome, open sourcing it means that the community can closely watch any changes and discussions and even supply patches.  They are even posting their internal meeting minutes for their design sessions.  Follow it for yourself at <a href="http://roslyn.codeplex.com">http://roslyn.codeplex.com</a></p>
<h3>Project N</h3>
<p>There was another major announcement that wasn&#8217;t announced at the keynotes and that is &#8216;Project N&#8217;.  It is a new preview for a project also known as .NET Native, which increases performance for .NET apps by running them thru a native compiler to pre-JIT and optimize .NET code into pure native code.  Currently this project is in preview and supports C# for Windows Store apps on ARM and x64 only, but they&#8217;ve discussed expanding this in the future.  See the <a href="http://msdn.microsoft.com/en-US/vstudio/dn642499.aspx">FAQ</a> for more information.</p>
<p>This year&#8217;s //build conference was really amazing for me.  In addition to the numerous updates mentioned above, this year was a great networking experience for me personally.  Since I was awarded my MVP this year, I&#8217;ve had a wonderful opportunity to meet so many new people, albeit virtually.  The conference gave me an opportunity to meet these people face-to-face.  It was also nice to see all the Microsoft folks.  Overall a great event lots of content to follow up on, thankfully it&#8217;s all recorded online at <a href="http://channel9.msdn.com/Events/Build/2014">http://channel9.msdn.com/Events/Build/2014</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/508/build-2014/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overriding ThemeResources in Windows 8.1 Apps</title>
		<link>http://www.bendewey.com/index.php/499/overriding-themeresources-in-windows-8-1-apps</link>
		<comments>http://www.bendewey.com/index.php/499/overriding-themeresources-in-windows-8-1-apps#comments</comments>
		<pubDate>Tue, 04 Feb 2014 21:30:13 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=499</guid>
		<description><![CDATA[Windows 8.1 offers a new markup extension called ThemeResource, this allows for dynamic theming of your app at runtime. There is also a new RequestedTheme.]]></description>
				<content:encoded><![CDATA[<p>Windows 8.1 offers a new markup extension called <a href="http://msdn.microsoft.com/en-us/library/windows/apps/dn263118.aspx">ThemeResource</a>, this allows for dynamic theming of your app at runtime.  There is also a new <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.frameworkelement.requestedtheme.aspx">RequestedTheme</a> property on FrameworkElement, which allows for retargeting specific islands of content.  I was working on a sample today and wanted to write a short post to show how to put this all together with the combination of ThemeDictionaries to create a dynamic app.</p>
<h2>ThemeResource</h2>
<p>When you create a new Windows 8.1 app it behooves you use the built-in brushes and styles. This keeps your app consistent with the Windows experience, and also manages cases where users change their underlying system preferences for things like accessibility.  Microsoft provides a <a href="http://msdn.microsoft.com/en-us/library/windows/apps/dn518235.aspx">reference of the XAML theme resources</a>.  To use them in Windows 8 you would just use a StaticResource.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;Border Background=&quot;{StaticResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
&lt;/Border&gt;
</pre>
<p>While StaticResource still works, with Windows 8.1, you can use the new <a href="http://msdn.microsoft.com/en-us/library/windows/apps/dn263118.aspx">ThemeResource</a> markup extension for these references.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;Border Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
&lt;/Border&gt;
</pre>
<p>This allows the resources to be updated dynamically whenever changes to the theme occur, previously this required an application restart.  With the dynamic themes comes a broader reach for theme changing.  To allow this, Microsoft added a RequestedTheme property to the FrameworkElement object.  This allows you to change themes within the context of any element, even nested.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;StackPanel Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
    &lt;TextBlock Text=&quot;Default Theme&quot; Foreground=&quot;{ThemeResource ApplicationForegroundThemeBrush}&quot; /&gt;
    &lt;StackPanel RequestedTheme=&quot;Light&quot; Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
        &lt;TextBlock Text=&quot;Light Theme&quot; Foreground=&quot;{ThemeResource ApplicationForegroundThemeBrush}&quot; /&gt;
        &lt;StackPanel x:Name=&quot;DarkContainer&quot; RequestedTheme=&quot;Dark&quot; Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
            &lt;TextBlock Text=&quot;DarkTheme&quot; Foreground=&quot;{ThemeResource ApplicationForegroundThemeBrush}&quot; /&gt;
        &lt;/StackPanel&gt;
    &lt;/StackPanel&gt;
&lt;/StackPanel&gt;
</pre>
<p>You can also change these values at runtime in code.</p>
<pre class="brush: csharp; title: ; notranslate">
DarkContainer.RequestedTheme = ElementTheme.Dark;
</pre>
<h2>Overrides with ThemeDictionaries</h2>
<p>You can override any of these existing styles by specifying a ResourceDictionary as part of the <a href="http://msdn.microsoft.com/library/windows/apps/br208807">ThemeDictionaries</a>.  Each dictionary must specify a key with one of the following names:</p>
<ul>
<li>Default</li>
<li>Dark</li>
<li>Light</li>
<li>HighContrast</li>
<li>HighContrastBlack</li>
<li>HighContrastWhite</li>
<li>HighContrastCustom</li>
</ul>
<p>The <a href="http://msdn.microsoft.com/library/windows/apps/br208807">ThemeDictionaries documentation</a> provides all the rules, but the HighContrast key is the default for all high contrast options and the Default key is the fallback when a theme name that cannot be located.  Inside the dictionary you can specify any resource override from the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/dn518235.aspx">full list of theme resource keys</a>.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;ResourceDictionary.ThemeDictionaries&gt;
    &lt;ResourceDictionary x:Key=&quot;Default&quot;&gt;
        &lt;SolidColorBrush x:Key=&quot;ApplicationPageBackgroundThemeBrush&quot; Color=&quot;Magenta&quot; /&gt;
    &lt;/ResourceDictionary&gt;
&lt;/ResourceDictionary.ThemeDictionaries&gt;
</pre>
<p>There is one caveat that I notice in my samples, if you specify an ApplicationPageBackgroundThemeBrush, it&#8217;s best to specify the value for all themes, in my case Dark and Light.  Until I made this change the Light theme wasn&#8217;t using the default white background brush I was looking for.  This only seems to be an issue with the page background key, but this code fixed it</p>
<pre class="brush: xml; title: ; notranslate">
&lt;ResourceDictionary.ThemeDictionaries&gt;
    &lt;ResourceDictionary x:Key=&quot;Dark&quot;&gt;
        &lt;SolidColorBrush x:Key=&quot;ApplicationPageBackgroundThemeBrush&quot; Color=&quot;Magenta&quot; /&gt;
    &lt;/ResourceDictionary&gt;
    &lt;ResourceDictionary x:Key=&quot;Light&quot;&gt;
        &lt;SolidColorBrush x:Key=&quot;ApplicationPageBackgroundThemeBrush&quot; Color=&quot;#FFFFFFFF&quot; /&gt;
    &lt;/ResourceDictionary&gt;
&lt;/ResourceDictionary.ThemeDictionaries&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/499/overriding-themeresources-in-windows-8-1-apps/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
