<?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>chillijam.co.uk &#187; WP7</title>
	<atom:link href="http://chillijam.co.uk/category/wp7/feed/" rel="self" type="application/rss+xml" />
	<link>http://chillijam.co.uk</link>
	<description></description>
	<lastBuildDate>Thu, 28 Jan 2021 10:32:11 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>WP7 Navigation Gotcha</title>
		<link>http://chillijam.co.uk/2012/02/16/wp7-navigation-gotcha/</link>
		<comments>http://chillijam.co.uk/2012/02/16/wp7-navigation-gotcha/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 15:28:13 +0000</pubDate>
		<dc:creator><![CDATA[Marc]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C# Snippets]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://chillijam.co.uk/?p=393</guid>
		<description><![CDATA[Navigating to a page, passing a key defined by a third party can present problems, but taking a little care over the way you pass the parameters can save a world of pain later.]]></description>
				<content:encoded><![CDATA[<p>This afternoon I discovered a bug in one of the apps I am working on.  It happens because the keys we use for navigation are provided in a third-party feed, and one of those keys contains a plus sign (&#8220;+&#8221;).  </p>
<p>This wasn&#8217;t immediately apparent as an issue, and we just navigated using </p>
<pre class="brush: csharp; title: ; notranslate">
NavigationService.Navigate(new Uri(&quot;/Views/TargetView.xaml?key=&quot; + myKeyValue, UriKind.Relative));
</pre>
<p>Unfortunately, this gets UrlDecoded on the receiving side as a sapce, so our key that started out being &#8220;text+text&#8221; was being resolved as &#8220;text text&#8221;.  When looking that value up in our tables the key was obviosuly not found and a NullReferenceException was thrown.</p>
<p>The fix was pretty simple, though.  We just had to UrlEncode the strong before we sent it, as follows.</p>
<pre class="brush: csharp; title: ; notranslate">
NavigationService.Navigate(new Uri(&quot;/Views/TargetView.xaml?key=&quot; + System.Net.HttpUtility.UrlEncode(myKeyValue), UriKind.Relative));
</pre>
<p>and all is good with the world again.</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2012/02/16/wp7-navigation-gotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alter a Pivot controls header template the easy way (WP7)</title>
		<link>http://chillijam.co.uk/2012/01/11/alter-a-pivot-controls-header-template-the-easy-way-wp7/</link>
		<comments>http://chillijam.co.uk/2012/01/11/alter-a-pivot-controls-header-template-the-easy-way-wp7/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 11:01:49 +0000</pubDate>
		<dc:creator><![CDATA[Marc]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C# Snippets]]></category>
		<category><![CDATA[Mango]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://chillijam.co.uk/?p=369</guid>
		<description><![CDATA[If you want to alter the template for a Windows Phone 7 pivot control&#8217;s header, the simplest way is as follows&#8230; Of course, all this example does is specifically set the colour used for the title and headers to black, but you can do (almost) whatever you like in those templates. Want to add an &#8230; <a href="http://chillijam.co.uk/2012/01/11/alter-a-pivot-controls-header-template-the-easy-way-wp7/" class="more-link">Continue reading <span class="screen-reader-text">Alter a Pivot controls header template the easy way (WP7)</span> <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you want to alter the template for a Windows Phone 7 pivot control&#8217;s header, the simplest way is as follows&#8230;</p>
<pre class="brush: csharp; title: ; notranslate">
        &lt;controls:Pivot Title=&quot;Altered Styles&quot;&gt;
            &lt;controls:Pivot.HeaderTemplate&gt;  
                &lt;!-- This changes to look of the items headers --&gt;
                &lt;DataTemplate&gt;
                    &lt;TextBlock Text=&quot;{Binding}&quot; Foreground=&quot;Black&quot;/&gt;
                &lt;/DataTemplate&gt;
            &lt;/controls:Pivot.HeaderTemplate&gt;
            &lt;controls:Pivot.TitleTemplate&gt;
                &lt;!-- This changes to look of the pivot overall title --&gt;
                &lt;DataTemplate&gt;
                    &lt;TextBlock Text=&quot;{Binding}&quot; Foreground=&quot;Black&quot;/&gt;
                &lt;/DataTemplate&gt;
            &lt;/controls:Pivot.TitleTemplate&gt;
            &lt;controls:PivotItem Header=&quot;daily&quot;&gt;
                &lt;Grid/&gt;
            &lt;/controls:PivotItem&gt;
            &lt;controls:PivotItem Header=&quot;hourly&quot;&gt;
                &lt;Grid/&gt;
            &lt;/controls:PivotItem&gt;
        &lt;/controls:Pivot&gt;
</pre>
<p>Of course, all this example does is specifically set the colour used for the title and headers to black, but you can do (almost) whatever you like in those templates.  Want to add an image as a bullet?  Go for it.</p>
<pre class="brush: csharp; title: ; notranslate">
&lt;controls:Pivot.HeaderTemplate&gt;
    &lt;DataTemplate&gt;
        &lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;
            &lt;Image Height=&quot;48&quot; Width=&quot;48&quot; Source=&quot;/MyBulletImage.png&quot; /&gt;
            &lt;TextBlock Text=&quot;{Binding}&quot; Foreground=&quot;Black&quot;/&gt;
        &lt;/StackPanel&gt;
    &lt;/DataTemplate&gt;
&lt;/controls:Pivot.HeaderTemplate&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2012/01/11/alter-a-pivot-controls-header-template-the-easy-way-wp7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alternating ListBox item background colours in WP7</title>
		<link>http://chillijam.co.uk/2012/01/11/alternating-listbox-item-background-colours-in-wp7/</link>
		<comments>http://chillijam.co.uk/2012/01/11/alternating-listbox-item-background-colours-in-wp7/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 10:34:42 +0000</pubDate>
		<dc:creator><![CDATA[Marc]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C# Snippets]]></category>
		<category><![CDATA[Mango]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://chillijam.co.uk/?p=364</guid>
		<description><![CDATA[I had a requirement today to implement alternating row colours in a Windows Phone 7 ListBox. After a bit of frustration with searching and only finding answers tht said &#8220;You can&#8217;t do it&#8221;, or that you need to add a property on the model to bind the background to, I eventually hit upon a nugget &#8230; <a href="http://chillijam.co.uk/2012/01/11/alternating-listbox-item-background-colours-in-wp7/" class="more-link">Continue reading <span class="screen-reader-text">Alternating ListBox item background colours in WP7</span> <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I had a requirement today to implement alternating row colours in a Windows Phone 7 ListBox. After a bit of frustration with searching and only finding answers tht said &#8220;You can&#8217;t do it&#8221;, or that you need to add a property on the model to bind the background to, I eventually hit upon a nugget of common sense on <a href="http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/f9e9ce26-d576-45f8-a79d-762176695385" target="_blank">this page</a>.</p>
<p>Basically you need to create a converter class that will handle the alternation of backgrounds for you. It is ridiculously simple once you see it in action.</p>
<p><strong>Step 1 : Create the converter.</strong></p>
<pre class="brush: csharp; title: ; notranslate">
public class AlternateRowColour : IValueConverter
{
bool isAlternate;
SolidColorBrush even = new SolidColorBrush(Colors.Transparent); // Set these two brushes to your alternating background colours.
SolidColorBrush odd = new SolidColorBrush(Color.FromArgb(255, 241, 241, 241));

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
isAlternate = !isAlternate;
return isAlternate ? even : odd ;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
</pre>
<p>Step 2 : Add the converter to the page</p>
<pre class="brush: csharp; title: ; notranslate">
&lt;UserControl
 	...snip...
 	xmlns:conv=&quot;clr-namespace:MyApplication.Converters&quot; 
 	...snip...
 	&gt;
	&lt;UserControl.Resources&gt;
		&lt;conv:AlternateRowColour x:Key=&quot;RowColour&quot; /&gt;
	&lt;/UserControl.Resources&gt;
	...snip...
&lt;/UserControl&gt;
</pre>
<p>Step 3 : Bind to the ListBox</p>
<pre class="brush: csharp; title: ; notranslate">
&lt;ListBox ItemsSource=&quot;{Binding}&quot;&gt;
  &lt;ListBox.ItemTemplate&gt;
    &lt;DataTemplate&gt;
      &lt;Grid Background=&quot;{Binding Converter={StaticResource RowColour}}&quot;&gt;
        &lt;!-- layout XAML --&gt;
      &lt;/Grid&gt;
    &lt;/DataTemplate&gt;
  &lt;/ListBox.ItemTemplate&gt;
&lt;/ListBox&gt;				
</pre>
<p>And you&#8217;re done.</p>
]]></content:encoded>
			<wfw:commentRss>http://chillijam.co.uk/2012/01/11/alternating-listbox-item-background-colours-in-wp7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
