<?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</title>
	<atom:link href="http://www.bendewey.com/index.php/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>Write for us sponsored posts</title>
		<link>http://www.bendewey.com/index.php/567/write-for-us-sponsored-posts</link>
		<comments>http://www.bendewey.com/index.php/567/write-for-us-sponsored-posts#comments</comments>
		<pubDate>Sat, 22 Mar 2025 05:04:02 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[blogs]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=567</guid>
		<description><![CDATA[Write for Us Sponsored Posts! To discuss your ideas for contributing please send an email to netherlandsmark@proton.me Please include in the subject line: guest post.]]></description>
				<content:encoded><![CDATA[<h1>Write for Us Sponsored Posts!</h1>
<p>To discuss your ideas for contributing please send an email to</p>
<p>netherlandsmark@proton.me</p>
<p>Please include in the subject line: guest post for [website]
<p>And send us the article you&#8217;d like to post attached or in the email itself.</p>
<p>&nbsp;</p>
<h2>General Submission Guidelines</h2>
<h2>What topics can I write about?</h2>
<p>We have no limit on which subject you can write about, however some websites retain the last call on accepting a guest post or not, they will all be read before posting by our editors.</p>
<h2>What language can I write in?</h2>
<p>We accept only posts in english, if you need a post in another language please email us first to discuss in which websites we could accept it in.</p>
<p>However you could write in english and include foreign anchor texts for your links, we do accept it that way.</p>
<h2>Can I contribute an edit to an existing post on the site?</h2>
<p>Yes you can, tell us which page and which piece of content you&#8217;d like to add or edit with your respective edit or addition including your link in that piece of content.</p>
<h2>Use Original Content</h2>
<p>The content you submit must be unique and not be posted anywhere else on the internet, we&#8217;ll check with copyscape your entire article.</p>
<h2>Be Free of Errors</h2>
<p>Ensure your submission contains no typos or grammatical errors.</p>
<h2>Length of Content</h2>
<p>Your article must be between 1000 and 3000 words, please stick to this guidelines, any smaller or bigger article will be rejected.</p>
<h2>Time it takes to publish</h2>
<p>After approval the article takes 2-4 days to be published in your desired website, you&#8217;ll be notified via email about the published status of your article.</p>
<h2>Links</h2>
<p>You can insert up to 3 outbound links in the body of your article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/567/write-for-us-sponsored-posts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with Windows 8 Going into settings</title>
		<link>http://www.bendewey.com/index.php/564/getting-started-with-windows-8-going-into-settings</link>
		<comments>http://www.bendewey.com/index.php/564/getting-started-with-windows-8-going-into-settings#comments</comments>
		<pubDate>Sat, 22 Mar 2025 05:02:14 +0000</pubDate>
		<dc:creator><![CDATA[bendewey]]></dc:creator>
				<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://www.bendewey.com/?p=564</guid>
		<description><![CDATA[https://pravinasar.com/ https://www.cliffarena.com/ https://elviscooper.com/ https://interaktive-panoramen.net/ https://psgpe.com/ https://podiumprod.com/ https://kostadinovlaw.com/ https://art.stellamarisacademy.org/ https://www.margunnsol.no/ https://stellarastrology.in/ https://ms.stellamarisacademy.org/ https://heneerealestate.com/ https://zeedzone.zone/ https://glendonvollmer.com/ https://stephendenbrock.de/ https://bencollin.com/ https://www.pavaj-milgroup.com/ https://orthodoxcontent.com/ https://ukrrimf.org.ua/ https://allianceconsortiumltd.com/ https://boor.by/ https://www.azureeducation.org/ https://maicondasilva.com.br/ https://andreas-heinemann.de/ https://vusingerslegacy.org/.]]></description>
				<content:encoded><![CDATA[<p><a href="https://pravinasar.com/">https://pravinasar.com/</a> <a href="https://www.cliffarena.com/">https://www.cliffarena.com/</a> <a href="https://elviscooper.com/">https://elviscooper.com/</a> <a href="https://interaktive-panoramen.net/">https://interaktive-panoramen.net/</a> <a href="https://psgpe.com/">https://psgpe.com/</a> <a href="https://podiumprod.com/">https://podiumprod.com/</a> <a href="https://kostadinovlaw.com/">https://kostadinovlaw.com/</a> <a href="https://art.stellamarisacademy.org/">https://art.stellamarisacademy.org/</a> <a href="https://www.margunnsol.no/">https://www.margunnsol.no/</a> <a href="https://stellarastrology.in/">https://stellarastrology.in/</a> <a href="https://ms.stellamarisacademy.org/">https://ms.stellamarisacademy.org/</a> <a href="https://heneerealestate.com/">https://heneerealestate.com/</a> <a href="https://zeedzone.zone/">https://zeedzone.zone/</a> <a href="https://glendonvollmer.com/">https://glendonvollmer.com/</a> <a href="https://stephendenbrock.de/">https://stephendenbrock.de/</a> <a href="https://bencollin.com/">https://bencollin.com/</a> <a href="https://www.pavaj-milgroup.com/">https://www.pavaj-milgroup.com/</a> <a href="https://orthodoxcontent.com/">https://orthodoxcontent.com/</a> <a href="https://ukrrimf.org.ua/">https://ukrrimf.org.ua/</a> <a href="https://allianceconsortiumltd.com/">https://allianceconsortiumltd.com/</a> <a href="https://boor.by/">https://boor.by/</a> <a href="https://www.azureeducation.org/">https://www.azureeducation.org/</a> <a href="https://maicondasilva.com.br/">https://maicondasilva.com.br/</a> <a href="https://andreas-heinemann.de/">https://andreas-heinemann.de/</a> <a href="https://vusingerslegacy.org/">https://vusingerslegacy.org/</a> <a href="https://virag10.ru/">https://virag10.ru/</a> <a href="https://anekaflowmeter.com/">https://anekaflowmeter.com/</a> <a href="https://gornaeva.com/">https://gornaeva.com/</a> <a href="https://myflecki.com/">https://myflecki.com/</a> <a href="https://prosdds.com/">https://prosdds.com/</a> <a href="https://www.aboundplausibleeloquent.com/">https://www.aboundplausibleeloquent.com/</a> <a href="https://ivantoar.pro.mk/">https://ivantoar.pro.mk/</a> <a href="https://lucarray.com/">https://lucarray.com/</a> <a href="https://portraitdiaries.com/">https://portraitdiaries.com/</a> <a href="https://ivokotas.cz/">https://ivokotas.cz/</a> <a href="https://smart-world.cz/">https://smart-world.cz/</a> <a href="https://www.elearning.org.hk/">https://www.elearning.org.hk/</a> <a href="https://swimmingwithdolphin.com/">https://swimmingwithdolphin.com/</a> <a href="https://karlmalonetrainingcenter.com/">https://karlmalonetrainingcenter.com/</a> <a href="https://onlinevetcare.co.uk/">https://onlinevetcare.co.uk/</a> <a href="https://luzbet.com/">https://luzbet.com/</a> <a href="https://makerpedagogy.org/">https://makerpedagogy.org/</a> <a href="https://lnwtf.com/">https://lnwtf.com/</a> <a href="https://indiancreekyouthcamp.org/">https://indiancreekyouthcamp.org/</a> <a href="https://kaki-design.fr/">https://kaki-design.fr/</a> <a href="https://designpraxisindia.com/">https://designpraxisindia.com/</a> <a href="https://nottheusual.nu/">https://nottheusual.nu/</a> <a href="https://bukorshtepi.com/">https://bukorshtepi.com/</a> <a href="https://relaxedbeing.se/">https://relaxedbeing.se/</a> <a href="https://mbei-online.org/">https://mbei-online.org/</a> <a href="https://www.matthewbooth.photography/">https://www.matthewbooth.photography/</a> <a href="https://wellnestmx.com/">https://wellnestmx.com/</a> <a href="https://www.tvm-engineering.com/">https://www.tvm-engineering.com/</a> <a href="https://www.crossfitcoorparoo.com.au/">https://www.crossfitcoorparoo.com.au/</a> <a href="https://etienneignat.info/">https://etienneignat.info/</a> <a href="https://cesarlomonaco.it/">https://cesarlomonaco.it/</a> <a href="https://bathforte.com/">https://bathforte.com/</a> <a href="https://andreymihaylenko.ru/">https://andreymihaylenko.ru/</a> <a href="https://signmediasmart.com/">https://signmediasmart.com/</a> <a href="https://www.camiisitma.com/">https://www.camiisitma.com/</a> <a href="https://www.ledespencer.com/">https://www.ledespencer.com/</a> <a href="https://bioecopest.com/">https://bioecopest.com/</a> <a href="https://styledtoat.com/">https://styledtoat.com/</a> <a href="https://stayinbelgrade.com/">https://stayinbelgrade.com/</a> <a href="https://kichashki.com/">https://kichashki.com/</a> <a href="https://sutangomunchen.com/">https://sutangomunchen.com/</a> <a href="https://www.mein-hobby.at/">https://www.mein-hobby.at/</a> <a href="https://andez.cl/">https://andez.cl/</a> <a href="https://themisscupcake.com/">https://themisscupcake.com/</a> <a href="https://continoom-music.com/">https://continoom-music.com/</a> <a href="https://giocareplayschool.com/">https://giocareplayschool.com/</a> <a href="https://www.insightphysiotherapy.com.au/">https://www.insightphysiotherapy.com.au/</a> <a href="https://delightfulemails.com/">https://delightfulemails.com/</a> <a href="https://purposefill.co.nz/">https://purposefill.co.nz/</a> <a href="https://cybanjou.org/">https://cybanjou.org/</a> <a href="https://enprimerafila.biz/">https://enprimerafila.biz/</a> <a href="https://bale-photographie.de/">https://bale-photographie.de/</a> <a href="https://www.govaluta.com/">https://www.govaluta.com/</a> <a href="https://bbsecommerce.com/">https://bbsecommerce.com/</a> <a href="https://livearts.eu/">https://livearts.eu/</a> <a href="https://vsemteam.ru/">https://vsemteam.ru/</a> <a href="https://geoimpuls.org/">https://geoimpuls.org/</a> <a href="https://prodata.co.id/">https://prodata.co.id/</a> <a href="https://www.autodealer.lt/">https://www.autodealer.lt/</a> <a href="https://nutani.com/">https://nutani.com/</a> <a href="https://aliceattie.com/">https://aliceattie.com/</a> <a href="https://fyby71.com/">https://fyby71.com/</a> <a href="https://www.eurowine.no/">https://www.eurowine.no/</a> <a href="https://skitowngourmet.com/">https://skitowngourmet.com/</a> <a href="https://c12phongdong.vinhthuan.edu.vn/">https://c12phongdong.vinhthuan.edu.vn/</a> <a href="https://ocu.vn/">https://ocu.vn/</a> <a href="https://formasag.com/">https://formasag.com/</a> <a href="https://arlandastadduathlon.se/">https://arlandastadduathlon.se/</a> <a href="https://play4dance.com/">https://play4dance.com/</a> <a href="https://internationaldrying.com/">https://internationaldrying.com/</a> <a href="https://magicbusinessforms.com/">https://magicbusinessforms.com/</a> <a href="https://www.ziaromat.sk/">https://www.ziaromat.sk/</a> <a href="https://www.praktijkmariekehuisman.nl/">https://www.praktijkmariekehuisman.nl/</a> <a href="https://sylvester.nl/">https://sylvester.nl/</a> <a href="https://www.vittayapun.com/">https://www.vittayapun.com/</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bendewey.com/index.php/564/getting-started-with-windows-8-going-into-settings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
	</channel>
</rss>
