<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>SilverlightTips.com</title>
    <description>Keeping it simple and useful</description>
    <link>http://silverlighttips.com/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.5.0.7</generator>
    <language>en-GB</language>
    <blogChannel:blogRoll>http://silverlighttips.com/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.dotnetblogengine.net/syndication.axd</blogChannel:blink>
    <dc:creator>Damon Serji</dc:creator>
    <dc:title>SilverlightTips.com</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Silverlighttips" /><feedburner:info uri="silverlighttips" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>Mass Effect 2 Silverlight banner wins Best Advertising Website by WebAward</title>
      <description>&lt;p&gt;&lt;img style="float: right;" src="../../image.axd?picture=2010%2f10%2fMetia-WebAward.jpg" alt="Metia 2010 WebAward for Best Advertising Website" /&gt;&lt;/p&gt;
&lt;p&gt;This morning we received a delivery of the glorious shiny and cool WebAward trophy for Best Advertising Website award right to our door here at &lt;a title="Metia" href="http://www.metia.com/"&gt;Metia&lt;/a&gt; in Leicester Square! This is for the project which I worked on at the beginning of this year and posted about on 28th January 2010. You can read my full post about this project at: &lt;a title="The first interactive Silverlight banner ad in the world!" href="http://silverlighttips.com/post/2010/01/28/MassEffect2-SilverlightBannerAD.aspx"&gt;The first interactive Silverlight banner ad in the world!&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The award is published on WebAwards website here: &lt;a title="Metia wins 2010 WebAward for Mass Effect 2 Silverlight Campaign" href="http://www.webaward.org/winner.asp?eid=15259"&gt;Metia wins 2010 WebAward for Mass Effect 2 Silverlight Campaign&lt;/a&gt;, and the actual project is available to see here: &lt;a title="Metia Award Winning Silverlight Campaign for Mass Effect 2" href="http://www.xindustry.com/eabanner/"&gt;Metia Award Winning Silverlight Campaign for Mass Effect 2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img style="float: left;" src="../../image.axd?picture=2010%2f10%2fWebAward-Best-of-Industry.gif" alt="WebAward - Best of Industry 2010" /&gt;&lt;/p&gt;
&lt;p&gt;As you may know, WebAward, sponsored by Web Marketing Association, are THE kind of awards any Internet marketing, online advertising, PR, and top web site design professionals would hope to get hold of. The WebAwards use seven criteria of Design, Content, Copywriting, Use of Technology, Innovation, Interactivity and Ease of use to evaluate award-winning websites from 96 industry categories.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Every year thousands and thousands of websites enter the WebAwards Competition and we at Metia not only were recognised as a #1 in our sector to receive the Best Advertising Website, but also managed to score about 20% higher than the category average, and this is a fantastic achievement that we are very proud of.&lt;/p&gt;
&lt;p&gt;As the developer of this project, I am particularly delighted to have been a part of an exciting team with creative and motivated team members and would like to congratulate Dean, Mark, Tina, Stuart, Stephen, Sarah and Colin who like always worked hard to deliver an outstanding result.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/f3KitnerKoM" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/f3KitnerKoM/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2010/10/08/Mass-Effect-2-Silverlight-banner-wins-Best-Advertising-Website-by-WebAward.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=1fee5113-d88f-4c98-8c87-96ca36f4dd96</guid>
      <pubDate>Fri, 08 Oct 2010 15:34:00 +0100</pubDate>
      <category>Silverlight News</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=1fee5113-d88f-4c98-8c87-96ca36f4dd96</pingback:target>
      <slash:comments>107</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=1fee5113-d88f-4c98-8c87-96ca36f4dd96</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2010/10/08/Mass-Effect-2-Silverlight-banner-wins-Best-Advertising-Website-by-WebAward.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=1fee5113-d88f-4c98-8c87-96ca36f4dd96</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=1fee5113-d88f-4c98-8c87-96ca36f4dd96</feedburner:origLink></item>
    <item>
      <title>Tracking in Silverlight (Google Analytics) - Part II</title>
      <description>&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2010%2f2%2fGoogleAnalyticsLogo.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In my previous posts I explaind how to use &lt;a href="http://silverlighttips.com/post/2010/01/26/Google-Analytics-in-Silverlight-%28Event-Tracking%29.aspx"&gt;Google Analytics in Silverlight&lt;/a&gt; to track different information about users interaction with your Silverlight application.&lt;/p&gt;
&lt;p&gt;One of the things you want to include in your tracking report is how many users who visited your site had Silverlight installed and how many didn&amp;rsquo;t. In addition, you might want to go in deeper details and find out more about users who didn&amp;rsquo;t have your required&amp;nbsp; Silverlight plug-in on their computers:&lt;/p&gt;
&lt;p&gt;- how many had an older version of Silverlight &amp;ndash; and which version did they have&lt;br /&gt; - how many had/didn&amp;rsquo;t have a Silverlight compatible platform&lt;br /&gt;- haw many of users without Silverlight plug-in clicked on &amp;ldquo;Download Silverlight plug-in&amp;rdquo; that you provided&lt;br /&gt;- how many didn&amp;rsquo;t download the Silverlight plug-in and continued interacting with the &amp;ldquo;none-Silverlight&amp;rdquo; version of the application that you provided (if you provided any)&lt;/p&gt;
&lt;p&gt;The source code for this project is available for &lt;a href="http://trackingsilverlight.codeplex.com/wikipage"&gt;download from CodePlex&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can capture all above details and add to your analytics report.&lt;/p&gt;
&lt;p&gt;Doing above tracking requires you to A. Find the required information about user, and B. Send them to your analytics software.&lt;/p&gt;
&lt;p&gt;You can find all information about the user Silverlight support from Silverlight.supportedUserAgent.js file which is provided by Microsoft. You can &lt;a href="http://code.msdn.microsoft.com/SLsupportedUA"&gt;download Silverlight.supportedUserAgent.js&lt;/a&gt; from Microsoft&amp;rsquo;s website.&lt;/p&gt;
&lt;p&gt;However in order to send the right data to Google Analytics/Webtrends (or any other analytics software) you need to modify this file slightly to send the information when necessary:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. add Silverlight.supportedUserAgent.js to your project&lt;/strong&gt;&lt;br /&gt;After downloading the Silverlight.supportedUserAgent.js file, add it to your Web project and call if from your Default.aspx (or any page that hosts your Silverlight application). You can call this file from the header, but just make sure it is called after your Tracking.js file (your tracking code).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. add tracking code to Silverlight.supportedUserAgent.js&lt;/strong&gt;&lt;br /&gt;If you open this file and have a look, you will quite quickly notice there are a few if-else statements which checks different browser and OS to see which is the user using. Off course it depends how you like your report to be generated and what you would like to capture, but this is what I have done:&lt;/p&gt;
&lt;p&gt;At the end of &amp;ldquo;if (slua.OS != 'Unsupported')&amp;rdquo; statement and just before the final closing curly bracket, add the following tracking code:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
 trackEvent(&lt;span class="str"&gt;"SilverlightApplication"&lt;/span&gt;, &lt;span class="str"&gt;"Platform supports Silverlight"&lt;/span&gt;, &lt;span class="str"&gt;"OS: "&lt;/span&gt; + slua.OS + &lt;span class="str"&gt;" - Browser: "&lt;/span&gt; + slua.Browser);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Above code could generates a similar report to this:&lt;/p&gt;
