
<?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>UnderBridgeCityUnderBridgeCity</title>
	<atom:link href="http://www.underbridgecity.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.underbridgecity.net/blog</link>
	<description>Hello World!</description>
	<lastBuildDate>Sun, 24 Feb 2013 05:32:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Why I think the Metro Style is important to understand.</title>
		<link>http://www.underbridgecity.net/blog/2012/06/why-i-think-the-metro-style-is-important-to-understand/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-i-think-the-metro-style-is-important-to-understand</link>
		<comments>http://www.underbridgecity.net/blog/2012/06/why-i-think-the-metro-style-is-important-to-understand/#comments</comments>
		<pubDate>Thu, 28 Jun 2012 03:31:10 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=150</guid>
		<description><![CDATA[So with Windows Phone 8 being announced and Windows 8 also about to come out. They look very similar, and also act similar. The design is the Metro design, and it is different then the other options out there today. First a &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/06/why-i-think-the-metro-style-is-important-to-understand/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>So with Windows Phone 8 being announced and Windows 8 also about to come out. They look very similar, and also act similar. The design is the Metro design, and it is different then the other options out there today.</p>
<p>First a little understand about why the metro design is cool, it is designed to be &#8220;glanceable,&#8221; what this means is they want you to take a look at it and see important information at a glance. When you look at your phone and see see a number next to your email you know you have that many emails. When you check the lock screen of your phone and see a symbol with a number you know you have a message waiting. And to get that nice glanceable design they developed the metro design to make it feel universal. Just image you were in a foreign airport, and not knowing the native language how would you get around? You would look at the symbols and understand what they mean. This is what the metro style was inspired from.</p>
<p>So now why it is important to understand metro design. The whole windows 8 and windows phone experience is built on metro so you should design your apps with that in mind. They make it easy for you to design your app with metro with the blend software that comes with the windows phone SDK. and even give design guides. So when you are building an app for windows phone or windows 8 keep try to make it glanceable, have important information get displayed in the icon. make it smooth and easy to transition.</p>
<p>Check out this blog post by the awesome Jeff Wilcox <a href="http://www.jeff.wilcox.name/2011/03/metro-design-guide-v1/">http://www.jeff.wilcox.name/2011/03/metro-design-guide-v1/</a> it goes over the metro design basics nicely I think.</p>
<p>Remember Metro is the future, learn to design with metro.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/06/why-i-think-the-metro-style-is-important-to-understand/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remember to check your backups</title>
		<link>http://www.underbridgecity.net/blog/2012/05/remember-to-check-your-backups/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remember-to-check-your-backups</link>
		<comments>http://www.underbridgecity.net/blog/2012/05/remember-to-check-your-backups/#comments</comments>
		<pubDate>Mon, 28 May 2012 15:46:19 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=126</guid>
		<description><![CDATA[So my old web host just disappeared, and it left me in a hurry to get my website and blog back online. I found a new host and as I was trying to upload the blog database to my new &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/05/remember-to-check-your-backups/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>So my old web host just disappeared, and it left me in a hurry to get my website and blog back online. I found a new host and as I was trying to upload the blog database to my new host. My old backup files were corrupt.</p>
<p>So just a nice friendly piece of advice. Remember to always back up your site and database, and check them to make sure they are good.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/05/remember-to-check-your-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Code Repository in DropBox</title>
		<link>http://www.underbridgecity.net/blog/2012/04/creating-a-code-repository-in-dropbox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-a-code-repository-in-dropbox</link>
		<comments>http://www.underbridgecity.net/blog/2012/04/creating-a-code-repository-in-dropbox/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 18:07:30 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Development Tips]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[tortoiseHg]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=129</guid>
		<description><![CDATA[So something very important to developers is backing up your code, and also version control. In this post I am going to show how to set up a mercurial repository inside a dropbox. This post requires some knowledge of mercurial &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/04/creating-a-code-repository-in-dropbox/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>So something very important to developers is backing up your code, and also version control. In this post I am going to show how to set up a mercurial repository inside a dropbox. This post requires some knowledge of mercurial and or version control. This will enable a version control system inside a dropbox for backup and easy to access on other computers. I am using TortoiseHG for handling mercurial, you can check it out and download it here <a href="http://tortoisehg.bitbucket.org/">http://tortoisehg.bitbucket.org/</a>. And for dropbox you can get it here <a href="http://db.tt/E3rO0W6E">http://db.tt/E3rO0W6E</a> &lt;&#8211; (that is a referral link, if you use it you get an extra 500MB of storage and so do I.)</p>
<p>So after you both of those installed (if you are having trouble and need help leave me a comment or send me an email and I will do my best to help you) Go to the folder the project you want to add to version control. Right click in the folder and go to TortoiseHg &gt; Create Repositoy</p>
<p><a href="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/CreateRepo.png"><img class="alignnone size-medium wp-image-133" title="CreateRepo" alt="" src="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/CreateRepo-300x218.png" width="300" height="218" /></a></p>
<p><span id="more-129"></span></p>
<p>Then you will need to Init the repository, you should see a popup like this.</p>
<p><a href="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/RepoInit.png"><img class="alignnone size-medium wp-image-137" title="RepoInit" alt="" src="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/RepoInit-300x122.png" width="300" height="122" /></a></p>
<p>Click Create and then you have your repository created. Now you need to commit your files into the repository. But before the commit, you should edit the .hgignore file. What this does is ignore files you don&#8217;t want to or you shouldn&#8217;t commit.</p>
<p><a href="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/IgnoreList.png"><img class="alignnone size-medium wp-image-134" title="IgnoreList" alt="" src="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/IgnoreList-300x206.png" width="300" height="206" /></a></p>
<p>Here is the ignore file I use. I got this from somewhere on the internet and it takes care of a good amount of files. This file tells what files and directors to ignore when committing files.</p>
<p>&nbsp;</p><pre class="crayon-plain-tag">syntax: glob
 *.suo
 *.obj
 *.pdb
 *.user
 *.vspscc
 *.bak
 *.cache
 *.log
 *.lib
 [Bb]in
 [Dd]ebug*/
 obj/
 [Rr]elease*/
 [Tt]est[Rr]esult*
 [Bb]uild[Ll]og.*
 *.[Pp]ublish.xml
 [Bb]uild[Pp]rocess[Tt]emplates/*
 Published/*
 [Tt]humbs.db
 [Uu]pgrade[Ll]og*.[Xx][Mm][Ll]
 _[Uu]pgradeReport_Files*/
 *.ReSharper.user</pre><p>Now copy the project folder and paste it into your dropbox folder. When you installed dropbox it created a folder called dropbox(in you followed the default install) I created a folder in it called Projects and then pasted my project folder(UnderBridgeGraffiti) in it.</p>
<p><a href="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/CopyFolder.png"><img class="alignnone size-medium wp-image-132" title="CopyFolder" alt="" src="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/CopyFolder-300x118.png" width="300" height="118" /></a></p>
<p>You can now open the repository explorer(workbench), right click in the folder (in the dropbox folder) and then click on Hg Workbench.</p>
<p><a href="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/OpenHGExplorer.png"><img title="OpenHGExplorer" alt="" src="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/OpenHGExplorer-300x222.png" width="300" height="222" /></a></p>
<p>Once you open up the workbench you need to commit all your file to the repository.</p>
<p><a href="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/IntiCommit.png"><img class="alignnone size-medium wp-image-135" title="IntiCommit" alt="" src="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/IntiCommit-300x247.png" width="300" height="247" /></a></p>
<p>First (1) click on the check mark at the top of the explorer to check all the files that need to be committed to the repository.  Second (2) click that check box to select all the files you want to commit to the repository. Then fill in the text box with a description(Init Commit) and then click commit (3). It will ask you if you want to add untracked files, select yes since there are no tracked files and you want to track all those files.</p>
<p>Congratulations you just created a repository inside your dropbox folder.</p>
<p>Now you can access your version control on any computer you have dropbox installed on.</p>
<p>If you wanted to create a clone of the repository so you can have the dropbox as the master file go to another computer or folder. Right click inside the folder, TortoiseHg -&gt; Clone</p>
<p><a href="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/CloneRepository.png"><img title="CloneRepository" alt="" src="http://www.underbridgecity.net/blog/wp-content/uploads/2012/04/CloneRepository-300x181.png" width="300" height="181" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/04/creating-a-code-repository-in-dropbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update to my Trial Mode post</title>
		<link>http://www.underbridgecity.net/blog/2012/04/update-to-my-trial-mode-post/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=update-to-my-trial-mode-post</link>
		<comments>http://www.underbridgecity.net/blog/2012/04/update-to-my-trial-mode-post/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 03:58:21 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Trial mode]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=109</guid>
		<description><![CDATA[So I just release an app to the marketplace recently. (Check it out here http://underbridgecity.net/underbridgegraffiti/) And I implemented the trial code I mentioned in my Trial Mode post (http://www.underbridgecity.net/blog/2012/03/trial-mode-in-windows-phone-7/) so that when you bought the app and then pressed the &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/04/update-to-my-trial-mode-post/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>So I just release an app to the marketplace recently. (Check it out here http://underbridgecity.net/underbridgegraffiti/) And I implemented the trial code I mentioned in my Trial Mode post (http://www.underbridgecity.net/blog/2012/03/trial-mode-in-windows-phone-7/) so that when you bought the app and then pressed the back button you should be in full mode and not trial.<br />
I tested it out, and it worked! I went into the app, clicked a button to go to the marketplace to buy it, bought it, went back&#8230; and I had to press back an extra time but then went back into the settings page and the app no longer was in trial mode. </p>
<p>So if you implement trial mode, I suggest adding in the check if trial or not in the application activated section to always check when you navigate to the app no matter how you get there.</p>
<p>I will upload a video soon of me buying it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/04/update-to-my-trial-mode-post/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multitouch in WP7</title>
		<link>http://www.underbridgecity.net/blog/2012/04/multitouch-in-wp7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=multitouch-in-wp7</link>
		<comments>http://www.underbridgecity.net/blog/2012/04/multitouch-in-wp7/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 04:01:49 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[application events]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Multitouch]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=111</guid>
		<description><![CDATA[I just published an app. (You can check it out here http://underbridgecity.net/underbridgegraffiti/.) Has the ability to allow more then one finger to interact with the screen at one time. Here is how I was able to set it up on a &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/04/multitouch-in-wp7/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>I just published an app. (You can check it out here <a href="http://underbridgecity.net/underbridgegraffiti/">http://underbridgecity.net/underbridgegraffiti/</a>.) Has the ability to allow more then one finger to interact with the screen at one time. Here is how I was able to set it up on a canvas which is set up in the xaml.</p>
<p>So to get multitouch set up I used a TouchFrameEventhandler. You will have to add</p><pre class="crayon-plain-tag">System.Windows.Input.Touch</pre><p>as a reference and a using statment.</p>
<p>I created a class called DrawingPoints and then created a list collection of them.</p><pre class="crayon-plain-tag">class DrawingPoints
 {
 public int id { get; set; }
 public Point currentPoint { get; set; }
 public Point oldPoint { get; set; }
 public bool drawing { get; set; }
 public SolidColorBrush currentColor { get; set; }
 public double drawSize { get; set; }
 }

List&lt;DrawingPoints&gt; drawingPoints = new List&lt;DrawingPoints&gt;();</pre><p><span id="more-111"></span></p>
<p>Now you will need to create the touchevent that will happen when something touches the screen.</p><pre class="crayon-plain-tag">void Touch_FrameReported(object sender, TouchFrameEventArgs e)
 {
 //This holds a collection of touches on the screen. So for each finger that touches the canvas one touch get added.
TouchPointCollection tCollection = e.GetTouchPoints(DrawingCanvas);

if (tCollection != null)
 {
 //iterate through the collection of touches
foreach (var point in tCollection)
 {
 //sets up a drawing point
DrawingPoints drawPoint;

//if the touch action is the finger leaving the screen, remove the drawing point from the list of drawpoints
 if (point.Action == TouchAction.Up)
 {
var oldPoint = drawingPoints.Single(x =&gt; x.id == point.TouchDevice.Id);

if (oldPoint != null)
 {
drawingPoints.Remove(oldPoint);
 }
 }

//if the touch action is down, add the point to the drawingpoint
 if (point.Action == TouchAction.Down)
 {
 //gets a list of colors to set which color is set as a drawing point
var colors = App.GetDrawingColors();

var color = colors.Single(c =&gt; c.ColorID == settings.DrawColor);
var size = settings.DrawSize;

//create a drawpoint and assing it Touchevent details
drawPoint = new DrawingPoints();

drawPoint.id = point.TouchDevice.Id; //sets the drawpoint an ID so it knows which finger is touching the screen
drawPoint.currentPoint = point.Position; //gets the position
drawPoint.oldPoint = drawPoint.currentPoint;

drawPoint.currentColor = color.ColorBrush;
drawPoint.drawSize = size;

drawingPoints.Add(drawPoint);
 }

//if the touch action is move, move the point and draw a path from the old point to the new point
 if (point.Action == TouchAction.Move)
 {
drawPoint = drawingPoints.Single(x =&gt; x.id == point.TouchDevice.Id);

drawPoint.currentPoint = point.Position;

draw(drawPoint); //calls the draw action method

drawPoint.oldPoint = drawPoint.currentPoint;
 }
 }
 }

}</pre><p>What that does is everytime a finger touches the screen in the canvas element(which takes up the whole screen on a page in my app,) a touchpoint gets added to a touch collection.<br />
Then for each touch in the touch collection, the code checks what the action of the touch is, it will either be Up &#8211; finger leaves the screen, Down &#8211; finger touches the screen or Move &#8211; finger is moving on the screen. When the action is Up it removes the draw point and stops drawing. When Down is adds a drawpoint to the drawpoint collection and gets ready for the move action. When it is moving it draws a line from the point the finger was at, to the point the finger is at now.</p>
<p>Now you have to add the event when you go to the page you want multi touch on, and when you leave the page remove the event. To do this I override the navigation events. Now I remove the event when leaving the page becasue the touch events can cause some weird things to happen on other pages in the application.</p><pre class="crayon-plain-tag">protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
base.OnNavigatedTo(e);

Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported); //Adds the event to the page
 }

protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
 {
base.OnNavigatedFrom(e);

Touch.FrameReported -= new TouchFrameEventHandler(Touch_FrameReported); //removes the event from the page
 }</pre><p>So that is how I got multitouch set up in my application. Any questions email me or leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/04/multitouch-in-wp7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My app Under Bridge Graffit was published</title>
		<link>http://www.underbridgecity.net/blog/2012/04/my-app-under-bridge-graffit-was-published/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-app-under-bridge-graffit-was-published</link>
		<comments>http://www.underbridgecity.net/blog/2012/04/my-app-under-bridge-graffit-was-published/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 03:07:15 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Apps]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=107</guid>
		<description><![CDATA[Just a small update. My app Under Bridge graffiti was just published in the marketplace. You can check out the page I made for it here http://underbridgecity.net/underbridgegraffiti/ I will soon blog about how I was able to get multi touch &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/04/my-app-under-bridge-graffit-was-published/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Just a small update. My app Under Bridge graffiti was just published in the marketplace. You can check out the page I made for it here <a href="http://underbridgecity.net/underbridgegraffiti/">http://underbridgecity.net/underbridgegraffiti/</a></p>
<p>I will soon blog about how I was able to get multi touch set up in the app. Also I am going to test out how I set up trial mode to make sure that if a user hits the back button after buying the app, it checks on activate so you don&#8217;t have to restart the app.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/04/my-app-under-bridge-graffit-was-published/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wow I have been busy&#8230;</title>
		<link>http://www.underbridgecity.net/blog/2012/04/wow-i-have-been-busy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wow-i-have-been-busy</link>
		<comments>http://www.underbridgecity.net/blog/2012/04/wow-i-have-been-busy/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 04:37:56 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=84</guid>
		<description><![CDATA[So I have been a bit busy lately. I am sorry I havn&#8217;t updated my blog recently, but don&#8217;t worry becasue I have been busy and that has given me more topics to blog about. I just submitted an app &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/04/wow-i-have-been-busy/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>So I have been a bit busy lately. I am sorry I havn&#8217;t updated my blog recently, but don&#8217;t worry becasue I have been busy and that has given me more topics to blog about.<br />
I just submitted an app to the WP7 marketplace and all I am waiting for is it to get approved (or not and I will have to fix something, but I hope not.)<br />
So I will blog about that app, I will also blog about something I coded into the app that I think is really cool, and I think would be helpful to someone out there.<br />
So stay tuned as a content filled blog will be posted soon.</p>
<p>Thank you,<br />
-Andrew</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/04/wow-i-have-been-busy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Different Templates in one Listbox</title>
		<link>http://www.underbridgecity.net/blog/2012/03/different-templates-in-one-listbox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=different-templates-in-one-listbox</link>
		<comments>http://www.underbridgecity.net/blog/2012/03/different-templates-in-one-listbox/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 02:08:37 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[listbox]]></category>
		<category><![CDATA[multiple templates]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=81</guid>
		<description><![CDATA[In this post I will explain how I selected different templates based on the type of data I wanted to show in the same listbox. Now why might you want 2 different templates in the same list box? Well what &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/03/different-templates-in-one-listbox/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>In this post I will explain how I selected different templates based on the type of data I wanted to show in the same listbox.</p>
<p>Now why might you want 2 different templates in the same list box? Well what if you wanted to display different tasks and appointments for a single day. But you want to see at a quick glance what a task is and what an appointment is. So lets say you have a square for all tasks and a circle for all appointments.</p>
<p>To do this you will use a <a title="ContentControl" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.contentcontrol(v=VS.95).aspx" target="_blank">ContentControl</a> which as the data gets bound to the listbox, we will override the method to check if the item getting bound is a task or appointment. And then set the template depending on what it is.</p>
<p>In my code example the tasks and appointments both inherit from a class called CalendarItem. This is an object orientated programing principle, and if you don&#8217;t understand it let me know and I will create a blog about the basics of it.</p>
<p><span id="more-81"></span></p>
<p>First think I did was to create the templates I would be using for tasks and appointments. I created a seperate file called &#8220;DataTemplates.xaml&#8221; and put it into a folder called &#8220;Resources&#8221;.</p><pre class="crayon-plain-tag">&lt;ResourceDictionary
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
 &lt;DataTemplate x:Key="TaskTemplate"&gt;
 &lt;StackPanel Orientation="Horizontal" Margin="0, 6"&gt;
 &lt;Grid Margin="12, 0, 12, 0"&gt;
 &lt;Rectangle Fill="{Binding categoryColor}" Width="20" Height="20"/&gt;
 &lt;/Grid&gt;
 &lt;StackPanel Orientation="Horizontal"&gt;
 &lt;TextBlock Text="{Binding title}" HorizontalAlignment="Left" TextWrapping="Wrap" FontSize="24" Width="300"/&gt;
 &lt;TextBlock Text="{Binding time}" HorizontalAlignment="Right" FontSize="24" Width="112"/&gt;
 &lt;/StackPanel&gt;
 &lt;/StackPanel&gt;
 &lt;/DataTemplate&gt;

&lt;DataTemplate x:Key="ApptTemplate"&gt;
 &lt;StackPanel Orientation="Horizontal" Margin="0, 6"&gt;
 &lt;Grid Margin="12, 0, 12, 0"&gt;
 &lt;Ellipse Fill="{Binding categoryColor}" Width="20" Height="20"/&gt;
 &lt;/Grid&gt;
 &lt;StackPanel Orientation="Horizontal"&gt;
 &lt;TextBlock Text="{Binding title}" HorizontalAlignment="Left" TextWrapping="Wrap" FontSize="24" Width="300"/&gt;
 &lt;TextBlock Text="{Binding time}" HorizontalAlignment="Right" FontSize="24" Width="300"/&gt;
 &lt;/StackPanel&gt;
 &lt;/StackPanel&gt;
 &lt;/DataTemplate&gt;

&lt;/ResourceDictionary&gt;</pre><p>As you look at this code you will see the template structures look alike, but one uses a rectangle and the other usues an ellipse. Now in the CalendarItem class everything has a category and a categoryColor, a title and a time. So we us all that data to display.</p>
<p>Next thing is you will have to create the override using the ContentControl. Create a class file in your solution, I called mine &#8220;TemplateSelector.cs.&#8221;</p><pre class="crayon-plain-tag">using System.Windows.Controls;
 using System.Windows;
 using System.Windows.Markup;
 using System.Xml.Linq;

namespace DuelTemplateSample.Helpers
 {
 public class DataTemplateHelper
 {
 public static DataTemplate LoadFromDictionary(string dictionary, string template)
 {
 var doc = XDocument.Load(dictionary);
 var dict = (ResourceDictionary)XamlReader.Load(doc.ToString(SaveOptions.None));
 return dict[template] as DataTemplate;
 }
 }

public class templateSelector : ContentControl
 {
 protected override void OnContentChanged(object oldContent, object newContent)
 {
 base.OnContentChanged(oldContent, newContent);

var calItem = (CalendarItem)newContent;

if (calItem.type == "APPT")
 {
 ContentTemplate = DataTemplateHelper.LoadFromDictionary(
 "DuelTemplateSample;component/Resources/DataTemplates.xaml",
 "ApptTemplate");
 }
 else
 {
 ContentTemplate = DataTemplateHelper.LoadFromDictionary(
 "DuelTemplateSample;component/Resources/DataTemplates.xaml",
 "TaskTemplate");
 }
 }
 }
 }</pre><p>As you can see in the ContentControl code we are overriding the OnContentChanged method, which takes in 2 objects. oldContent and newContent. If you don&#8217;t understand what an override is, it is another principle of object orientated programming. We then typecase (that is setting the object as another type), in this case we are saying the the newContent is a CalendarItem. Then we check the the type is, this is a property of calendar item, it will be either &#8216;APPT&#8217; for appointment or &#8216;TASK&#8217; for task. Then depending on what the type is we load the ContentTemplate from the DateTemplate file and the template name. In the code I am calling a method called LoadFromDictionary which is defined in the code above the OnContentChanged. All this does is loads in the xaml file that you created before, and gets the template matching the template name. As you can see I am sending a string that is giving the location of the xaml file, this format is used to tell the location of the file in the application the &#8220;DuelTemplateSample;&#8221; tells what namespace the file is located in, and the &#8220;component/Resources/DataTemplates.xaml&#8221; tells that the file is located in the Resources folder. The component means it is in the &#8216;root&#8217; of the project.</p>
<p>Now is the time to get to set up to work in the ListBox. In your xaml page that will contain the ListBox, add in</p><pre class="crayon-plain-tag">xmlns:templateSelector=&quot;clr-namespace:DuelTemplateSample.Helpers&quot;</pre><p>to the PhoneApplicationPage with all the other namespaces. As you can see &#8220;DuelTemplateSample.Helpers&#8221; is the namespace of where the templateSelector / OnContentChanged is located. Now for the ListBox mine looks like this</p>
<p>[sourcecode language="xml"]</p>
<p>[/sourcecode]</p>
<p>As you see I set the DataTemplate to<br />
[sourcecode language="xml"]<br />
&lt;templateSelector:templateSelector Content=&#8221;{Binding}&#8221;/&gt;<br />
[/sourcecode]<br />
This is what calls the OnContentChange override method and sets the template to the template depending on the type that we coded before.</p>
<p>Now all you need to do is bind a set of data to the ListBox and check out the results. In this case I have a list of CalendarItems a mix of tasks and appointments and load it into the ListBox in the code behind.</p>
<p>I hope this helps and if you are confused, have any questions or comments please comment or email me at andy (at) underbridgecity.net.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/03/different-templates-in-one-listbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overwrite WP7 Style Theme</title>
		<link>http://www.underbridgecity.net/blog/2012/03/overwrite-wp7-style-theme/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=overwrite-wp7-style-theme</link>
		<comments>http://www.underbridgecity.net/blog/2012/03/overwrite-wp7-style-theme/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 02:41:56 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[accent color]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[custom theme]]></category>
		<category><![CDATA[overwrite theme]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=64</guid>
		<description><![CDATA[I was working on a Windows Phone 7 application and the client wanted to always have the light theme and have a special accent color depending on settings inside the app. They wanted to do this for branding reasons so &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/03/overwrite-wp7-style-theme/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>I was working on a Windows Phone 7 application and the client wanted to always have the light theme and have a special accent color depending on settings inside the app. They wanted to do this for branding reasons so I had to find a way to always have this app look like it was in the light theme and override the accent color to the colors they wanted.</p>
<p>I will now go over how I did that. You can use this to always have the light theme for the app like the native mail app, or even create your own custom theme.</p><pre class="crayon-plain-tag">//OverwriteTheme is the function to overwrite the dark or light theme to your own custom theme.
 //You can either create your own theme, or copy a theme from the design folder in the WP7 SDK
 private void OverwriteTheme()
 {
 //A string that contains the location to your custom theme file
 string source = String.Format("/SampleApp;component/Resources/LightTheme.xaml");

//Creates a resourceDictionary file that contains all the data for your custom theme
 var customThemeStyle = new ResourceDictionary { Source = new Uri(source, UriKind.Relative) };

//Creates a resourceDicionary of the current theme data
 ResourceDictionary appResources = App.Current.Resources;

//Cycle through each entry in the custom Theme ResourceDictionary and check if
 //there is a matching key resource. If so overwrite the current theme color brush
 //with the custom color brush.
 foreach (DictionaryEntry entry in customThemeStyle)
 {
 //Gets the SolidBrushColor of the current custom entry
 SolidColorBrush colorBrush = entry.Value as SolidColorBrush;

//Looks to see if there is a current theme entry with matching key
 SolidColorBrush existingBrush = appResources[entry.Key] as SolidColorBrush;

//If both SolidBrushColor variables are not null, overwrite current resource with custom resource
 if (existingBrush != null &amp;&amp; colorBrush != null)
 {
 existingBrush.Color = colorBrush.Color;
 }
 }

//This loads the settings from the application
 Setting settings = new Setting();
 IsolatedStorageGateway settingStorage = new IsolatedStorageGateway(StorageType.Setting);

settings = settingStorage.LoadSettings();

//Checks to see what theme setting is selected, and then overwrite the accent Color with the custom accent color
 if (settings.ThemeSettingID == 0)
 {
 (App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color = Color.FromArgb(255, 255, 129, 24);
 }
 else if (settings.ThemeSettingID == 1)
 {
 (App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color = Color.FromArgb(255, 246, 119, 189);
 }
 }</pre><p>In the code I created a method in the App.xaml.cs file, and this method get called in the constructor for App() before the InitializePhoneApplication() call.</p>
<p>You will also need to set teh background on all the pages to {StaticResource PhoneBackgroundBrush} like</p><pre class="crayon-plain-tag">&lt;Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}"&gt;</pre><p>I tried to document the code so you can understand what is going on line by line so I will give a little explanation here.</p>
<p>The line</p><pre class="crayon-plain-tag">string source = String.Format("/SampleApp;component/Resources/LightTheme.xaml");</pre><p>loads the theme you are going override. Here I copied a default theme resource file (Edit: the theme resource file is ThemeResource.xaml) from the design folder located on my machine at <code>C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Design\LightBlue</code> and called it LightTheme.xaml. If you look in the design folder you will see many folders.</p>
<p>Then the code went though all the entries and compared the ResourceDictionaries, if the custom theme file contains the key name of a main style element, it will overwrite it&#8217;s brushcolor. If you look at a default theme resource file, it contains a bunch of colors with keys and the keys are pretty self explanatory. So if you wanted to create your own custom theme you can start by copying and editing one of those files.</p>
<p>Also in my code you see me checking a setting value and then overriding the accent color depending and the user setting. This isn&#8217;t required unless you want the user to select a special accent colors in the settings or want them to change, if you just want one over ridden accent color just put it into your style resource file.</p>
<p>And questions or comments just let me know and thank you for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/03/overwrite-wp7-style-theme/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Trial Mode in Windows Phone 7</title>
		<link>http://www.underbridgecity.net/blog/2012/03/trial-mode-in-windows-phone-7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=trial-mode-in-windows-phone-7</link>
		<comments>http://www.underbridgecity.net/blog/2012/03/trial-mode-in-windows-phone-7/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 04:02:26 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Trial mode]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.underbridgecity.net/blog/?p=57</guid>
		<description><![CDATA[While building my apps for WP7 that users will pay for, I like to create a trial so the users can try out my app before they buy it. But when you are debugging your app there is no Trial &#8230;<p class="read-more"><a href="http://www.underbridgecity.net/blog/2012/03/trial-mode-in-windows-phone-7/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>While building my apps for WP7 that users will pay for, I like to create a trial so the users can try out my app before they buy it. But when you are debugging your app there is no Trial simulation. So Looking on the web I found one.</p>
<p>Here is what i do to simulate trial mode in my Windows Phone 7 apps.</p>
<p>First at the top of your App.xaml.cs file add this</p>
<p>*EDIT*<br />
I forgot to put this in here at the top. You need it to access the licence information.</p><pre class="crayon-plain-tag">//Used to determine if app is running under a trail license.
 private static LicenseInformation _licenseInfo = new LicenseInformation();</pre><p>and to use that you will need to add in the folling using statment.</p><pre class="crayon-plain-tag">using Microsoft.Phone.Marketplace;</pre><p>*END EDIT*</p><pre class="crayon-plain-tag">private static bool _isTrial = true;
 public bool IsTrial
 {
 get
 {
 return _isTrial;
 }
 }</pre><p>I usually add that in right under my RootFrame property.</p>
<p>I then create a method in my App.xaml.cs</p><pre class="crayon-plain-tag">private void CheckLicense()
 {
 #if DEBUG
 if (MessageBox.Show("This is for debugging purposes. This allows trial mode to be set. Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.", "Debug Trial",
 MessageBoxButton.OKCancel) == MessageBoxResult.OK)
 {
 _isTrial = true;
 }
 else
 {
 _isTrial = false;
 }
 #else
 _isTrial = _licenseInfo.IsTrial();
 #endif

}</pre><p>I then put the CheckLicence method into my Application_Launching and Application_Activated methods in my App.xaml.cs file to check if the application is bought or a trial version.</p>
<p>Then in your code you set up what will happen in your trial version and all you have to is check the IsTrial if true, it is a trail version. If false it is a full/paid version.</p><pre class="crayon-plain-tag">if ((Application.Current as App).IsTrial)
 {
 //Do trial things in here
 }</pre><p>I hope this helps you out creating your WP7 app!</p>
<p>(EDIT: Putting this code in will check if trial or not after you buy the app, check out my post here http://www.underbridgecity.net/blog/2012/04/update-to-my-trial-mode-post/)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.underbridgecity.net/blog/2012/03/trial-mode-in-windows-phone-7/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
