<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - Swapping application bars dynamically on Windows Phone 8</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - Swapping application bars dynamically on Windows Phone 8</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Sun, 19 May 2013 02:33:23 GMT</pubDate>
	<lastBuildDate>Sun, 19 May 2013 02:33:23 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>3</c9:totalResults>
	<c9:pageCount>-3</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - Swapping application bars dynamically on Windows Phone 8</title>
		<description><![CDATA[<p>Its 5:20 AM and I woke up at 4:45 with an approach that would make my life easier. Had to code it. It worked beautifully, so I had to blog it to get opinions and help others.</p><p>&nbsp;</p><p>The app I am working on have 2 states, and on each state the user will see a different set of buttons and menu items on the app bar.</p><p>I didnt want to write the app bar completely in C#, for I always choose XAML over C# when possible. Otherwise we would just write it all in C#!&nbsp;</p><p>I started by creating the buttons as app resources in APP.XAML. Note that some buttons overlap both app bars, so this approach avoids having 2 buttons that do the same thing.</p><p><pre class="brush: text">
&lt;Application.Resources&gt;
&lt;shell:ApplicationBarIconButton x:Key=&quot;ChooseButton&quot; IconUri=&quot;/Images/ChooseButton.png&quot; Text=&quot;choose&quot;&gt;
...
&lt;/shell:ApplicationBarIconButton&gt;
</pre></p><p>&nbsp;I then added both app bars to APP.XAML resource as well, referencing the buttons as StaticResources</p><p><pre class="brush: text">
&lt;shell:ApplicationBar x:Key=&quot;AppBarState1&quot; IsVisible=&quot;True&quot; Opacity=&quot;0.5&quot;&gt;
&lt;shell:ApplicationBar.Buttons&gt;
&lt;StaticResource ResourceKey=&quot;ChooseButton&quot; /&gt;
...
&lt;/shell:ApplicationBar.Buttons&gt;
&lt;/shell:ApplicationBar&gt;
 
</pre></p><p>Now on the page code&nbsp;behind&nbsp;comes the inevitable C#. I feel this is perfectly OK as it has to do with procedure and&nbsp;intelligence&nbsp;rather then declaration.</p><p><pre class="brush: text">

var chooseButton = (ApplicationBarIconButton)App.Current.Resources[&quot;ChooseButton&quot;];
chooseButton.Click &#43;= ChooseButtonClick;
...
</pre></p><p>After setting up the button handlers we will decide which app bar to show and&nbsp;assign&nbsp;it to the page's ApplicationBar property:</p><p><pre class="brush: text">
ApplicationBar = (IApplicationBar)App.Current.Resources[&quot;AppBarState1&quot;]; // choose based on app state
 
</pre></p><p>&nbsp;I hope this helps some folks. If you think of a more elegant or appropriate way of achieving the same , please let us know.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Swapping-application-bars-dynamically-on-Windows-Phone-8/6a9e1c47609d42f4a30aa14800aff468#6a9e1c47609d42f4a30aa14800aff468</link>
		<pubDate>Wed, 16 Jan 2013 10:40:37 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Swapping-application-bars-dynamically-on-Windows-Phone-8/6a9e1c47609d42f4a30aa14800aff468#6a9e1c47609d42f4a30aa14800aff468</guid>
		<dc:creator>Mauricio Feijo</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Mauricio Feijo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Swapping application bars dynamically on Windows Phone 8</title>
		<description><![CDATA[<p>@<a href="/Forums/TechOff/Swapping-application-bars-dynamically-on-Windows-Phone-8#c6a9e1c47609d42f4a30aa14800aff468">Mauricio Feijo</a>: Nice solution -- will this work in WP7 or just WP8?</p><p>My WP7 app used C# to change the app bar buttons (see example on <a href="http://stackoverflow.com/questions/4234202/hide-application-bar-icon-programmatically-in-a-wp7-silverlight-application/4234430#4234430">StackOverflow</a>), but your solution is much more elegant. &nbsp;Well done!</p><p>Herbie</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Swapping-application-bars-dynamically-on-Windows-Phone-8/a31c070da45741f4a38ba14800b7544a#a31c070da45741f4a38ba14800b7544a</link>
		<pubDate>Wed, 16 Jan 2013 11:07:28 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Swapping-application-bars-dynamically-on-Windows-Phone-8/a31c070da45741f4a38ba14800b7544a#a31c070da45741f4a38ba14800b7544a</guid>
		<dc:creator>Herbie Smith</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Dr Herbie/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Swapping application bars dynamically on Windows Phone 8</title>
		<description><![CDATA[<p>Thank Herbie!</p><p>I am not really sure if it will work on &nbsp;WP7. Hopefully it will. If you try let us know the results.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/Swapping-application-bars-dynamically-on-Windows-Phone-8/f92428fd66e64567af36a148010c15ef#f92428fd66e64567af36a148010c15ef</link>
		<pubDate>Wed, 16 Jan 2013 16:16:04 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/Swapping-application-bars-dynamically-on-Windows-Phone-8/f92428fd66e64567af36a148010c15ef#f92428fd66e64567af36a148010c15ef</guid>
		<dc:creator>Mauricio Feijo</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Mauricio Feijo/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>