&lt;p&gt;Category: SilverlightApplication&lt;br /&gt;Action: Platform supports Silverlight&lt;br /&gt;Label: OS: Windows &amp;ndash; Browser: IE5&lt;/p&gt;
&lt;p&gt;So by seeing above report I know how many users did support Silverlight and what platform where they using.&lt;/p&gt;
&lt;p&gt;Find and modify the &amp;ldquo;if (version == '2.0')&amp;rdquo; and &amp;ldquo;else if (version == '1.0')&amp;rdquo;&amp;nbsp; statements at the bottom of the page and change them to include tracking code like this:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (version == &lt;span class="str"&gt;'2.0'&lt;/span&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trackEvent(&lt;span class="str"&gt;"NoneSilverlight"&lt;/span&gt;, &lt;span class="str"&gt;"Unsupported silverlight"&lt;/span&gt;, &lt;span class="str"&gt;"Silverlight Version: 2.0"&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; (supUA &amp;amp;&amp;amp; (slua.OS != &lt;span class="str"&gt;'MacPPC'&lt;/span&gt;));&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (version == &lt;span class="str"&gt;'1.0'&lt;/span&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trackEvent(&lt;span class="str"&gt;"NoneSilverlight"&lt;/span&gt;, &lt;span class="str"&gt;"Unsupported silverlight"&lt;/span&gt;, &lt;span class="str"&gt;"Silverlight Version: 1.0"&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; (supUA &amp;amp;&amp;amp; (ua.indexOf(&lt;span class="str"&gt;'Windows NT 5.0'&lt;/span&gt;) &amp;lt; 0));&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now you know if user had a different version of Silverlight, and can drill down in the report to find out which version did they have.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. If your Silverlight application was loaded &lt;/strong&gt;&lt;br /&gt;Since it is not clear from above report if user actually saw your Silverlight application you can add the below code:&lt;/p&gt;
&lt;p&gt;In your Silverlight object add the following parameter:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="onload"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="onSilverlightLoad"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;And then add the following java script code to your Default.aspx page:&lt;br /&gt;&lt;div class="code"&gt;
 function onSilverlightLoad(sender) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trackEvent(&lt;span class="str"&gt;"SilverlightApplication"&lt;/span&gt;, &lt;span class="str"&gt;"Platform supports Silverlight"&lt;/span&gt;, &lt;span class="str"&gt;"SilverlightApp was loaded"&lt;/span&gt;);&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This piece of code will be loaded every time your Silverlight application is loaded.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. if user interacts with the none-Silverlight version of your site/application&lt;/strong&gt;&lt;br /&gt;if (and you must always) prepared a none- Silverlight version, using above method you should now have a good idea on how to send the tracking code to your analytics software if Silverlight was not loaded for any reason and the user carries on interacting with your none- Silverlight version.&lt;/p&gt;
&lt;p&gt;Hint: to add none Silverlight version you can add your HTML inside the &amp;lt;object&amp;gt; tag and right after the last &amp;lt;param&amp;gt; tag. Any code or text before the &amp;lt;/object&amp;gt; will be displayed when you don&amp;rsquo;t have Silverlight installed/enabled.&lt;/p&gt;
&lt;p&gt;And to send the tracking on i.e. links, add it to your onload or similar function/event.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. Call CheckSupported()function&lt;/strong&gt;&lt;br /&gt;Finally, add this function to your page:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
 function CheckSupported() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var tst = Silverlight.supportedUserAgent();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (tst) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;else&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} &lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And now call it from your Default.aspx just before to &amp;lt;/body&amp;gt; tag. i.e.:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    CheckSupported();&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;    &lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/Axz6mqnE1cc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/Axz6mqnE1cc/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2010/02/10/Analytics-tracking-on-your-Silverlight-Part-II.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=30a2c853-ba75-42b4-9b84-193eb6a2507e</guid>
      <pubDate>Wed, 10 Feb 2010 13:24:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=30a2c853-ba75-42b4-9b84-193eb6a2507e</pingback:target>
      <slash:comments>108</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=30a2c853-ba75-42b4-9b84-193eb6a2507e</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2010/02/10/Analytics-tracking-on-your-Silverlight-Part-II.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=30a2c853-ba75-42b4-9b84-193eb6a2507e</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=30a2c853-ba75-42b4-9b84-193eb6a2507e</feedburner:origLink></item>
    <item>
      <title>The first interactive Silverlight banner ad in the world!</title>
      <description>&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2010%2f1%2fMassEffect2-Screenshot02.jpg" alt="MassEffect2-Screenshot - Expanded view" /&gt;&lt;span style="font-size:10px;"&gt;Expanded view of Mass Effect 2 Silverlight banner&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Today I am very excited to say we at &lt;a href="http://www.metia.com/"&gt;Metia&lt;/a&gt; are at the very final stage of launching the world&amp;rsquo;s first interactive and expandable banner ad developed using Microsoft Silverlight 3.0 technology.&lt;/p&gt;
&lt;p&gt;This Silverlight banner, which is going to be published on &lt;a title="MSN tech and gadgets" onclick="javascript:pageTracker._trackPageview('/outbound/article/tech.uk.msn.com');" href="http://tech.uk.msn.com/gaming/" target="_blank"&gt;Tech and Gadgets page of MSN UK&lt;/a&gt; this afternoon (28th Jan 2010) and then published and remain on &lt;a title="MSN UK homepage" onclick="javascript:pageTracker._trackPageview('/outbound/article/uk.msn.com');" href="http://uk.msn.com/" target="_blank"&gt;MSN UK homepage&lt;/a&gt; for a few weeks from tomorrow, has been developed to launch Electronic Art&amp;rsquo;s new game: &lt;a href="http://eu.masseffect.com/index.asp?lang=en"&gt;&lt;strong&gt;Mass Effect 2&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2010%2f1%2fMassEffect2-Screenshot03.jpg" alt="MassEffect2-Screenshot - Minimized view" /&gt;&lt;span style="font-size:10px;"&gt;Minimized view of Mass Effect 2 Silverlight banner on MSN's homepage&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As the developer of this project, I am particularly excited about launching this because apart from the fact that this is the first Silverlight banner in the world, it also uses cool Silverlight features such as Deep Zoom and Smooth Streaming. The banner has been designed to give the same exciting and lively feeling as the game by using some graphics from the game, and most importantly the creativity of our interactive designers as well as everybody else involved in this project at Metia, to add the essential touches to the user experience.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So some rather technical facts:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;At first glance you might think how did Microsoft allow a banner with HD quality video and high resolution images, 1280&amp;times;720 and 1920&amp;times;1200 to be precise,&amp;nbsp; to be displayed on their MSN homepage, surly this is going to slow down the loading time for their homepage? Well it could slow the loading time down because the content of the banner all together is about 600MB! Yet, the answer is NO, and the reason is because the size of initial download banner is only about 40kb!&lt;/p&gt;
&lt;p&gt;Basically, there are two .xap files for this banner: footprint and content. The footprint is the preloader .xap file that gets downloaded when loading the page and is 40kb, and the content .xap file, which is about 600kb, is the one that contains UI elements and dlls. All other contents including videos and images are streamed or downloaded seperatly in the background when needed. Seriously, the banner is supper fast.&lt;/p&gt;
&lt;p&gt;So the banner is quite smart enough to not throw all content including Mass Effect 2 screenshots and many high-resolution images for your desktop wallpaper to your computer when you don&amp;rsquo;t actually want them. Instead, it starts downloading content at different stages according to the user&amp;rsquo;s behaviour, i.e. it guesses what content is the user going to see next and starts downloading it in the background, so when the user opens the content he/she is more likely to see the actual content instead of the loading bar. The amazing Smooth Streaming has also made it possible to download HD quality videos including Mass Effect 2 trailer without leaving the user waiting for hours!&lt;/p&gt;
&lt;p&gt;I am very pleased to have experienced working on this exciting project, with exciting people, for an exciting client, and for an exciting event! The banner is going live this afternoon, so make sure you visit &lt;a title="MSN tech and gadgets" onclick="javascript:pageTracker._trackPageview('/outbound/article/tech.uk.msn.com');" href="http://tech.uk.msn.com/gaming/" target="_blank"&gt;Tech and Gadgets page of MSN UK&lt;/a&gt; and download Mass Effect 2 wallpapers!&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2010%2f1%2fMassEffect2-Screenshot00.jpg" alt="Mass Effect 2 screenshot" /&gt;&lt;/p&gt;
&lt;div style="font-size:10px; clear:left;"&gt;Mass Effect 2 screenshot&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2010%2f1%2fMassEffect2-Screenshot01.jpg" alt="Mass Effect 2 screenshot" /&gt;&lt;/p&gt;
&lt;div style="font-size:10px; clear:left;"&gt;Mass Effect 2 screenshot&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/KgINw_QjJ_0" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/KgINw_QjJ_0/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2010/01/28/MassEffect2-SilverlightBannerAD.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=ac66ca0b-2e3d-4251-b584-7920230f4065</guid>
      <pubDate>Thu, 28 Jan 2010 06:16:00 +0100</pubDate>
      <category>Silverlight News</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=ac66ca0b-2e3d-4251-b584-7920230f4065</pingback:target>
      <slash:comments>111</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=ac66ca0b-2e3d-4251-b584-7920230f4065</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2010/01/28/MassEffect2-SilverlightBannerAD.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=ac66ca0b-2e3d-4251-b584-7920230f4065</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=ac66ca0b-2e3d-4251-b584-7920230f4065</feedburner:origLink></item>
    <item>
      <title>Google Analytics in Silverlight (Event Tracking)</title>
      <description>&lt;p&gt;&lt;a href="http://www.google.com/analytics/"&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2010%2f1%2fgoogle-analytics-logo.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As you may be aware, &lt;a href="http://www.google.com/analytics/"&gt;Google Analytics&lt;/a&gt; does not track any actions such as click and etc from inside Silverlight applications. To overcome this issue and track the actions made by users on a Silverlight application we need to manually report to Google the actions. We do this using &amp;ldquo;Event Tracking&amp;rdquo; feature on Google Analytics.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2010%2f1%2fGoogleAnalyticsEventTrackingScreenShot.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Above screen shot shows how the data show in Google Analytics once they are captured in Event Tracking. In the screen shot: Homepage, Home &amp;ndash; video player and Products page are categories. Each category then has a list of Event Actions and each action could have a label to provide more details about that action, for instance you could have: &amp;lsquo;Homepage&amp;rsquo; &amp;gt; &amp;lsquo;Clicks&amp;rsquo; &amp;gt; &amp;lsquo;Logo Image&amp;rsquo;, which displays how many times the &amp;lsquo;Logo Image&amp;rsquo; was clicked from the homepage of the site.&lt;/p&gt;
&lt;p&gt;The process of tracking actions in Silverlight is very simple, it consists of capturing the actions and passing them to Google Analytics using a JavaScript function that Google provides us in their tracking code.&lt;/p&gt;
&lt;p&gt;The first thing I would do in setting up tracking for my Silverlight application is to create a separate class in the main Silverlight project to managed the all tracking code. I then can use this class everywhere within my application and pass to it the required parameter for tracking. This way if I decided to change something in my tracking code, or use a complete different application for my tracking i.e. &lt;a href="http://www.webtrends.com/"&gt;Webtrends&lt;/a&gt;, I then only need to change my code in one place and the rest of code remains as before.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. create Tracking class&lt;/strong&gt;&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;namespace&lt;/span&gt; SilverlightGoogleAnalytics.Tracking&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Tracking&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; declare some private variables for passing required parameters to the analytics:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; category;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; resourceLabel;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; groupType;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; action;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Tracking _instance;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;B.&lt;/strong&gt; create an instance of the Tracking class as a property&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Tracking Instance&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (_instance == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _instance = &lt;span class="kwrd"&gt;new&lt;/span&gt; Tracking();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; _instance;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Instance is a static public variable that holds a reference to the Tracking class itself. You will see later how we use this property to access its Tracking&amp;rsquo;s public methods.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C.&lt;/strong&gt; create a public method to receive parameters and pass to the analytics:&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Track(&lt;span class="kwrd"&gt;string&lt;/span&gt; trackingCategory, &lt;span class="kwrd"&gt;string&lt;/span&gt; trackingResourceLabel, &lt;span class="kwrd"&gt;string&lt;/span&gt; trackingAction)&lt;br /&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; category = trackingCategory;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; resourceLabel = trackingResourceLabel;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; action = trackingAction;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SendTracking();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Track(&lt;span class="kwrd"&gt;string&lt;/span&gt; trackingCategory, &lt;span class="kwrd"&gt;string&lt;/span&gt; trackingAction)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; category = trackingCategory;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; action = trackingAction;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; resourceLabel = &lt;span class="str"&gt;""&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SendTracking();&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The Track methods (note they both are called Track but have different signatures) take the tracking data: category, resourceLabel and action.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;D.&lt;/strong&gt; send the data to &amp;ldquo;trackEvent&amp;rdquo; JavaScript function &lt;br /&gt;now that we have the tracking information we simply call a private method which sends the data to our JavaScript function (see step 2) using Invoke method for being sent off to Google Analytics:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendTracking()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HtmlPage.Window.Invoke(&lt;span class="str"&gt;"trackEvent"&lt;/span&gt;, category, action, resourceLabel);&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;We don&amp;rsquo;t need to do anything else with this class, from now on we can simply use this track whenever we need to pass some tracking data to Google Analytics.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. JavaScript function to pass parameters to Google Analytics&lt;/strong&gt;&lt;br /&gt;this is the code we need for passing the data to Google Analytics to save it as an event:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
function trackEvent(category, action, opt_label, opt_value) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pageTracker._trackEvent(category, action, opt_label, opt_value);&lt;/p&gt;
&lt;p&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here I added this to a separate JavaScript file called Tracking.js, but you can also add it straight to your html/asp page inside script tags.&lt;br /&gt;The default script that Google provides you for the analytics remain as they are.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Calling Tracking class from your code and passing tracking values&lt;/strong&gt;&lt;br /&gt;first create a private variable to hold a reference to your Tracking class:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; Tracking.Tracking tracking;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now initialize your variable in your constructor or Loaded method:&lt;br /&gt;&lt;div class="code"&gt;
tracking = &lt;span class="kwrd"&gt;new&lt;/span&gt; SilverlightGoogleAnalytics.Tracking.Tracking();&lt;/div&gt;&lt;br /&gt;Now you can call the Track methods within Tracking class anytime needed. i.e.:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
tracking.Track(&lt;span class="str"&gt;"SilverlightApplication"&lt;/span&gt;, &lt;span class="str"&gt;"Loaded"&lt;/span&gt;);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here I called the Track method within tracking that takes two parameters: Category and Action. I could also pass another parameter (resource label) for instance:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
tracking.Track(&lt;span class="str"&gt;"Homepage"&lt;/span&gt;, &lt;span class="str"&gt;"Click"&lt;/span&gt;, &lt;span class="str"&gt;"ClickButton"&lt;/span&gt;);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Improving your code:&lt;/strong&gt;&lt;br /&gt;The above code works perfectly fine, however this was a small project, if you were dealing with a much bigger scale project then you wouldn&amp;rsquo;t want to type in the category, action and resource label every time you have to pass the parameters because you could end up with inconsistent data or typo errors.&lt;/p&gt;
&lt;p&gt;One solution to this is to use Enum variables for either category, action or resource label. So whenever you have to pass a action you just select it from the list of available actions and if it wasn&amp;rsquo;t there you can add it to the list so next time you can use the same action and not end up with an inconsistent report like: &amp;ldquo;Homepage &amp;gt; ClickButton &amp;gt; Clicked&amp;rdquo; and &amp;ldquo;Homepage &amp;gt; ClickButton &amp;gt; Mouse Click&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; create a new class in your Silverlight project and call it Enums.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; create required enum types&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
 &lt;span class="kwrd"&gt;namespace&lt;/span&gt; SilverlightGoogleAnalytics.Enums&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; TrackingCategories&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SilverlightApplication,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Homepage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; TrackingGenericLabels&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ClickButton&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; TrackingActions&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Click,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Load&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. use the created enum types to pass values&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
 tracking.Track(Enums.TrackingCategories.Homepage.ToString(), Enums.TrackingGenericLabels.ClickButton.ToString(), Enums.TrackingActions.Click.ToString());&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/SS37DdNrhy0" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/SS37DdNrhy0/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2010/01/26/Google-Analytics-in-Silverlight-(Event-Tracking).aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=c0d8fc90-0a97-41ae-9e86-442fc52cf0a1</guid>
      <pubDate>Tue, 26 Jan 2010 10:29:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=c0d8fc90-0a97-41ae-9e86-442fc52cf0a1</pingback:target>
      <slash:comments>131</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=c0d8fc90-0a97-41ae-9e86-442fc52cf0a1</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2010/01/26/Google-Analytics-in-Silverlight-(Event-Tracking).aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=c0d8fc90-0a97-41ae-9e86-442fc52cf0a1</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=c0d8fc90-0a97-41ae-9e86-442fc52cf0a1</feedburner:origLink></item>
    <item>
      <title>Set Margin and Canvas programmatically</title>
      <description>&lt;p&gt;To set the margin or Canvas of an object from the code you can use SetValue() which is a built-in method. SetValue() takes a DependencyProperty such as a Button, and a double value.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
myButton.SetValue(Canvas.LeftProperty, myPoint.X);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In above example &amp;lsquo;myButton&amp;rsquo; is a Button on the xaml, and myPoint is a variable of type Point which we use the X value of.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/ho3LML7nuEA" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/ho3LML7nuEA/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2010/01/11/Set_Margin_programmatically.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=6f91e933-49a0-4fe2-8bbf-ea6fc57efc1f</guid>
      <pubDate>Mon, 11 Jan 2010 18:36:00 +0100</pubDate>
      <category>Basic</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=6f91e933-49a0-4fe2-8bbf-ea6fc57efc1f</pingback:target>
      <slash:comments>87</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=6f91e933-49a0-4fe2-8bbf-ea6fc57efc1f</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2010/01/11/Set_Margin_programmatically.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=6f91e933-49a0-4fe2-8bbf-ea6fc57efc1f</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=6f91e933-49a0-4fe2-8bbf-ea6fc57efc1f</feedburner:origLink></item>
    <item>
      <title>Silverlight Preloader</title>
      <description>&lt;p&gt;Before I started writing this post I had a quick search on the internet about Silverlight Preloader (Silverlight progressbar) and noticed a few good posts that already exist and explain how to do this.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.silverlighttips.com/includes/preloader/"&gt;&lt;img style="float: right;" src="http://silverlighttips.com/image.axd?picture=2009%2f12%2fSilverlightPreloader.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;However, one thing I noticed from most of the tutorials about creating Silverlight progressbar is that they all replace the standard Silverlight preloader animation with a simple rectangle progressbar! Although displaying your logo with a standard progressbar in shape of rectangle is much better and professional than leaving the standard Silverlight preloader to be displayed, but I think it is not that cool!&lt;/p&gt;
&lt;p&gt;To test this project I added a large file to the project in order to slow down the process of loading for us to see the effect. To view the live demo click &lt;a href="http://www.silverlighttips.com/includes/preloader/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The code can be downloaded from CodePlex &lt;a href="http://silverlightpreloader.codeplex.com" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As a result, I want to explain how to take your logo and with a bit use of maths do something cool to it, like filling it with color to display the progress of loading.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1.&amp;nbsp; Add new xaml and js files to your Web project&lt;/strong&gt;&lt;br /&gt;this xaml file will include your custom progress bar, you can call this anything you like, here we call it preloader.xaml. To add a new xaml file: right click on your .Web project from the menu find &amp;lsquo;Add&amp;rsquo; and click on &amp;lsquo;New Item...&amp;rsquo;, from the left side (Categories) select &amp;lsquo;Silverlight&amp;rsquo;, and then from the right side (Templates) choose &amp;lsquo;Silverlight JScript Page&amp;rsquo;. Once you add the xaml file Visual Studio will add a new .js file for you too. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Add splashscreensource and onSourceDownloadProgressChanged parameters to your Silverlight object&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;on your Default.aspx, or any page that hosts your Silverlight application (in our case SilverlightPreloaderTestPage.aspx), add the splashscreensource parameter i.e.:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;object&lt;/span&gt; &lt;span class="attr"&gt;data&lt;/span&gt;&lt;span class="kwrd"&gt;="data:application/x-silverlight,"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="application/x-silverlight"&lt;/span&gt; &lt;br /&gt;&lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="SL"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="splashscreensource"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="loading.xaml"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="onSourceDownloadProgressChanged"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="onSourceDownloadProgressChanged"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The first parameter simply loads the loading.xaml while loading the main components of the Silverlight application.&lt;/p&gt;
&lt;p&gt;The second parameter calls the onSourceDownloadProgressChanged&amp;nbsp; function from or preloader.js file.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Create a new progress bar in preloader.xaml using Blend&lt;/strong&gt;&lt;br /&gt;Since we want to fill a logo or a shape with color instead of just creating a rectangle progressbar, we need to draw the shape manually in Expression Blend. You might notice Blend doesn&amp;rsquo;t open the preloader.xaml file from our .Web project. To solve this issue I simply open a new xaml file in Blend and once I am happy with my changes I copy and paste the code to my preloader.xaml file.&lt;/p&gt;
&lt;p&gt;To demonstrate the filling of a shape we need to use Path Clipping technique. Basically we need to create a rectangular Canvas and then cut the shape we want out from it. Then we can move another coloured rectangular, which is inside the canvas but positioned outside it by adding a high margin to it, to the left/right/up/down towards inside the canvas according to the percentage of loading. This way user will see the shape we draw earlier getting filled with color as the percentage of loading increases. To learn about Path &lt;a href="http://www.silverlighttips.com/post/2009/12/30/Clipping-paths-in-Expression-Blend.aspx"&gt;Clipping visit Clipping paths in canvas using Expression Blend&lt;/a&gt; by &lt;a href="http://www.silverlightbuzz.com/" target="_blank"&gt;Gavin Wignall&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Do the calculation in Java Script file&lt;/strong&gt;&lt;br /&gt;copy this code to your preloader.js file:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
function onSourceDownloadProgressChanged(sender, eventArgs) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (sender.findname(&lt;span class="str"&gt;"loadingStatus"&lt;/span&gt;) != &lt;span class="kwrd"&gt;null&lt;/span&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var loaded = Math.round(eventArgs.progress * 10) / 10;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sender.findName(&lt;span class="str"&gt;"loadingStatus"&lt;/span&gt;).Text = &lt;span class="str"&gt;"Loading: "&lt;/span&gt; + (Math.round(eventArgs.progress * 1000)) / 10 + &lt;span class="str"&gt;"%"&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var newValue = 79 - (79 * loaded);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sender.findName(&lt;span class="str"&gt;"LoadFill"&lt;/span&gt;)[&lt;span class="str"&gt;"Canvas.Top"&lt;/span&gt;] = newValue;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;onSourceDownloadProgressChanged is the name of function which we call from our object in .aspx page (&amp;lt;param name="onSourceDownloadProgressChanged" value="onSourceDownloadProgressChanged" /&amp;gt;).&lt;/p&gt;
&lt;p&gt;loadingStatus is a name we have given to a TextBlock in our preloader.xaml. Here we find the TextBlock loadingStatus and then assign the current loading percentage to it.&lt;/p&gt;
&lt;p&gt;eventArgs.progress&amp;nbsp; is a very long number like 0.3452345234232 and shows the percentage of loading, 1 is 100%. So we need to change this to something like 34.5 and 100 as 100%. To do this we first multiply eventArgs.progress&amp;nbsp; by 1000, this way we get 345.2345234232 and to remove the .2345234232 we use Math.round()function which is a Java Script built-in function. Now we should have 345. To get 34.5 which is the actual percentage of loading we simple divid&lt;/p&gt;
&lt;p&gt;e the number by 10. At the end we add a bit of text to the result and insert it to our loadingStatus TextBlock.&lt;/p&gt;
&lt;p&gt;In order to show our logo is getting filled by color we need to move the rectangular inside by changing its &amp;ldquo;Canvas.Top&amp;rdquo; property which acts just like Margin. As we want to keep the rectangular outside the visible area we position it 79 pixels, which is just the actual height of our rectangular, away from the top, so it sits just below the visible area.&lt;/p&gt;
&lt;p&gt;If you follow the maths as I explain above you will understand that &amp;lsquo;loaded&amp;rsquo; variable will have a value like 0.34 (this time we multiplied it by 10 instead of 1000). Lets say if we had 99 percent loaded then the &amp;lsquo;loaded&amp;rsquo; variable would have a value of 0.99. times that by 79 and you get 78.21, now if we follow the equation: 79 &amp;ndash; (78.21) =&amp;nbsp; 0.79. If we set the Canvas.Top to 0.79 then our clipped area will be almost completely filled with color because the rectangular is sitting right at the top and that is exactly what we wanted to achieve.&lt;/p&gt;
&lt;p&gt;Please note, if your rectangular is larger or smaller than 79 pixels you need to change both 79 to actual height of your rectangular to get this working correctly.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/PQFyDnbRaFE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/PQFyDnbRaFE/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/12/30/Silverlight-Preloader.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=d01b5de4-6fca-4f2e-86c8-89491fe9ce7e</guid>
      <pubDate>Wed, 30 Dec 2009 12:47:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=d01b5de4-6fca-4f2e-86c8-89491fe9ce7e</pingback:target>
      <slash:comments>153</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=d01b5de4-6fca-4f2e-86c8-89491fe9ce7e</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/12/30/Silverlight-Preloader.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=d01b5de4-6fca-4f2e-86c8-89491fe9ce7e</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=d01b5de4-6fca-4f2e-86c8-89491fe9ce7e</feedburner:origLink></item>
    <item>
      <title>Clipping paths in canvas using Expression Blend</title>
      <description>&lt;p&gt;Sometimes you need to cut a shape out from your canvas to produce a special effect by showing another object from behind the canvas appearing in the clipped area. This mainly is used in making animations to for instance display a text appearing in the clipped area.&lt;/p&gt;
&lt;p&gt;In order to achieve this all you need is a canvas, another object inside the canvas, i.e. text or a rectangular to work as a color panel, and a path in your desired shape:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Add a canvas to your page&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Add a rectangular inside the Canvas and fill it with a color&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Draw a path&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;img style="float: right;" src="http://silverlighttips.com/image.axd?picture=2009%2f12%2fpen.gif" alt="" /&gt;make sure you clicked on the LayoutRoot level before drawing the path, so your path doesn&amp;rsquo;t appear inside the canvas. You can draw a path using Pen tool. Select the Pen tool from tools panel and click on different places on the page to see the shape been drawn, to end the path click on the start point.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Clipping the path out from the canvas&lt;/strong&gt;&lt;br /&gt;you can choose which object to be clipped from the other by the order of selecting them. In this case we want our shape which we created using path method to be clipped from the canvas. Therefore, we need to click and select our path first, and then holding the Ctrl button on the keyboard click on the canvas.&lt;/p&gt;
&lt;p&gt;We should now have both our path and canvas selected. Go to &amp;lsquo;Object&amp;rsquo; menu in Blend and from &amp;lsquo;Path&amp;rsquo; click on &amp;lsquo;Make Clipping Path&amp;rsquo; (shortcut key is Ctrl + 7).&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f12%2fCanvas-Rectangular-Shape.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now your canvas should have a hole in the shape you draw earlier using the Pen. So by moving the rectangular inside the canvas you will be able to notice the clipped area appearing when the rectangular or text is on the same position and disappearing when we move the rectangular or text to outside the clipped area.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f12%2fClippedAreaInCanvas.gif" alt="" /&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/ZItZznOuoEA" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/ZItZznOuoEA/post.aspx</link>
      <author>Gavin</author>
      <comments>http://silverlighttips.com/post/2009/12/30/Clipping-paths-in-Expression-Blend.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=4a4c73dd-116b-41e6-9ecb-d3e3b2a689f5</guid>
      <pubDate>Wed, 30 Dec 2009 11:33:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>Gavin</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=4a4c73dd-116b-41e6-9ecb-d3e3b2a689f5</pingback:target>
      <slash:comments>87</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=4a4c73dd-116b-41e6-9ecb-d3e3b2a689f5</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/12/30/Clipping-paths-in-Expression-Blend.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=4a4c73dd-116b-41e6-9ecb-d3e3b2a689f5</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=4a4c73dd-116b-41e6-9ecb-d3e3b2a689f5</feedburner:origLink></item>
    <item>
      <title>Silverlight Pagination (DataPager)</title>
      <description>&lt;div id="silverlightControlHost"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
// --&gt;&lt;/script&gt;
&lt;script src="http://www.silverlighttips.com/includes/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;object width="546" height="480" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://silverlighttips.com/includes/SilverlightPagination.xap" /&gt;
&lt;param name="onError" value="onSilverlightError" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="3.0.40623.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40623.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" /&gt;&amp;nbsp;&lt;/a&gt;
&lt;/object&gt;
&lt;span style="font-size:10px;"&gt;Silverlight pagination&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;Pagination (DataPager) is a built-in control in Silverlight 3.0. You simply bind your data to the DataContext through a PagedCollectionView variable.&lt;/p&gt;
&lt;p&gt;PagedCollectionView is a class that could store collection of your data with IEnumerable interface. Through this class you are then able to use cool features such as sorting, filtering and paging functionalities.&lt;/p&gt;
&lt;p&gt;To test pagination in this post I created a class of type &amp;ldquo;Contact&amp;rdquo; to store name, surname and tel number for each contact.&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Contact&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Surname { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Telephone { get; set; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;To get a better visual and have different fields display for each of my contacts I created a ContactTemplate.xaml. This simply contains the template for each of my contacts:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="50"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Name}"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Left"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="19"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Surname}"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Left"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="100,2,0,19"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Tel:"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,17,0,6"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Left"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Telephone}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="25,17,0,7"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In my Mainpage.xaml I use an ItemsControl to list all contacts that have created using Contact class, and since I want each contact to be displayed within my ContactTemplate I display a reference to the ContactTemplate.xaml page and bind each contact to that:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="Contacts"&lt;/span&gt; &lt;span class="attr"&gt;ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding}"&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Local:ContactTemplate&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;To create a reference to the ContactTemplate.xaml you first need to create a namespace in your MainPage.xaml that refers to the project which ContactTemplate.xaml exists (the same project in our case). So don&amp;rsquo;t forget to add this to the top of the MainPage.xaml in order for your above code to work:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;xmlns:Local="clr-namespace:SilverlightPagination"&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Last thing we need to do in the MainPage.xaml is to add a reference to the pagination control (DataPager):&lt;/p&gt;
&lt;p&gt;First add the reference:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now add the control:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;data:DataPager&lt;/span&gt; &lt;span class="attr"&gt;DisplayMode&lt;/span&gt;&lt;span class="kwrd"&gt;="PreviousNext"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,0,4"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding}"&lt;/span&gt; &lt;span class="attr"&gt;NumericButtonCount&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Value, ElementName=numericButtonCount}"&lt;/span&gt; &lt;span class="attr"&gt;AutoEllipsis&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding IsChecked, ElementName=autoEllipsis}"&lt;/span&gt; &lt;span class="attr"&gt;IsTotalItemCountFixed&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding IsChecked, ElementName=totalItemCountFixed}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And to get it working your MainPage.xaml.cs should look something like this:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; List&amp;lt;Contact&amp;gt; allContacts;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; MainPage()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;this&lt;/span&gt;.Loaded += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(MainPage_Loaded);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MainPage_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; allContacts = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Contact&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddData();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PagedCollectionView pcv = &lt;span class="kwrd"&gt;new&lt;/span&gt; PagedCollectionView(allContacts);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pcv.PageSize = 6;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataContext = pcv;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddData()&lt;br /&gt;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt;25; i ++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Contact contact = &lt;span class="kwrd"&gt;new&lt;/span&gt; Contact();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contact.Name = &lt;span class="str"&gt;"DummyName "&lt;/span&gt; + i;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contact.Surname = &lt;span class="str"&gt;"DummySurname "&lt;/span&gt; + i;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contact.Telephone = 020711111 + i;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; allContacts.Add(contact);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In summary, AddData() creates some contacts so that we can test this project, and the rest happens in the MainPage_Loaded. As I explained at the beginning of this post, if you add your list of data to a variable of type PagedCollectionView then you can use the pagination feature of this class. Set the page size, and set the DataContext of the page to your PagedCollectionView variable. The DataContext simply binds your data where ever it is asked to down your code (even in your ContactTemplate.xaml page that you had already added in the ItemsControl.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/-Dw98lN5Oyo" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/-Dw98lN5Oyo/post.aspx</link>
      <author>allan</author>
      <comments>http://silverlighttips.com/post/2009/12/14/Silverlight-Pagination-DataPager.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=0ab57b87-d269-492b-88a9-efc1c72ade03</guid>
      <pubDate>Mon, 14 Dec 2009 19:33:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>allan</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=0ab57b87-d269-492b-88a9-efc1c72ade03</pingback:target>
      <slash:comments>79</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=0ab57b87-d269-492b-88a9-efc1c72ade03</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/12/14/Silverlight-Pagination-DataPager.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=0ab57b87-d269-492b-88a9-efc1c72ade03</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=0ab57b87-d269-492b-88a9-efc1c72ade03</feedburner:origLink></item>
    <item>
      <title>Play sound in Silverlight using MediaElement</title>
      <description>&lt;p&gt;If you want to play music or a short sound clip in Silverlight here is what you need to do:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Your sound file&lt;br /&gt;&lt;/strong&gt;First, make sure you sound file is MP3 or WMA format as other formats are not supported.&lt;/p&gt;
&lt;p&gt;Save your file to ClientBin folder (where your xap file gets coppied when buiding the project)&lt;/p&gt;
&lt;p&gt;If you dont want to store your file to the ClientBin folder do this: from Visual Studio right click on the sound file and select Properties. Now in Properties window change Build Action to Resource. This ensures the file gets copied to the ClientBin folder during execution.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Add a MediaElement in your Xaml file&lt;br /&gt;&lt;/strong&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MediaElement&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="SoundClip"&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="boing.mp3"&lt;/span&gt; &lt;span class="attr"&gt;Volume&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;AutoPlay&lt;/span&gt;&lt;span class="kwrd"&gt;="False"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;MediaElement&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;set the &lt;strong&gt;Source&lt;/strong&gt; to be the name of your file and &lt;strong&gt;AutoPlay&lt;/strong&gt; to False so it can be played at click of a button.&lt;/p&gt;
&lt;p&gt;Also add a button to play the sound when clicked:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="PlaySound"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Play Sound"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. play the sound&lt;/strong&gt;&lt;br /&gt;in your code behind add this to the Click event of your button:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
SoundClip.Play();&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If you have any questions please visit Silverlight Forums here: &lt;a href="http://silverlightforums.com/showthread.php?p=2080#post2080" target="_blank"&gt;http://silverlightforums.com/showthread.php?p=2080#post2080&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/sLNJj9Qduzc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/sLNJj9Qduzc/post.aspx</link>
      <author>allan</author>
      <comments>http://silverlighttips.com/post/2009/12/10/Play-sound-in-Silverlight-using-MediaElement.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=c9fa3a12-fad0-4d2a-bfe7-b98670ab4b7a</guid>
      <pubDate>Thu, 10 Dec 2009 13:16:00 +0100</pubDate>
      <category>Basic</category>
      <dc:publisher>allan</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=c9fa3a12-fad0-4d2a-bfe7-b98670ab4b7a</pingback:target>
      <slash:comments>108</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=c9fa3a12-fad0-4d2a-bfe7-b98670ab4b7a</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/12/10/Play-sound-in-Silverlight-using-MediaElement.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=c9fa3a12-fad0-4d2a-bfe7-b98670ab4b7a</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=c9fa3a12-fad0-4d2a-bfe7-b98670ab4b7a</feedburner:origLink></item>
    <item>
      <title>Silverlight Deep Linking</title>
      <description>&lt;div id="silverlightControlHost"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
// --&gt;&lt;/script&gt;
&lt;script src="http://www.silverlighttips.com/includes/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;object width="546" height="480" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://silverlighttips.com/includes/SilverlightDeepLinking.xap" /&gt;
&lt;param name="onError" value="onSilverlightError" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="3.0.40623.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40623.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" /&gt;&amp;nbsp;&lt;/a&gt;
&lt;/object&gt;
&lt;span style="font-size:10px;"&gt;Silverlight Deep Linking.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;This post is an update to the previous post I have done about Silverlight Deep Linking. So for details and to see previous code visit &lt;a href="http://www.silverlighttips.com/post/2009/09/06/Basic-Silverlight-Deep-Linking.aspx"&gt;Basic Silverlight Deep Linking&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Download:&lt;/strong&gt;&lt;br /&gt;As usual, you can download the complete project from &lt;a href="http://www.codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt; site &lt;a href="http://silverlightdeeplink.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Questions and answers:&lt;/strong&gt;&lt;br /&gt;For updates and any issues visit the specific thread regarding this post at Silverlight Forums: &lt;a href="http://silverlightforums.com/showthread.php?t=1425" target="_blank"&gt;http://silverlightforums.com/showthread.php?t=1425&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Basically, we need to use a built-in class called &amp;ldquo;NavigationFailed&amp;rdquo; from our Frame control to fire the event when user tries navigation to a none-existent page.&lt;/p&gt;
&lt;p&gt;Here I demonstrate two ways of handling the error exception and displaying a friendly error message.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using an error template page&lt;/li&gt;
&lt;li&gt;Using a child window to display a popup message for the error&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Here are 3 steps to get this working with error template page:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Create Error404.xaml and add it to UriMapper&lt;/strong&gt;&lt;br /&gt;add a new page to your Silverlight project and call it Error404 as it will only be used for the Error 404&amp;nbsp; or &amp;ldquo;Page not found&amp;rdquo; error.&lt;/p&gt;
&lt;p&gt;Now, in your App.xaml add the error page to your Navigation UriMapper so the application can navigate to it when needed:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Nav:UriMapping&lt;/span&gt; &lt;span class="attr"&gt;Uri&lt;/span&gt;&lt;span class="kwrd"&gt;="Error"&lt;/span&gt; &lt;span class="attr"&gt;MappedUri&lt;/span&gt;&lt;span class="kwrd"&gt;="/Error404.xaml"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Add &amp;ldquo;MainFrame_NavigationFailed&amp;rdquo; method in MainPage.xaml.cs&lt;/strong&gt;&lt;br /&gt;in your MainPage.xaml.cs and in your constructor or Loaded method, add NavigationFailed event handler to your Frame control (MainFrame):&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
MainFrame.NavigationFailed += &lt;span class="kwrd"&gt;new&lt;/span&gt; System.Windows.Navigation.NavigationFailedEventHandler(MainFrame_NavigationFailed);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If you use the Visual Studio&amp;rsquo;s snippet/shortcut it will automatically create the method for NavigationFailed event for you. Otherwise, add this method:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
 &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MainFrame_NavigationFailed(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, System.Windows.Navigation.NavigationFailedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MainFrame.Navigate(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;"Error"&lt;/span&gt;, UriKind.Relative));&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Handle the exception&lt;/strong&gt;&lt;br /&gt;although the above code looks find and seems to be working, If you run it you get the following exception error:&lt;/p&gt;
&lt;p&gt;System.ArgumentException:&lt;br /&gt;Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.&lt;/p&gt;
&lt;p&gt;To fix this, you need to tell the Frame control (MainFrame) that this exception is being handled. So add this to your MainFrame_NavigationFailed method:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
e.Handled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now if you try to change the URL to a page that doesnt exist you should get to see the Error404.xml page.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using Child Window&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To do this using Child Window all we need to do is to show the Child Window which we had created before (for more information about creating and showing a Child Window see my post: &lt;a href="http://www.silverlighttips.com/post/2009/09/24/Passing-value-from-child-window-to-parent-window.aspx"&gt;Passing value from Child Window to parent window&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Create a new Child Window (ErrorPopup.xaml)&lt;/strong&gt;&lt;br /&gt;add this file to your Silverlight project. Since we could use this for other errors too I tried to called it something more generic.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Add error property and placeholder to ErrorPopup&lt;/strong&gt;&lt;br /&gt;Since we want to be able to pass different error message to our popup control in the future, we add a TextBlock in the ErrorPopup.xaml, and we also add a property to our control (in ErrorPopup.xaml.cs) to receive the error message and display it in the TextBlock.&lt;/p&gt;
&lt;p&gt;In ErrorPopup.xaml:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="Error"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In ErrorPopup.xaml.cs add a private member and control its value through the property:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
 &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _errorMessage;&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ErrorMessage &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _errorMessage; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _errorMessage = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now add the following code to ensure every time the ErrorPopup is loaded it displays the error message that it received through its property (ErrorMessage):&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ErrorPopup_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Error.Text = _errorMessage;&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Show ErrorPopup and pass an error message&lt;/strong&gt;&lt;br /&gt;in MainPage.xaml.cs create a private variable of type ErrorPopup:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; ErrorPopup errorPopup;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In Loaded or constructor method create a new instance of the errorPopup:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
errorPopup = &lt;span class="kwrd"&gt;new&lt;/span&gt; ErrorPopup(); &lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now you are ready to use the ErrorPopup every time needed within your application. So in your MainFrame_NavigationFailed method add the following code:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
errorPopup.ErrorMessage = &lt;span class="str"&gt;"Page you were trying to access could not be found."&lt;/span&gt;;&lt;br /&gt;errorPopup.Show(); &lt;/div&gt;&lt;/p&gt;
&lt;p&gt;don&amp;rsquo;t forget to keep e.Handled = true; in that method as otherwise you receive the exception error I explained above.&lt;/p&gt;
&lt;p&gt;Please note in the download from CodePlex I included both methods and just commented the display through Error404 template out by commenting out the MainFrame.Navigate function in the MainFrame_NavigationFailed method. Feel free to put that line back in and comment the other method out if you needed to.&lt;/p&gt;
&lt;p&gt;I personally prefer to you the ErrorPopup, but depending on your need you can user either of the two options I explained above.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/y_VqS1h2GO8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/y_VqS1h2GO8/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/12/04/Silverlight-Deep-Linking.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=6990d0e4-b986-43f3-ae67-650bdc330d97</guid>
      <pubDate>Fri, 04 Dec 2009 00:06:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=6990d0e4-b986-43f3-ae67-650bdc330d97</pingback:target>
      <slash:comments>61</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=6990d0e4-b986-43f3-ae67-650bdc330d97</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/12/04/Silverlight-Deep-Linking.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=6990d0e4-b986-43f3-ae67-650bdc330d97</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=6990d0e4-b986-43f3-ae67-650bdc330d97</feedburner:origLink></item>
    <item>
      <title>Silverlight RSS Part I (Simple RSS reader)</title>
      <description>&lt;div id="silverlightControlHost"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
// --&gt;&lt;/script&gt;
&lt;script src="http://www.silverlighttips.com/includes/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;object width="546" height="480" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://silverlighttips.com/includes/Silverlight_Simple_RSS.xap" /&gt;
&lt;param name="onError" value="onSilverlightError" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="3.0.40623.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40623.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" /&gt; &lt;/a&gt;
&lt;/object&gt;
&lt;span style="font-size:10px;"&gt;&lt;a href="http://feeds.feedburner.com/Silverlighttips"&gt;Latest posts&lt;/a&gt; from SilverlightTips.com&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;Displaying a RSS feed is a very straight forward task in Silverlight.&lt;/p&gt;
&lt;p&gt;In summary: we need to access and download the RSS (XML file) and read it as a single string value, read the downloaded string as XML using XmlReader class, load the XML into a variable of type SyndicationFeed, and finally using a loop extract each node and save it in a desirable variable.&lt;/p&gt;
&lt;p&gt;Some of the Silverlight built-in classes used in this example are:&lt;/p&gt;
&lt;table style="width: 546px;" border="0" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="125" valign="top"&gt;&lt;strong&gt;Uri:&lt;/strong&gt;&lt;/td&gt;
&lt;td style="padding-bottom:4px;" width="421" valign="top"&gt;Takes the URL of the RSS feed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;strong&gt;XmlReader:&lt;/strong&gt;&lt;/td&gt;
&lt;td style="padding-bottom:4px;" valign="top"&gt;Represents a reader that provides fast, non-cached, forward-only access to XML data&amp;rdquo; (&lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx" target="_blank"&gt;msdn&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;strong&gt;SyndicationFeed:&lt;/strong&gt;&lt;/td&gt;
&lt;td style="padding-bottom:4px;" valign="top"&gt;Represents a top-level feed object, &amp;lt;feed&amp;gt; in Atom 1.0 and &amp;lt;rss&amp;gt; in RSS 2.0&amp;rdquo; (&lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx" target="_blank"&gt;msdn&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;strong&gt;WebClient: &lt;/strong&gt;&lt;/td&gt;
&lt;td valign="top"&gt;Receives data from a recource defuned by Uri (in our case a URL to RSS or XML file)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I am going to demonstrate how to read and display a RSS feed (XML file) in three simple steps:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1: Create a custom RSS class&lt;/strong&gt;&lt;br /&gt;here I am just creating a new public class (RSSItem) for my RSS feed to contain any information I would like to keep for each item in the RSS. This will help to keep my project tidy and my code meaningful. In my RSSItem class I will add as many properties as I need:&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RSSItem&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="preproc"&gt;#region&lt;/span&gt; Properties&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; RSSTitle {get; set;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; RSSDescription { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; Uri RSSLink { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;strong&gt;Step 2: Reading the RSS feed in Silverlight&lt;/strong&gt;&lt;br /&gt;create three private variables for Uri, XmlReader and SyndicationFeed (for this you need to add a new reference in your project to System.ServiceModel.Syndication &amp;ndash; do this by right clicking on &amp;lsquo;References&amp;rsquo; folder in you Silverlight project and clicking on &amp;lsquo;Add Reference...&amp;rsquo;)&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; Uri rssUri;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; XmlReader xmlReader;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; SyndicationFeed feed;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;and don't forget to add the namespaces:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ServiceModel.Syndication;&lt;/div&gt;&lt;br /&gt;Now, in your constructor or &amp;lsquo;Loaded&amp;rsquo; method add the following:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
rssUri = &lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;"http://feeds.feedburner.com/Silverlighttips"&lt;/span&gt;);&lt;br /&gt;WebClient client = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;br /&gt;client.DownloadStringCompleted += &lt;span class="kwrd"&gt;new&lt;/span&gt; DownloadStringCompletedEventHandler(client_DownloadStringCompleted);&lt;br /&gt;client.DownloadStringAsync(rssUri);&lt;/div&gt;&lt;br /&gt;WebClient is another built-in class in Silverlight and is used to open the XML (RSS). Since the operation is done asynchronously the callback method (DownloadStringCompleted) is called after the operation is done.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3: Populate RSS nodes&lt;/strong&gt;&lt;br /&gt;first, add an ItemsControl in the MainPage.xaml:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="RSS"&lt;/span&gt; &lt;span class="attr"&gt;ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding}"&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;HyperlinkButton&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="Title"&lt;/span&gt; &lt;span class="attr"&gt;NavigateUri&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding RSSLink}"&lt;/span&gt;&lt;br /&gt;             &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="305"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,22,0,15"&lt;/span&gt; &lt;span class="attr"&gt;Foreground&lt;/span&gt;&lt;span class="kwrd"&gt;="#FF10589F"&lt;/span&gt; &lt;br /&gt;             &lt;span class="attr"&gt;FontSize&lt;/span&gt;&lt;span class="kwrd"&gt;="12"&lt;/span&gt; &lt;span class="attr"&gt;FontWeight&lt;/span&gt;&lt;span class="kwrd"&gt;="Bold"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;HyperlinkButton.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding RSSTitle}"&lt;/span&gt; &lt;span class="attr"&gt;TextWrapping&lt;/span&gt;&lt;span class="kwrd"&gt;="Wrap"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;HyperlinkButton.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;HyperlinkButton&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;In the ItemsControl we can bind the required properties from our RSSItem class using {Binding &lt;em&gt;nameOfProperty&lt;/em&gt;}.&lt;/p&gt;
&lt;p&gt;Now, from our DownloadStringCompleted method in MainPage.xaml.cs we can retrieve the RSS in form of a string. Then, we can create our XmlReader and load it to a SyndicationFeed variable which treats the XML as a 'RSS' and allow us to use its properties:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; client_DownloadStringCompleted(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, DownloadStringCompletedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (e.Error == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;int&lt;/span&gt; itemsCount = 5;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlReader = XmlReader.Create(&lt;span class="kwrd"&gt;new&lt;/span&gt; StringReader(e.Result));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feed = SyndicationFeed.Load(xmlReader);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;RSSItem&amp;gt; itemsList = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;RSSItem&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (feed.Items.Count() &amp;lt; 5)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemsCount = feed.Items.Count();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt;= itemsCount; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RSSItem rssitem = &lt;span class="kwrd"&gt;new&lt;/span&gt; RSSItem();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rssitem.RSSTitle = feed.Items.ToList()[i].Title.Text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rssitem.RSSLink = feed.Items.ToList()[i].Links[0].Uri;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemsList.Add(rssitem);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RSS.ItemsSource = itemsList;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;you will need to add the namespace for the StringReader:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In the above method from top:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;check if there are any errors in the result, if not continue&lt;/li&gt;
&lt;li&gt;set the number of items to read&lt;/li&gt;
&lt;li&gt;load the XML into a SyndicationFeed variable&lt;/li&gt;
&lt;li&gt;create a new List of type RSSItem to hold each RSSItem&lt;/li&gt;
&lt;li&gt;if the number of total RSS items to be found (itemsCount) is greater than the total number of RSS items available then go with the total number of available items&lt;/li&gt;
&lt;li&gt;search in each node for &amp;lsquo;Title&amp;rsquo; and &amp;lsquo;Summary&amp;rsquo; (description)&lt;/li&gt;
&lt;li&gt;add Title and Summary of each RSS item to the variable of type RSSItem class, and finally add the rssitem to the RSSItem list&lt;/li&gt;
&lt;li&gt;at the end we bind our itemsList to 'RSS' which is an ItemsControl in our XAML page&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/5HJkoOuYLc0" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/5HJkoOuYLc0/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/11/29/SilverlightSimpleRSS.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=ccc6e7ad-74bc-4984-86b1-06e6a48272af</guid>
      <pubDate>Sun, 29 Nov 2009 14:52:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=ccc6e7ad-74bc-4984-86b1-06e6a48272af</pingback:target>
      <slash:comments>85</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=ccc6e7ad-74bc-4984-86b1-06e6a48272af</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/11/29/SilverlightSimpleRSS.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=ccc6e7ad-74bc-4984-86b1-06e6a48272af</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=ccc6e7ad-74bc-4984-86b1-06e6a48272af</feedburner:origLink></item>
    <item>
      <title>Microsoft Silverlight 4 Beta is out!</title>
      <description>&lt;p&gt;&lt;img style="float: right;" src="http://silverlighttips.com/image.axd?picture=2009%2f11%2ficon_silverlight.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Today Microsoft released &lt;a href="http://silverlight.net/getstarted/silverlight-4-beta/" target="_blank"&gt;Silverlight 4.0 Beta&lt;/a&gt; version along with the SDK and tools for Visual Studio 2010 Beta 2 for software developers.&lt;/p&gt;
&lt;p&gt;there are great new features added to this version of Silverlight that enables Silverlight applications to provide 'rich interactive media experiences' to end users.&lt;/p&gt;
&lt;p&gt;Since most of these new features, such as, printing, webcam, clipboard access, right mouse click and drag and drop functionalities, are completely brand new and did not exist in previous versions of Silverlight, we will be going through them by posting tutorials and exemplas, and hopefully you will be able to play around with the demos here at Silverlight Tips website. So, make sure you have all requirements for developing on Silverlight 4.0 Beta on your computer.&lt;/p&gt;
&lt;p&gt;Resouces:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://silverlight.net/getstarted/silverlight-4-beta/" target="_blank"&gt;Microsoft Silverlight - getting started&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/myB4FYcPm7o" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/myB4FYcPm7o/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/11/18/Microsoft-Silverlight-4-beta.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=a96c73ef-97ee-4126-84c1-77f4b46fa963</guid>
      <pubDate>Wed, 18 Nov 2009 23:18:00 +0100</pubDate>
      <category>Silverlight News</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=a96c73ef-97ee-4126-84c1-77f4b46fa963</pingback:target>
      <slash:comments>27</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=a96c73ef-97ee-4126-84c1-77f4b46fa963</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/11/18/Microsoft-Silverlight-4-beta.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=a96c73ef-97ee-4126-84c1-77f4b46fa963</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=a96c73ef-97ee-4126-84c1-77f4b46fa963</feedburner:origLink></item>
    <item>
      <title>New authors on board</title>
      <description>&lt;p&gt;&lt;img style="float: left;" src="http://silverlighttips.com/image.axd?picture=2009%2f11%2fsilverlighttips.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;During the past two months or so I had been working on building Silverlight Tips website and managed to put up some useful Silverlight tutorials along with examples and demos. Just after a few weeks of the site's launch, it started receiving a great number of visits from around the world. The site received about 5000 visitors through this short period of time (2 months) and I must mention the comments I received from visitors were great and motivating. The site was picked up by major and minor search engines within the first two weeks and is now been featured on various great Silverlight and none-Silverlight websites including &lt;a href="http://silverlightshow.net" target="_blank"&gt;silverlightshow.net&lt;/a&gt;,&amp;nbsp; &lt;a href="http://www.silverlightcream.com/" target="_blank"&gt;silverlightcream.com&lt;/a&gt; and &lt;a href="http://www.silverlightbuzz.com/" target="_blank"&gt;silverlightbuzz.com&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Today, I am glad to announce Gavin Wignall, an Interactive Design Lead and owner of &lt;a href="http://www.silverlightbuzz.com/" target="_blank"&gt;Silverlight Buzz&lt;/a&gt; website, along with Allan Mullar, a Silverlight and WCF expert and owner of &lt;a href="http://www.silverlightforums.com/" target="_blank"&gt;Silverlight Forums&lt;/a&gt; website, have joined the site to publish their tutorials and tips on Silverlight Tips website, and help to build a great source of information and tutorials about Microsoft Silverlight by using their experiences and expertise in this field.&lt;br /&gt;&lt;br /&gt;I am looking forward to continue posting articles on Silverlight Tips and am most grateful to have Gavin and Allan on board.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/TC1rgrfkgy4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/TC1rgrfkgy4/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/11/09/new-authors.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=cb02da69-3d13-40f5-84d6-98f4317096dd</guid>
      <pubDate>Mon, 09 Nov 2009 09:18:00 +0100</pubDate>
      <category>Silverlight News</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=cb02da69-3d13-40f5-84d6-98f4317096dd</pingback:target>
      <slash:comments>13</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=cb02da69-3d13-40f5-84d6-98f4317096dd</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/11/09/new-authors.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=cb02da69-3d13-40f5-84d6-98f4317096dd</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=cb02da69-3d13-40f5-84d6-98f4317096dd</feedburner:origLink></item>
    <item>
      <title>Silverlight 3.0 validation – Part 1 validating TextBox</title>
      <description>&lt;div id="silverlightControlHost"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
// --&gt;&lt;/script&gt;
&lt;script src="http://www.silverlighttips.com/includes/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;object width="546" height="480" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://silverlighttips.com/includes/SilverlightValidation.xap" /&gt;
&lt;param name="onError" value="onSilverlightError" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="3.0.40623.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40623.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" /&gt; &lt;/a&gt;
&lt;/object&gt;
&lt;/div&gt;
&lt;p&gt;The built-in validation in Silverlight 3.0 is a great new feature that can be used on essential Silverlight controls such as TextBox. Using this feature, it is possible to nicely display an error message and highlight the TextBox that has bad value.&lt;/p&gt;
&lt;p&gt;In this post I will only cover validating data in TextBox controls, which are simply used in most forms to receive basic information such as Name, Surname and Email address. The completed and working version of this project can be downloaded from &lt;a href="http://codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt; from &lt;a href="http://validatesilverlight3.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;. I will explain and provide solution on how to validate ComboBox, Radio Button controls or etc in another post soon, so please keep yourself updated on new posts here.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Create a basic form with a few TextBox controls in the xaml&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Create a class, call it CustomValidation&lt;/strong&gt;&lt;br /&gt;Add the following code to your CustomValidation class:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; message; &lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; CustomValidation(&lt;span class="kwrd"&gt;string&lt;/span&gt; message)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;this&lt;/span&gt;.message = message;&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; ShowErrorMessage&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set; &lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; ValidationError&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (ShowErrorMessage)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ValidationException(message);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Create an Extension class (Extensions)&lt;/strong&gt;&lt;br /&gt;To understand what is an Extension class and for more information about them visit my tutorial post &amp;ldquo;&lt;a href="Extension methods in Silverlight and C#"&gt;Extension methods in Silverlight and C#&lt;/a&gt;&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;In brief: Extensions will be your Extension class to extend any object of type FrameworkElement like TextBox controls within your application framework. It means you can use the public methods within this class as a &amp;ldquo;built-in&amp;rdquo; method for your TextBox.&lt;/p&gt;
&lt;p&gt;Create a static public method and call it SetValidation. This method receives an instance of a FrameWorkElement and a string value, and returns nothing:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetValidation(&lt;span class="kwrd"&gt;this&lt;/span&gt; FrameworkElement frameworkElement, &lt;span class="kwrd"&gt;string&lt;/span&gt; message)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustomValidation customValidation = &lt;span class="kwrd"&gt;new&lt;/span&gt; CustomValidation(message);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Binding binding = &lt;span class="kwrd"&gt;new&lt;/span&gt; Binding(&lt;span class="str"&gt;"ValidationError"&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mode = System.Windows.Data.BindingMode.TwoWay,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NotifyOnValidationError = &lt;span class="kwrd"&gt;true&lt;/span&gt;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ValidatesOnExceptions = &lt;span class="kwrd"&gt;true&lt;/span&gt;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Source = customValidation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; frameworkElement.SetBinding(Control.TagProperty, binding);&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;CustomValidation is the class we defined earlier.&lt;/p&gt;
&lt;p&gt;"Binding" is a class in System.Windows.Data assembly which gets or sets a value that indicates whether to raise the error attached event on the bound object.&lt;/p&gt;
&lt;p&gt;What are we doing? Here we have a CustomValidation class that has one property ("ShowErrorMessage") and one public methods ("ValidationError"). "ValidationError" is our source binding object and what we want to be able to do in the future is to bind our frameworkElement, which is a TextBox, to ValidationError. We are in simple words binding the CustomValidation class to our TextBox once we call this method on our TextBox.&lt;/p&gt;
&lt;p&gt;For more information on Binding and BindingExpression visi msdn article &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.bindingexpression.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Create another two methods for displaying validation error and also for clearing validation error when the error was corrected:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RaiseValidationError(&lt;span class="kwrd"&gt;this&lt;/span&gt; FrameworkElement frameworkElement)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BindingExpression b = &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; frameworkElement.GetBindingExpression(Control.TagProperty);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (b != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((CustomValidation)b.DataItem).ShowErrorMessage = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.UpdateSource();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ClearValidationError(&lt;span class="kwrd"&gt;this&lt;/span&gt; FrameworkElement frameworkElement)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BindingExpression b = &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; frameworkElement.GetBindingExpression(Control.TagProperty);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (b != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((CustomValidation)b.DataItem).ShowErrorMessage = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.UpdateSource();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;By creating a new BindingExpression you will be creating an instance of your binding so you can control the properties and public methods of your binding source/target. In above case, we are casting the BindingExpression.DataItem as CustomValidation. This enables us to access the properties of this class, "ShowErrorMessage" in this case.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. RaiseValidationError() and ClearValidationError()&lt;/strong&gt;&lt;br /&gt;So now we have our TextBox, a method in our Extension class to bind the TextBox to our CustomValidation class and passes our error message, and a method in our Extension class that fires throw new ValidationException(message); from the CustomValidation class.&lt;/p&gt;
&lt;p&gt;All we need to do now is to check if a specific TextBox is valid or not. If the TextBox was not valid we can simply use the RaiseValidationError() and ClearValidationError() methods, which should now be available from the intellisense in Visual Studio, to throw the validation exception and display a suitable error message and we do that by following code when the submit button was pressed:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
Name.ClearValidationError();&lt;br /&gt;&lt;span class="kwrd"&gt;bool&lt;/span&gt; isFormValid = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (Name.Text == &lt;span class="str"&gt;""&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name.SetValidation(&lt;span class="str"&gt;"Please enter your name"&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name.RaiseValidationError();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; isFormValid = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;use isFormValid variable to check if you have to submit the form or not. The Name.ClearValidationError() makes sure you clear the form everytime you press submit, so if the form was valid the error message had already been cleaned.&lt;/p&gt;
&lt;p&gt;I have some extra validation extensions on this project and have organised the code in different class files. Download the project from &lt;a href="http://validatesilverlight3.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/NdSlKhOHILE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/NdSlKhOHILE/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/10/08/SilverlightValidationTextBox.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=e405b58d-0ffe-4345-8a78-03125091f109</guid>
      <pubDate>Thu, 08 Oct 2009 19:24:00 +0100</pubDate>
      <category>Advance</category>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=e405b58d-0ffe-4345-8a78-03125091f109</pingback:target>
      <slash:comments>82</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=e405b58d-0ffe-4345-8a78-03125091f109</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/10/08/SilverlightValidationTextBox.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=e405b58d-0ffe-4345-8a78-03125091f109</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=e405b58d-0ffe-4345-8a78-03125091f109</feedburner:origLink></item>
    <item>
      <title>Silverlight QueryString Validating ID, GUID and Timestamp (Date)</title>
      <description>&lt;p&gt;This post is very much a combination of my three previous posts (&lt;a href="http://silverlighttips.com/post/2009/09/30/Getting-QuerryString-values-in-Silverlight-using-TryParse.aspx"&gt;Silverlight QueryString using TryParse() method&lt;/a&gt;, &lt;a href="http://silverlighttips.com/post/2009/10/07/SilverlightGUID.aspx"&gt;Validate GUID in Silverlight &amp;ndash; Parse GUID in C#&lt;/a&gt; and &lt;a href="http://silverlighttips.com/post/2009/10/06/SilverlightExtension.aspx"&gt;Extension methods in Silverlight and C#&lt;/a&gt;) to demonstrate all these great features in one place. I have also added an &lt;a href="http://silverlighttips.com/?tag=/extension+methods"&gt;Extension method&lt;/a&gt; in this project to validate Date and Time using a simple Regular Expression, for better validation I suggest change the &lt;a href="http://silverlighttips.com/?tag=/regular+expressions"&gt;Regular Expression&lt;/a&gt; to match your specific needs.&lt;/p&gt;
&lt;p&gt;I am not explaining the code for this project as each part is explained in details in the posts I mentioned above, but please do feel free to ask any questions in the comment section below and I will try to answer as soon as I can.&lt;/p&gt;
&lt;p&gt;This project can be downloaded from &lt;a href="http://codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt; from &lt;a href="http://csharpquerrystring.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;, and feel free to play with the working version of it below.&lt;/p&gt;
&lt;div id="silverlightControlHost"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
// --&gt;&lt;/script&gt;
&lt;script src="http://www.silverlighttips.com/includes/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;object width="546" height="440" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://silverlighttips.com/includes/SilverlightQueryString.xap" /&gt;
&lt;param name="onError" value="onSilverlightError" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="3.0.40623.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40623.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" /&gt; &lt;/a&gt;
&lt;/object&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/lYU1Gs9gP2Y" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/lYU1Gs9gP2Y/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/10/07/SilverlightQueryString.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=bfceb93c-3529-4794-9c84-115a6448bd04</guid>
      <pubDate>Wed, 07 Oct 2009 18:57:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=bfceb93c-3529-4794-9c84-115a6448bd04</pingback:target>
      <slash:comments>25</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=bfceb93c-3529-4794-9c84-115a6448bd04</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/10/07/SilverlightQueryString.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=bfceb93c-3529-4794-9c84-115a6448bd04</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=bfceb93c-3529-4794-9c84-115a6448bd04</feedburner:origLink></item>
    <item>
      <title>Validate GUID in Silverlight – Parse GUID in C#</title>
      <description>&lt;p&gt;I have been looking around to find any built-in method to parse GUIDs in Silverlight, or to tell me if a value of type string is a valid GUID or not. After a few research I decided to create an Extension method to validate my GUID using Regular Expressions.&lt;/p&gt;
&lt;p&gt;You can read more about &lt;a href="http://silverlighttips.com/?tag=/extension+methods"&gt;Extension methods&lt;/a&gt; in Silverlight in my previous post &lt;a href="http://silverlighttips.com/post/2009/10/06/SilverlightExtension.aspx"&gt;here&lt;/a&gt;, but here I have a method to receive a string value and return true/false depending on if the sting value is a valid GUID or not. Anyway, here is what we can do to validate Silverlight GUID!&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsGUIDValid(&lt;span class="kwrd"&gt;string&lt;/span&gt; expression)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (expression != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Regex guidRegEx = &lt;span class="kwrd"&gt;new&lt;/span&gt; Regex(&lt;span class="str"&gt;@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; guidRegEx.IsMatch(expression);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/xrYyKeE1n6c" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/xrYyKeE1n6c/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/10/07/SilverlightGUID.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=ff076b6b-6605-4dab-8c81-812f3cdc2d78</guid>
      <pubDate>Wed, 07 Oct 2009 16:17:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=ff076b6b-6605-4dab-8c81-812f3cdc2d78</pingback:target>
      <slash:comments>28</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=ff076b6b-6605-4dab-8c81-812f3cdc2d78</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/10/07/SilverlightGUID.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=ff076b6b-6605-4dab-8c81-812f3cdc2d78</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=ff076b6b-6605-4dab-8c81-812f3cdc2d78</feedburner:origLink></item>
    <item>
      <title>Extension methods in Silverlight and C#</title>
      <description>&lt;p&gt;Extension methods are great way to add and use custom functionality on your objects.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So what is an Extension method?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In a short and simple describing: instead of creating a method that takes an instance of your object, applies your changes and then returns you the instance of that control, you can create an Extension method for that specific object to do the same thing but in a way of built-in within your object.&lt;/p&gt;
&lt;p&gt;Example: if we had a TextBox that needed to have a valid text input:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBox&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;=”&lt;span class="attr"&gt;InputEmail&lt;/span&gt;” &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;And you have:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;string&lt;/span&gt; inputEmail = InputEmail.Text; &lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You can do:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
If (inputEmail != &amp;ldquo;&amp;rdquo; &amp;amp;&amp;amp; ValidateEmail(inputEmail) == &lt;span class="kwrd"&gt;true&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; .&lt;br /&gt;&amp;nbsp;&amp;nbsp; .&lt;br /&gt;}&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; ValidateEmail(&lt;span class="kwrd"&gt;string&lt;/span&gt; getInputEmail)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; .&lt;br /&gt;&amp;nbsp;&amp;nbsp; .&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;or you can do it in a much cleaner and easier to understand way using &amp;ldquo;IsEmailValid&amp;rdquo; extension, which extends the string:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (inputEmail.IsEmailValid())&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;You can immediately notice from the above example that how much time and line of codes you will save by simply using Extensions instead of re-writing your custom methods to apply the same operation on a common object or element within a project that uses that feature in many places.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to add an Extension method to Silverilght objects?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First we need to add a new static class that contains a static method for our new Extension method (IsEmailValid).&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; FrameworkElementExtensionExtensions&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsEmailValid (&lt;span class="kwrd"&gt;this&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; getInputEmail)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;bool&lt;/span&gt; isMatched = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Regex regex = &lt;span class="kwrd"&gt;new&lt;/span&gt; Regex(&lt;span class="str"&gt;@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (getInputEmail != &amp;ldquo;&amp;rdquo; &amp;amp;&amp;amp; regex.IsMatch(s))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isMatched = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; regex.IsMatch(s);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;Note in the IsEmailValid method we used the keyword &amp;ldquo;this&amp;rdquo; before string getInputEmail, this simply means the IsEmailValid Extension method belongs to objects of type &amp;ldquo;string&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;To use the above extension method anywhere within your project, all you have to do is to import the reference to any of your classes, where you like the extension to be available, by adding &amp;ldquo;using FrameworkElementExtensionExtensions;&amp;rdquo; to that class.&lt;/p&gt;
&lt;p&gt;Now you should even get the IsEmailValid method in your Visual Studio Intellisense when you add a dot after any string variable. So now you could simply do:&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (inputEmail.IsEmailValid()){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HtmlPage.Window.Alert(&lt;span class="str"&gt;"Email was successfully submitted!"&lt;/span&gt;);&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;Above example was a very simple example, I will update the example solution regularly to include more advanced examples for you to use (copy &amp;amp; paste!) in the future, so please check this post later for updates. Also, this example, along with more examples in the future, is available to download from &lt;a href="http://codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt; from &lt;a href="http://silverlightextension.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/P9cBfQ2xQOU" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/P9cBfQ2xQOU/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/10/06/SilverlightExtension.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=350af8b5-3c7c-44a5-a9a0-dd475767cc11</guid>
      <pubDate>Tue, 06 Oct 2009 09:37:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=350af8b5-3c7c-44a5-a9a0-dd475767cc11</pingback:target>
      <slash:comments>79</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=350af8b5-3c7c-44a5-a9a0-dd475767cc11</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/10/06/SilverlightExtension.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=350af8b5-3c7c-44a5-a9a0-dd475767cc11</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=350af8b5-3c7c-44a5-a9a0-dd475767cc11</feedburner:origLink></item>
    <item>
      <title>Silverlight QueryString using TryParse() method</title>
      <description>&lt;p&gt;In order to get the value of your QueryString parameters from the URL all you need is this line of code:&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;int&lt;/span&gt; id = HtmlPage.Document.QueryString[&lt;span class="str"&gt;"ID"&lt;/span&gt;];&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And you need to add Windows.Browser namespace for HtmlPage class:&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Browser;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;However, there are always two situations which could break your application:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;if there are no &amp;ldquo;ID&amp;rdquo; parameters in the url&lt;/li&gt;
&lt;li&gt;if there is an &amp;ldquo;ID&amp;rdquo; parameter in the url, but it has a string value instead of an integer number.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To avoid breaking the code and causing runtime error we need to add a few conditions and also parse the value to integer instead of assigning it right away. We can use Int32.TryParse() method to test the value which we are about to assign to an integer variable before we actually do so, this way we will only assign it if it really is an integer:&lt;div class="code"&gt;
 &lt;span class="kwrd"&gt;int&lt;/span&gt; id = -1;&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (HtmlPage.Document.QueryString.ContainsKey(&lt;span class="str"&gt;"ID"&lt;/span&gt;))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;string&lt;/span&gt; queryStringValue = HtmlPage.Document.QueryString[&lt;span class="str"&gt;"ID"&lt;/span&gt;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (Int32.TryParse(queryStringValue, &lt;span class="kwrd"&gt;out&lt;/span&gt; id))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // the result was successful and&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // the correct ID will be inserted to id&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // the result was not successful&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;} &lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Using above method, you ensure the id gets assigned a value only if the ID parameter in the url has a valid integer value, or it will remain as -1 if the value was not an integer.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/pUCJX-RpCis" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/pUCJX-RpCis/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/30/GettingQueryStringTryParse.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=9bc22915-4a73-4e09-ab99-1962e99b892e</guid>
      <pubDate>Wed, 30 Sep 2009 22:30:00 +0100</pubDate>
      <category>Basic</category>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=9bc22915-4a73-4e09-ab99-1962e99b892e</pingback:target>
      <slash:comments>46</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=9bc22915-4a73-4e09-ab99-1962e99b892e</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/30/GettingQueryStringTryParse.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=9bc22915-4a73-4e09-ab99-1962e99b892e</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=9bc22915-4a73-4e09-ab99-1962e99b892e</feedburner:origLink></item>
    <item>
      <title>Learn Expression Blend in a Month!</title>
      <description>&lt;p&gt;Gavin Wignall at &lt;a href="http://www.silverlightbuzz.com/" target="_blank"&gt;Silverlight Buzz&lt;/a&gt; is doing a series of posts on his blog, aiming to cover the most useful information and techniques on Expression Blend for both beginners and pros. For more information, and to see the list of topics, which will be posted through the whole October, visit &lt;a href="http://www.silverlightbuzz.com/2009/09/26/learn-expression-blend-in-a-month/" target="_blank"&gt;Learn Expression Blend in a Month!&lt;/a&gt; at &lt;a href="http://www.silverlightbuzz.com/" target="_blank"&gt;SilverlightBuzz.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/3htzMgzC33Y" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/3htzMgzC33Y/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/30/Learn-Expression-Blend-in-a-Month!.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=24566964-c010-45d6-916f-b6a0ade2ecbe</guid>
      <pubDate>Wed, 30 Sep 2009 21:26:00 +0100</pubDate>
      <category>Silverlight News</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=24566964-c010-45d6-916f-b6a0ade2ecbe</pingback:target>
      <slash:comments>4</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=24566964-c010-45d6-916f-b6a0ade2ecbe</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/30/Learn-Expression-Blend-in-a-Month!.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=24566964-c010-45d6-916f-b6a0ade2ecbe</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=24566964-c010-45d6-916f-b6a0ade2ecbe</feedburner:origLink></item>
    <item>
      <title>How to display image using ImageBrush</title>
      <description>&lt;p&gt;
&lt;script type="text/javascript"&gt;&lt;!--
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
// --&gt;&lt;/script&gt;
&lt;script src="http://www.silverlighttips.com/includes/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;/p&gt;
&lt;p&gt;In this example I will demonstrate how to use ImageBrush to fill area of shapes like rectangle or ellipse with an image.&lt;/p&gt;
&lt;p&gt;In order to fill the area of a control like Rectangle control, we need to create an instance of type BitmapImage, and this is not possible if we do not have a Uri which points to a real image file.&lt;/p&gt;
&lt;p&gt;So first, I create an Uri pointing to an image which I had put in the &amp;ldquo;images&amp;rdquo; folder in my Silverlight application project.&lt;/p&gt;
&lt;p&gt;Hint: try to use Uri.TryCreate to create your Uri as by this way you stop your application from breaking if the path you gave your Uri was not valid or did not exist.&lt;/p&gt;
&lt;p&gt;Second, create a new instance of BitmapImage and assign your Uri to its value.&lt;div class="code"&gt;
Uri imageUri;&lt;br /&gt;BitmapImage image = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (Uri.TryCreate(&lt;span class="str"&gt;"images/SilverlightTips.jpg"&lt;/span&gt;, UriKind.RelativeOrAbsolute, &lt;span class="kwrd"&gt;out&lt;/span&gt; imageUri))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; image = &lt;span class="kwrd"&gt;new&lt;/span&gt; BitmapImage(imageUri);&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now you can create a new instance of ImageBrush and assign your created BitmapImage to its ImageSource value:&lt;div class="code"&gt;
ImageBrush imageBrush = &lt;span class="kwrd"&gt;new&lt;/span&gt; ImageBrush();&lt;br /&gt;imageBrush.ImageSource = image;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Finally, using .Fill method on your Rectangle control fill the entire rectangle (or any other shapes your object is) with your ImageBrush. And here is how your final code should look like:&lt;div class="code"&gt;
Uri imageUri;&lt;br /&gt;BitmapImage image = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (Uri.TryCreate(&lt;span class="str"&gt;"images/SilverlightTips.jpg"&lt;/span&gt;, UriKind.RelativeOrAbsolute, &lt;span class="kwrd"&gt;out&lt;/span&gt; imageUri))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; image = &lt;span class="kwrd"&gt;new&lt;/span&gt; BitmapImage(imageUri);&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (image != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ImageBrush imageBrush = &lt;span class="kwrd"&gt;new&lt;/span&gt; ImageBrush();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; imageBrush.ImageSource = image;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logo.Fill = imageBrush;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LogoEllipse.Fill = imageBrush;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LogoRectangle.Fill = imageBrush;&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Download this project from &lt;a href="http://codeplex.com/" target="_blank"&gt;CodePlex&lt;/a&gt; from &lt;a href="http://imagebrush.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;. Here it is working:&lt;/p&gt;
&lt;div id="silverlightControlHost"&gt;
&lt;object width="546" height="380" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://silverlighttips.com/SilverlightImageBrush.xap" /&gt;
&lt;param name="onError" value="onSilverlightError" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="3.0.40623.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40623.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" /&gt; &lt;/a&gt;
&lt;/object&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/vSdkV3ACtWc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/vSdkV3ACtWc/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/28/How-to-display-image-using-ImageBrush.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=47e92fa2-ac7f-49e5-aeba-894fa0b90fb4</guid>
      <pubDate>Mon, 28 Sep 2009 13:42:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=47e92fa2-ac7f-49e5-aeba-894fa0b90fb4</pingback:target>
      <slash:comments>39</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=47e92fa2-ac7f-49e5-aeba-894fa0b90fb4</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/28/How-to-display-image-using-ImageBrush.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=47e92fa2-ac7f-49e5-aeba-894fa0b90fb4</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=47e92fa2-ac7f-49e5-aeba-894fa0b90fb4</feedburner:origLink></item>
    <item>
      <title>Passing value from Child Window to parent window</title>
      <description>&lt;div id="silverlightControlHost"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null &amp;&amp; sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

            errMsg += "Code: "+ iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " +  args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
// --&gt;&lt;/script&gt;
&lt;script src="http://www.silverlighttips.com/includes/Silverlight.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;object width="546" height="440" data="data:application/x-silverlight-2," type="application/x-silverlight-2"&gt;
&lt;param name="source" value="http://silverlighttips.com/includes/SilverlightChilWindow.xap" /&gt;
&lt;param name="onError" value="onSilverlightError" /&gt;
&lt;param name="background" value="white" /&gt;
&lt;param name="minRuntimeVersion" value="3.0.40623.0" /&gt;
&lt;param name="autoUpgrade" value="true" /&gt; &lt;a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40623.0"&gt; &lt;img style="border-style:none" src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" /&gt; &lt;/a&gt;
&lt;/object&gt;
&lt;/div&gt;
&lt;p&gt;Silverlight Child Window is a great new feature which enables you to use advantage of a fully enhanced popup window. Child Window can be customized just like a normal xaml file to display or request information from the user. In this post I will explain briefly how receive and save information entered by user from a Child Window (ChildWindowForm.xaml in our example) and then display them in the parent window (MainPage.xam).&lt;/p&gt;
&lt;p&gt;I am going to create an example in which user enters his/her name and surname in a Child Window and once submitted different details, along with the entered name and surname, are displayed in the main page.&lt;/p&gt;
&lt;p&gt;I have uploaded the working example of this post to &lt;a href="https://www.codeplex.com" target="_blank"&gt;CodePlex&lt;/a&gt; and you can download it from &lt;a href="http://childwindow.codeplex.com/" target="_blank"&gt;here&lt;/a&gt; to test it for yourself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. add a new Child Window&lt;/strong&gt;&lt;br /&gt;in Visual Studio = right click on your Silverlight project, then, Add &amp;gt; New Item &amp;gt; Silverlight Child Window. The Child Window will have an OK and a Cancel button by default when it is created. Add two TextBox controls to the page for users to enter their name and surname.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Create an EventHandler in Child Window&lt;/strong&gt;&lt;br /&gt;code to create a new EventHandler:&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler SubmitClicked;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Create public properties to save the values&lt;/strong&gt;&lt;br /&gt;it is possible to access the value of the TextBox controls we added in the Child Window directly from the MainPage.xaml.cs, however, this is a terrible practice as it will reduces your code stability in the future. Therefore create two public properties of type string to save the value of both TextBox controls. You will notice in my project I save the value of the TextBox in a private string variable and then save that variable to my public &amp;ndash; this is just a better practice for coding so don&amp;rsquo;t get confused.&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; NameText&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _nameText; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _nameText = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SurnameText&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _surnameText; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _surnameText = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Fire the event once submit button is clicked in Child Window&lt;/strong&gt;&lt;br /&gt;there should already be a method for when the OK (Submit) button is pressed, it is called OKButton_Click. Inside that we need to fire the event which we created earlier, so that our event gets fired when the code reaches this method i.e. when we press OK in Child Window. &lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OKButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (SubmitClicked != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _nameText = Name.Text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _surnameText = Surname.Text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SubmitClicked(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; EventArgs());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;this&lt;/span&gt;.DialogResult = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;5. In MainPage.xaml create a new instance of the Child Window&lt;/strong&gt;&lt;br /&gt;in order to display your Child Window first create a private variable your Child Window type - what ever you called your Child Window file will be the type of your variable i.e. ChildWindowForm.xaml:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; ChildWindowForm childWindowForm;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;now create a new instance of it:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
childWindowForm = &lt;span class="kwrd"&gt;new&lt;/span&gt; ChildWindowForm();&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. How to show Child Window&lt;/strong&gt;&lt;br /&gt;you need to display the actual Child Window which you created and have the instance in your MainPage. To do that, use the instance you just created and call the build-in method for any Child Window called &amp;ldquo;Show&amp;rdquo;:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;
childWindowForm.Show();&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7. In MainPage.xaml hook up the submit event in Child Window&lt;/strong&gt;&lt;br /&gt;now we have an event which will get fired up from the Child Window when we click the submit button (OK button). All we have to do is to wire that event up so that we can do something when it is fired:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;
childWindowForm.SubmitClicked += &lt;span class="kwrd"&gt;new&lt;/span&gt;&lt;br /&gt;EventHandler(childWindowForm_SubmitClicked);&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;8. Access the properties of the Child Window&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; childWindowForm_SubmitClicked(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name.Text = childWindowForm.NameText;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Surname.Text = childWindowForm.SurnameText;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have skipped explaining some features that you will see in the example I created for this project (download from &lt;a href="http://childwindow.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;) to concentrate more on the subject of this post. However if you have any questions about this post or the example please do feel free to post your comments and I will try to help as much as I can.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/JoI_atnoWls" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/JoI_atnoWls/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/24/Passing-value-from-child-window-to-parent-window.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=f8e43d5e-afd1-42bd-badf-43d258d3601e</guid>
      <pubDate>Thu, 24 Sep 2009 21:27:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=f8e43d5e-afd1-42bd-badf-43d258d3601e</pingback:target>
      <slash:comments>81</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=f8e43d5e-afd1-42bd-badf-43d258d3601e</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/24/Passing-value-from-child-window-to-parent-window.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=f8e43d5e-afd1-42bd-badf-43d258d3601e</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=f8e43d5e-afd1-42bd-badf-43d258d3601e</feedburner:origLink></item>
    <item>
      <title>Add a global variable to Web.Config</title>
      <description>&lt;p&gt;You could use a variable globally in your .NET website if you declare it in your Web.config file.&lt;/p&gt;
&lt;p&gt;in your Web.config file find &amp;lt;appSettings&amp;gt; tag and insert your variables before it's closing tag:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&amp;lt;appSettings&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;add key=&lt;span class="str"&gt;"MyVariable1"&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;=&lt;span class="str"&gt;"False"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;add key=&lt;span class="str"&gt;"MyName"&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;=&lt;span class="str"&gt;"Damon Serji"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;lt;/appSetting&amp;gt;&lt;/p&gt;
&lt;p&gt;Now you can easily access &lt;span class="kwrd"&gt;this&lt;/span&gt; variable and its &lt;span class="kwrd"&gt;value&lt;/span&gt; from your C# code:&lt;/p&gt;
&lt;p&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; myVariable = System.Configuration.ConfigurationSettings.AppSettings[&lt;span class="str"&gt;"MyName"&lt;/span&gt;];&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;To break the above code down and to make sense of it: System really looks in your Web.Config file and the rest of the line becomes more obvious when you look at your Web.Config structure:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="UTF-8"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/.NetConfiguration/v2.0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configSections&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      .&lt;br /&gt;      .&lt;br /&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configSections&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;      &lt;br /&gt;      .&lt;br /&gt;     &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;appSettings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;       &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;key&lt;/span&gt;&lt;span class="kwrd"&gt;="MyVariable1"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="False"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;       &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;key&lt;/span&gt;&lt;span class="kwrd"&gt;="MyName"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="Damon Serji"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;appSetting&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;     .&lt;br /&gt;     .&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;So your Web.Config is nothing but a simple XML. System.Configuration tells the compiler to look in to &amp;lt;configuration&amp;gt; tag and System.Configuration.ConfigurationSettings.AppSettings tells it specifically to look into the &amp;lt;appSettings&amp;gt; tag. The result is a simple array of other tags which were added by you manually, so to find a specific tag you need to give it the index of the array i.e. an integer, or the "key" for that array, which is another way to find the tag you are looking for.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/MfDqNWcy-qc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/MfDqNWcy-qc/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/22/Add-a-global-variable-to-WebConfig.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=0a2a338f-2859-43b0-80f5-4233c65c08fb</guid>
      <pubDate>Tue, 22 Sep 2009 18:06:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=0a2a338f-2859-43b0-80f5-4233c65c08fb</pingback:target>
      <slash:comments>10</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=0a2a338f-2859-43b0-80f5-4233c65c08fb</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/22/Add-a-global-variable-to-WebConfig.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=0a2a338f-2859-43b0-80f5-4233c65c08fb</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=0a2a338f-2859-43b0-80f5-4233c65c08fb</feedburner:origLink></item>
    <item>
      <title>Adding meta tag to your site dynamically</title>
      <description>&lt;p&gt;meta tags contain useful information that could be used by user&amp;rsquo;s browser, search engine optimization, Java Script and etc. Some of the most common ones are "keyword" and "Description" meta tags which are used for better optimization.&lt;br /&gt;&lt;br /&gt;Changing/Adding these meta tags is particularly useful if you display different data according to user&amp;rsquo;s setting or your application setting, e.g. if you have more than one language and want to have a different keyword meta tag for each language.&lt;br /&gt;&lt;br /&gt;Here is how to add meta tags to your site programmatically:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
HtmlMeta htmlMeta = &lt;span class="kwrd"&gt;new&lt;/span&gt; HtmlMeta();&lt;br /&gt;htmlMeta.Name = &lt;span class="str"&gt;"keywords"&lt;/span&gt;;&lt;br /&gt;htmlMeta.Content = &lt;span class="str"&gt;"Tips, Silverlight Tips, SilverlightTips.com"&lt;/span&gt;;&lt;br /&gt;Page.Header.Controls.Add(htmlMeta);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Above code will generate the following code in your .aspx file:&lt;/p&gt;
&lt;p&gt;&lt;span class="HTML_TAG"&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;meta&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="keywords"&lt;/span&gt; &lt;span class="attr"&gt;content&lt;/span&gt;&lt;span class="kwrd"&gt;="Tips, Silverlight Tips, SilverlightTips.com"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/wN8qfDZaK9Q" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/wN8qfDZaK9Q/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/22/Adding-meta-tag-to-your-site-dynamically.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=c27cd546-9556-467f-88a6-80b1d2dfd2f3</guid>
      <pubDate>Tue, 22 Sep 2009 17:39:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=c27cd546-9556-467f-88a6-80b1d2dfd2f3</pingback:target>
      <slash:comments>6</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=c27cd546-9556-467f-88a6-80b1d2dfd2f3</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/22/Adding-meta-tag-to-your-site-dynamically.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=c27cd546-9556-467f-88a6-80b1d2dfd2f3</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=c27cd546-9556-467f-88a6-80b1d2dfd2f3</feedburner:origLink></item>
    <item>
      <title>How to call a JavaScript function from Silverlight</title>
      <description>&lt;p&gt;In order to call a function that you created in your .HTML or .ASPX file (which hosts your Silverlight application), you need to Invoke that function by using Invoke method in System.Windows.Browser.HtmlPage namespace:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
HtmlPage.Window.Invoke(&lt;span class="str"&gt;"yourFunction"&lt;/span&gt;);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If you want to pass some parameter to that function, simply add the parameters to the method using comma.&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
HtmlPage.Window.Invoke(&lt;span class="str"&gt;"yourFunction"&lt;/span&gt;, param1, param2);&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/BPbheT2AlRE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/BPbheT2AlRE/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/22/How-to-call-a-JavaScript-function-from-Silverlight.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=08928288-6ce6-4dfb-88d1-51c018e3dbcd</guid>
      <pubDate>Tue, 22 Sep 2009 17:29:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=08928288-6ce6-4dfb-88d1-51c018e3dbcd</pingback:target>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=08928288-6ce6-4dfb-88d1-51c018e3dbcd</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/22/How-to-call-a-JavaScript-function-from-Silverlight.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=08928288-6ce6-4dfb-88d1-51c018e3dbcd</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=08928288-6ce6-4dfb-88d1-51c018e3dbcd</feedburner:origLink></item>
    <item>
      <title>Silverlight localization</title>
      <description>&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f9%2fSilverlightLocalization.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;This post explains how to add localization to a Silverlight application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Adding a resource file (.resx) to your Silverlight project&lt;/strong&gt;&lt;br /&gt;first add a new folder to your Silverlight application and call it anything you like, i.e. LocResources, and then in your Visual Studio add a new Resource File in that folder: Add&amp;gt;New Item&amp;gt;(General category)Resources File. Then, add a new resource to your file, i.e. SiteTitle, and save it. While the resource file is opened, change the Access Modifier to Public (using the combo box).&lt;/p&gt;
&lt;p&gt;Now copy and paste the .resx file in your LocResources folder and rename the new file to &lt;em&gt;yourfilename&lt;/em&gt;&lt;strong&gt;.fr-FR&lt;/strong&gt;.resx.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Very important:&lt;/strong&gt; Open your &lt;em&gt;resourcefile&lt;/em&gt;.Designer.cs file and change the Constructor to public, i.e. open SiteContent.Designer.cs and change &lt;strong&gt;internal SiteContent()&lt;/strong&gt; to &lt;strong&gt;public SiteContent()&lt;/strong&gt;. This will allow your MainPage to have access to this file.&lt;/p&gt;
&lt;p&gt;A .resx file is really nothing but a XML file that contains your content in a format which can be used to localize your application, try opening the .resx file with Notepad to see it for yourself.&lt;/p&gt;
&lt;p&gt;Please note, you can call your .resx file anything you like, but unless it is the default language of your site it has to end with the local indicator characters, i.e. if it is French your file has to be called &lt;em&gt;name&lt;/em&gt;.fr-FR.resx&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Add a Resources namespace and a static resource&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;xmlns:MyResources="clr-namespace:name"&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Add the above namespace accordingly, where name is your Silverlight application name. Then add a static resource:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MyResources:SiteContent&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="SiteContent"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Replace the hardcoded text with Static Resources&lt;/strong&gt;&lt;br /&gt;update Silverlight controls to have the following format where they display text:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;Text="{Binding SiteTitle, Source={StaticResource SiteContent}}"&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;SiteTitle is the name of your resource data, you added this in step 1 in your resource file (.resx). SiteContent is the x:Name we gave to our reference of resource file which we created in step 2.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Update the .csproj file of your Silverlight project&lt;/strong&gt;&lt;br /&gt;open the .csproj file of your Silverlight project in Notepad, locate the SupportedCultures element, at the moment it should not have any value, you will need to change this to a different value if you were going to localize it for a different language than your default language, i.e. you would needed to change this to fr-FR if you were going to localize this for French language, so change this to &amp;lt;SupportedCultures&amp;gt;fr-FR&amp;lt;/SupportedCultures&amp;gt; then save and close the file.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. add InitParameters to the Silverlight control&lt;/strong&gt;&lt;br /&gt;open your &lt;em&gt;TestPage.aspx&lt;/em&gt; (the default page that hosts your Silverlight Control in your web application project), and add InitParameters="UICulture=fr-FR" in order to localize for French. If you are using Object tag add &amp;lt;param name="uiculture" value="fr-FR"/&amp;gt;, and if you are using &amp;lt;asp:Silverlight ... tag add this: InitParameters="UICulture=fr-FR" to your tag.&lt;/p&gt;
&lt;p&gt;6. Update App.xaml.cs&lt;br /&gt;copy the following code to the Application_Startup method:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;if&lt;/span&gt; (e.InitParams.Count &amp;gt; 0)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;string&lt;/span&gt; cultureName = e.InitParams[&lt;span class="str"&gt;"UICulture"&lt;/span&gt;].ToString();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(cultureName))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.CurrentThread.CurrentUICulture =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;new&lt;/span&gt; CultureInfo(cultureName);&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You may need to addthe following namespaces to the top of the page:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Threading;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Globalization;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Run and enjoy!&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/mM2Q4P1ZYyY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/mM2Q4P1ZYyY/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/15/Basic-Silverlight-localization.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=33fefd49-312a-44ef-bb03-67b8531e8a9c</guid>
      <pubDate>Tue, 15 Sep 2009 22:11:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=33fefd49-312a-44ef-bb03-67b8531e8a9c</pingback:target>
      <slash:comments>40</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=33fefd49-312a-44ef-bb03-67b8531e8a9c</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/15/Basic-Silverlight-localization.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=33fefd49-312a-44ef-bb03-67b8531e8a9c</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=33fefd49-312a-44ef-bb03-67b8531e8a9c</feedburner:origLink></item>
    <item>
      <title>Setting focus on ListBox items</title>
      <description>&lt;p&gt;The trick is to capture the selected index of the item which has been clicked, and then assign it back to the ListBox control by using .SelectedIndex method.&lt;/p&gt;
&lt;p&gt;The only thing I needed to do extra was to assign the .SelectedIndex to 0 before I assign it back to the actual selected index.&lt;/p&gt;
&lt;p&gt;Also, you will see in this example that I am capturing the selected index number on .MouseLeftButtonUp of TextBlocks which are my LibBox&amp;rsquo;s items, you could off course capture this information on .Click or . MouseLeftButtonUp of any other control in your ListBox items.&lt;br /&gt;You can download the working project from &lt;a title="Setting Focus on ListBox" href="http://focusonlistbox.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To test the project click on an item in the ListBox, then click on Loose Focus button, and then click on Focus button to bring the focus back to the ListBox.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/HbobnuINQHw" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/HbobnuINQHw/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/15/Setting-focus-on-ListBox-items.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=e375f049-0299-4ec5-9e47-9a7d20833997</guid>
      <pubDate>Tue, 15 Sep 2009 10:33:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=e375f049-0299-4ec5-9e47-9a7d20833997</pingback:target>
      <slash:comments>9</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=e375f049-0299-4ec5-9e47-9a7d20833997</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/15/Setting-focus-on-ListBox-items.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=e375f049-0299-4ec5-9e47-9a7d20833997</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=e375f049-0299-4ec5-9e47-9a7d20833997</feedburner:origLink></item>
    <item>
      <title>Setting the Z Index of a control from C#</title>
      <description>&lt;p&gt;To set the ZIndex of a Silverlight control programmatically use:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
Canvas.SetZIndex(_control, zIndex);&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Where &lt;em&gt;_control&lt;/em&gt; is your Silverlight control and &lt;em&gt;_zIndex&lt;/em&gt; is an integer number which you would like the new ZIndex of your control to be assigned to.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/-7BMJLu6qDg" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/-7BMJLu6qDg/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/12/Setting-the-Z-Index-of-a-control-programmatically-from-C.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=2fc791f5-cb54-4235-80a7-ce63395afffd</guid>
      <pubDate>Sat, 12 Sep 2009 16:55:00 +0100</pubDate>
      <category>Basic</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=2fc791f5-cb54-4235-80a7-ce63395afffd</pingback:target>
      <slash:comments>6</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=2fc791f5-cb54-4235-80a7-ce63395afffd</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/12/Setting-the-Z-Index-of-a-control-programmatically-from-C.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=2fc791f5-cb54-4235-80a7-ce63395afffd</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=2fc791f5-cb54-4235-80a7-ce63395afffd</feedburner:origLink></item>
    <item>
      <title>Changing VisualState of a control programmatically</title>
      <description>&lt;p&gt;How to change the state of a Silverlight control to go to a different VisualState in your VisualStateManager programmatically?&lt;/p&gt;
&lt;p&gt;Let's say you have a VisualStateManager in your Style which has TargetType="Button" and defines different VisualStates for different events, i.e. MouseOver, Pressed, Disabled and Normal. They of course work when you mouse hover the button or press it, but if you decided to force the button to change its state from the code here is the code you need:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
VisualStateManager.GoToState(_YourButton, &lt;span class="str"&gt;"Normal"&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/m8XdCnxg57A" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/m8XdCnxg57A/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/11/Changing-VisualState-of-a-control.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=591ba778-76bb-4f4e-91e8-888b7cb3a56f</guid>
      <pubDate>Fri, 11 Sep 2009 13:43:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=591ba778-76bb-4f4e-91e8-888b7cb3a56f</pingback:target>
      <slash:comments>17</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=591ba778-76bb-4f4e-91e8-888b7cb3a56f</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/11/Changing-VisualState-of-a-control.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=591ba778-76bb-4f4e-91e8-888b7cb3a56f</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=591ba778-76bb-4f4e-91e8-888b7cb3a56f</feedburner:origLink></item>
    <item>
      <title>Basic Silverlight Deep Linking</title>
      <description>&lt;p&gt;DeepLinking is one of the greatest features of Silverlight 3 in my opinion and this post will show you how to add Deep Linking to your Silverlight application in four simple steps:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Add Frame control in MainPage.xaml&lt;br /&gt;&lt;/strong&gt;Add System.Windows.Controls.Navigation in your project References and then a reference to navigation namespace to enable you adding the Frame control. &lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="SilverlightDeepLinking.MainPage"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:d&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;xmlns:mc&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;xmlns:Nav&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:System.Windows.Controls; &lt;br /&gt;               assembly=System.Windows.Controls.Navigation"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;mc:Ignorable&lt;/span&gt;&lt;span class="kwrd"&gt;="d"&lt;/span&gt; &lt;span class="attr"&gt;d:DesignWidth&lt;/span&gt;&lt;span class="kwrd"&gt;="546"&lt;/span&gt; &lt;span class="attr"&gt;d:DesignHeight&lt;/span&gt;&lt;span class="kwrd"&gt;="150"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="546"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="150"&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFC2CBD8"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Nav:Frame&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="MainFrame"&lt;/span&gt; &lt;span class="attr"&gt;UriMapper&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource uriMapper}"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;HorizontalContentAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt; &lt;span class="attr"&gt;VerticalContentAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Add URI Routing using UriMapper&lt;/strong&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Application&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;             &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;br /&gt;             &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="SilverlightDeepLinking.App"&lt;/span&gt;&lt;br /&gt;             &lt;span class="attr"&gt;xmlns:Nav&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:System.Windows.Navigation;&lt;br /&gt;             assembly=System.Windows.Controls.Navigation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Nav:UriMapper&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="uriMapper"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Nav:UriMapping&lt;/span&gt; &lt;span class="attr"&gt;Uri&lt;/span&gt;&lt;span class="kwrd"&gt;=""&lt;/span&gt; &lt;span class="attr"&gt;MappedUri&lt;/span&gt;&lt;span class="kwrd"&gt;="/HomePage.xaml"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Nav:UriMapping&lt;/span&gt; &lt;span class="attr"&gt;Uri&lt;/span&gt;&lt;span class="kwrd"&gt;="About"&lt;/span&gt; &lt;span class="attr"&gt;MappedUri&lt;/span&gt;&lt;span class="kwrd"&gt;="/About.xaml"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Nav:UriMapper&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Application&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Add your pages to the application&lt;/strong&gt;&lt;br /&gt;Here I have added a Homepage.xaml and About.xaml and added different content and color to them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Add navigation links to your MainPage.xaml&lt;br /&gt;&lt;/strong&gt;Since we have Homepage and About page, I am going to add to HyperlinkButtons on my MainPage.xaml in order to enable me browse to my two different pages. Please note, the Homepage and About pages will appear inside your &lt;em&gt;&amp;lt;Nav:Frame&lt;/em&gt; control, therefore we should have our navigation links i.e. on top/bottom and have the Frame in the middle, where the content will be displayed.&lt;/p&gt;
&lt;p&gt;Here is the MainPage.xaml after adding the HyperlinkButtons and adjusting the layout:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="546"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="150"&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFC2CBD8"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;HyperlinkButton&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="HomeLink"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Homepage"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,2,60,0"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="15"&lt;/span&gt; &lt;br /&gt;     &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="#009A480E"&lt;/span&gt; &lt;br /&gt;     &lt;span class="attr"&gt;Foreground&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFC55314"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;HyperlinkButton&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="AboutLink"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="About"&lt;/span&gt; &lt;br /&gt;     &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="60,2,0,0"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="15"&lt;/span&gt; &lt;br /&gt;     &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="attr"&gt;Foreground&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFC55314"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Nav:Frame&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="MainFrame"&lt;/span&gt; &lt;span class="attr"&gt;UriMapper&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource uriMapper}"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;HorizontalContentAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt; &lt;span class="attr"&gt;VerticalContentAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt; &lt;br /&gt;     &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,20,0,0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Add the code behind MainPage.xaml.cs&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; MainPage()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;this&lt;/span&gt;.Loaded += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(MainPage_Loaded);&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MainPage_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HomeLink.Click += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(HomeLink_Click);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AboutLink.Click += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(AboutLink_Click);&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AboutLink_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MainFrame.Navigate(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;"About"&lt;/span&gt;, UriKind.Relative));&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; HomeLink_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MainFrame.Navigate(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;""&lt;/span&gt;, UriKind.Relative));&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;When you click on the About link, you will navigate away from the current page, note the "#About" at the end of the URL.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f9%2fSilverlightDeepLinking1.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f9%2fSilverlightDeepLinking.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The complete project can be downloaded from &lt;a href="http://deeplinking.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32646" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/I8LR_qy4NTo" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/I8LR_qy4NTo/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/06/Basic-Silverlight-Deep-Linking.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=c9ec0199-9749-4589-bdd4-9181d1ef7028</guid>
      <pubDate>Sun, 06 Sep 2009 12:48:00 +0100</pubDate>
      <category>Basic</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=c9ec0199-9749-4589-bdd4-9181d1ef7028</pingback:target>
      <slash:comments>64</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=c9ec0199-9749-4589-bdd4-9181d1ef7028</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/06/Basic-Silverlight-Deep-Linking.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=c9ec0199-9749-4589-bdd4-9181d1ef7028</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=c9ec0199-9749-4589-bdd4-9181d1ef7028</feedburner:origLink></item>
    <item>
      <title>Create a Tooltip window with smart positioning</title>
      <description>&lt;p&gt;As well as demonstrating how to create a simple Tooltip control for your application, this post will also show you how to get/set the absolute position of a control in your application even if it is not a Canvas control.&lt;/p&gt;
&lt;p&gt;The idea of tooltip is really to display some information such as images or text, when you hover the mouse on a control, and hide when you hover out.&lt;/p&gt;
&lt;p&gt;To this, all we need to do is to change the Visibility of our control which contains that information to visible/collapse when the mouse if hovered/left.&lt;/p&gt;
&lt;p&gt;I am going to put my information in a separate xaml file called Tooltip.xaml.&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="SilverlightPositioningNoneCanvasControl.Tooltip"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="70"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="40"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="Pink"&lt;/span&gt;  &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="70"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="40"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="My Tooltip"&lt;/span&gt; &lt;span class="attr"&gt;Foreground&lt;/span&gt;&lt;span class="kwrd"&gt;="Chocolate"&lt;/span&gt; &lt;br /&gt;        &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I will then add a reference to the tooltip in my MainPage.xaml file with Visibility set to Collapsed.&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="SilverlightPositioningNoneCanvasControl.MainPage"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:local&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:SilverlightPositioningNoneCanvasControl"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:d&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;xmlns:mc&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt; &lt;br /&gt;    &lt;span class="attr"&gt;mc:Ignorable&lt;/span&gt;&lt;span class="kwrd"&gt;="d"&lt;/span&gt; &lt;span class="attr"&gt;d:DesignWidth&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt; &lt;span class="attr"&gt;d:DesignHeight&lt;/span&gt;&lt;span class="kwrd"&gt;="280"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="280"&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="Azure"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="tb_Tooltip"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Hover me"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="40"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="54"&lt;/span&gt; &lt;br /&gt;        &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="14"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Left"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="tb_Tooltip2"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Hover me"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="40"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="54"&lt;/span&gt; &lt;br /&gt;        &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="14"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Right"&lt;/span&gt;  &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Bottom"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;local:Tooltip&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="TooltipWindow"&lt;/span&gt; &lt;span class="attr"&gt;Visibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Collapsed"&lt;/span&gt; &lt;br /&gt;        &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Left"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now from my code behind (MainPage.xaml.cs) I can easily control the Visibility of my tooltip control by using MouseEnter and MouseLeave events.&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MainPage_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tb_Tooltip.MouseEnter += &lt;span class="kwrd"&gt;new&lt;/span&gt; MouseEventHandler(tb_tooltip_MouseEnter);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tb_Tooltip.MouseLeave += &lt;span class="kwrd"&gt;new&lt;/span&gt; MouseEventHandler(tb_Tooltip_MouseLeave);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tb_Tooltip2.MouseEnter += &lt;span class="kwrd"&gt;new&lt;/span&gt; MouseEventHandler(tb_tooltip_MouseEnter);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tb_Tooltip2.MouseLeave += &lt;span class="kwrd"&gt;new&lt;/span&gt; MouseEventHandler(tb_Tooltip_MouseLeave);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; tb_Tooltip_MouseLeave(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, MouseEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TooltipWindow.Visibility = Visibility.Collapsed;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; tb_tooltip_MouseEnter(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, MouseEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TooltipWindow.Visibility = Visibility.Visible;&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f9%2ftooltip.psd" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f9%2fnormalTooltip.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see from the screen shot above, the tooltip appears at the top left corner of the application if you hover your mouse on any of the "Hover me" text. So what I am going to do, is to capture the position of the "Hover me" text which the mouse is hovering, and make some calculations to workout where to display my tooltip window, and finally reposition my tooltip control before I set its visibility to Visible:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; tb_tooltip_MouseEnter(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, MouseEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TextBlock tb = sender &lt;span class="kwrd"&gt;as&lt;/span&gt; TextBlock;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GeneralTransform transform = tb.TransformToVisual(LayoutRoot);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Point position = transform.Transform(&lt;span class="kwrd"&gt;new&lt;/span&gt; Point(0, 0));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;double&lt;/span&gt; senderHeight = tb.ActualHeight;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;double&lt;/span&gt; senderWidth = tb.ActualWidth;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;double&lt;/span&gt; x = position.X;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;double&lt;/span&gt; y = position.Y;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;int&lt;/span&gt; gap = 3;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (x + TooltipWindow.Width + senderWidth + gap &amp;gt; LayoutRoot.ActualWidth)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = position.X - TooltipWindow.Width - gap;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = position.X + senderWidth + gap;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (position.Y + senderHeight + TooltipWindow.Height &amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LayoutRoot.ActualHeight)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = position.Y - TooltipWindow.Height + tb.Height / 2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = position.Y + tb.Height / 2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TooltipWindow.Margin = &lt;span class="kwrd"&gt;new&lt;/span&gt; Thickness(x, y, 0, 0);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TooltipWindow.Visibility = Visibility.Visible;&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;and the result for hovering on both "Hover me" text:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f9%2fSmartTooltip.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the tooltip is displayed on the bottom-right of the top-left text and on the top-left of the bottom text when you hover the mouse on them. This is done by some simple calculation and comparing the final X and Y positions to the Width and Height of the main application's container control, in this case a Grid called LayoutRoot.&lt;/p&gt;
&lt;p&gt;In order to get the coordinates of the "Hover me" text, I first had to have a transform object, so I used .TransformToVisual method and passed it the control that contains my TextBlock (LayoutRoot). I then used .Transform method to get the current position of my GeneralTransform opbject according to the very top left position of my LayoutRoot container.&lt;/p&gt;
&lt;p&gt;Finally I set the position of my tooltip by changing its margin with new X and Y values.&lt;/p&gt;
&lt;p&gt;Download the working version of the entire project from &lt;a href="http://smarttooltip.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/wGRL0zkv8r8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/wGRL0zkv8r8/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/09/01/Create-a-Tooltip-window-with-smart-positioning.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=16eada26-d514-433c-a703-213ec9ab9d33</guid>
      <pubDate>Tue, 01 Sep 2009 19:06:00 +0100</pubDate>
      <category>Basic</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=16eada26-d514-433c-a703-213ec9ab9d33</pingback:target>
      <slash:comments>36</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=16eada26-d514-433c-a703-213ec9ab9d33</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/09/01/Create-a-Tooltip-window-with-smart-positioning.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=16eada26-d514-433c-a703-213ec9ab9d33</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=16eada26-d514-433c-a703-213ec9ab9d33</feedburner:origLink></item>
    <item>
      <title>How to find individual items in list-based controls</title>
      <description>&lt;p&gt;this post will give you answer to below questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to find/target a Silverlight control which was added through a DataTemplate of a &lt;span id="main" style="visibility: visible;"&gt;&lt;span id="search" style="visibility: visible;"&gt;list-based&lt;/span&gt;&lt;/span&gt; control such as ItemsControl, ComboBox, ListBox or etc.&lt;/li&gt;
&lt;li&gt;Use Tag property in Silverlight controls to identify different items&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In order to identify different controls in your ItemsControl, you could assign a unique identifier (ID) to each control through the "Tag" property.&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ListBox&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="lb_test"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="200"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="200"&lt;/span&gt; &lt;br /&gt;         &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Top"&lt;/span&gt; &lt;span class="attr"&gt;ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding}"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="190"&lt;/span&gt; &lt;span class="attr"&gt;Tag&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Id}"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Name}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ListBox&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Code behind for adding the data:&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MainPage_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;Items&amp;gt; itemsList = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Items&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Items it = &lt;span class="kwrd"&gt;new&lt;/span&gt; Items();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; it.Name = &lt;span class="str"&gt;"Damon"&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; it.Id = 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemsList.Add(it);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Items it2 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Items();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; it2.Name = &lt;span class="str"&gt;"Allan"&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; it2.Id = 2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemsList.Add(it2);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Items it3 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Items();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; it3.Name = &lt;span class="str"&gt;"Rachel"&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; it3.Id = 3;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemsList.Add(it3);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lb_test.ItemsSource = itemsList;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;Create a new class called Items to store Name and Id&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Items&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name {get; set;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Id { get; set; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;and the result:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://silverlighttips.com/image.axd?picture=2009%2f9%2fListBox.gif" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now we need to find items inside the ListBox control and apply whatever code we want to them. Here I am going to find the TextBlock for Allan thought the ID I gave it (2) and add an MouseLeftButtonUp event to it, so when we click on Allan we get an alert popup.&lt;/p&gt;
&lt;p&gt;First thing we need to do is to add the following line to the end of our MainPage_Loaded method (after the ItemsSource of our ListBox is assigned):&lt;br /&gt;&lt;div class="code"&gt;
CompositionTarget.Rendering += &lt;span class="kwrd"&gt;new&lt;/span&gt; EventHandler(CompositionTarget_Rendering);&lt;/div&gt;&lt;br /&gt;Above line will re-render you layout to force any updates you have done after your xaml was initially rendered.&lt;/p&gt;
&lt;p&gt;And here is the method that is called through the above code:&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CompositionTarget_Rendering(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddEventHandlers(lb_test, -1);&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And finally the method to find the TexBlock we are looking for, and adding the EventHandler:&lt;br /&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddEventHandlers(DependencyObject parent, &lt;span class="kwrd"&gt;int&lt;/span&gt; childIndex)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DependencyObject child;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TextBlock textBlock;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;int&lt;/span&gt; childrenCount = VisualTreeHelper.GetChildrenCount(parent);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (parent == lb_test &amp;amp;&amp;amp; childrenCount &amp;gt; 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompositionTarget.Rendering -= CompositionTarget_Rendering;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; index = 0; index &amp;lt; childrenCount; index++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; child = VisualTreeHelper.GetChild(parent, index);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (child &lt;span class="kwrd"&gt;is&lt;/span&gt; TextBlock)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textBlock = (TextBlock)child;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (textBlock.Tag != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;int&lt;/span&gt; id = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)textBlock.Tag;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (id == 2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textBlock.MouseLeftButtonUp +=&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;new&lt;/span&gt; MouseButtonEventHandler(textBlock_MouseLeftButtonUp);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textBlock.Foreground = &lt;span class="kwrd"&gt;new&lt;/span&gt; SolidColorBrush(Colors.Green);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (child &lt;span class="kwrd"&gt;is&lt;/span&gt; ContentPresenter)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddEventHandlers(child, index);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddEventHandlers(child, childIndex);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; textBlock_MouseLeftButtonUp(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender&lt;br /&gt;, MouseButtonEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TextBlock tb = sender &lt;span class="kwrd"&gt;as&lt;/span&gt; TextBlock;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt; (tb != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Browser.HtmlPage.Window.Alert(tb.Text + &lt;span class="str"&gt;" was&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clicked!"&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In summary, we are passing the x:Name of our ListBox "parent" to the AddEventHandlers and search in its children for any TextBlock controls. If we didn&amp;rsquo;t find any TextBlock we search in any other searchable controls we find inside that and we do that again until we find all TextBlocks or there is no more controls to search within.&lt;/p&gt;
&lt;p&gt;When we find a TextBlock, we check if it has a Tag property and if the value is what we were looking for, if true, we simply add or EventHandler, change color, or do anything we want to do to that TextBlock.&lt;/p&gt;
&lt;p&gt;Download the working version of the entire project from &lt;a href="http://listbasedcontrols.codeplex.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/QG_e9gPw8O0" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/QG_e9gPw8O0/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/08/30/How-to-find-individual-items-in-list-based-controls.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=b56a98ec-7897-4e73-8600-e9b9344e53b1</guid>
      <pubDate>Sun, 30 Aug 2009 20:02:00 +0100</pubDate>
      <category>Intermediate</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=b56a98ec-7897-4e73-8600-e9b9344e53b1</pingback:target>
      <slash:comments>23</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=b56a98ec-7897-4e73-8600-e9b9344e53b1</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/08/30/How-to-find-individual-items-in-list-based-controls.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=b56a98ec-7897-4e73-8600-e9b9344e53b1</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=b56a98ec-7897-4e73-8600-e9b9344e53b1</feedburner:origLink></item>
    <item>
      <title>Adding 'mailto' link</title>
      <description>&lt;p&gt;&lt;img style="FLOAT: left" src="http://silverlighttips.com/image.axd?picture=2009%2f8%2fat-sign.jpg" alt="" /&gt;How to programmatically add a 'mailto' link in silverlight:&lt;br /&gt;&lt;br /&gt;Add the below line to your .xaml.cs file to open mailto (email link) when an event gets fired (i.e. HyperlinkButton is clicked or etc):&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;
HtmlPage.Window.Navigate(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;"mailto:tips@silverlighttips.com"&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;if HtmlPage is not recognised in your Visual Studio, it is because you are missing an assemblly reference, so simply add this reference to the very top of your page:&lt;/p&gt;
&lt;p&gt;&lt;div class="code"&gt;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Browser;&lt;/div&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Silverlighttips/~4/M_6m2e5iAkc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/Silverlighttips/~3/M_6m2e5iAkc/post.aspx</link>
      <author>damon</author>
      <comments>http://silverlighttips.com/post/2009/08/24/Adding-mailto-link.aspx#comment</comments>
      <guid isPermaLink="false">http://silverlighttips.com/post.aspx?id=943701e1-eb63-4669-99a2-6cd8602e917b</guid>
      <pubDate>Mon, 24 Aug 2009 16:44:00 +0100</pubDate>
      <category>Basic</category>
      <dc:publisher>damon</dc:publisher>
      <pingback:server>http://silverlighttips.com/pingback.axd</pingback:server>
      <pingback:target>http://silverlighttips.com/post.aspx?id=943701e1-eb63-4669-99a2-6cd8602e917b</pingback:target>
      <slash:comments>106</slash:comments>
      <trackback:ping>http://silverlighttips.com/trackback.axd?id=943701e1-eb63-4669-99a2-6cd8602e917b</trackback:ping>
      <wfw:comment>http://silverlighttips.com/post/2009/08/24/Adding-mailto-link.aspx#comment</wfw:comment>
      <wfw:commentRss>http://silverlighttips.com/syndication.axd?post=943701e1-eb63-4669-99a2-6cd8602e917b</wfw:commentRss>
    <feedburner:origLink>http://silverlighttips.com/post.aspx?id=943701e1-eb63-4669-99a2-6cd8602e917b</feedburner:origLink></item>
  </channel>
</rss>
