<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.devlifestyle.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Articles</title><link>http://www.devlifestyle.net/blogs/articles/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Devlifestyle May 2011 Event Materials</title><link>http://www.devlifestyle.net/blogs/articles/archive/2011/05/04/devlifestyle-may-2011-event-materials.aspx</link><pubDate>Thu, 05 May 2011 05:12:00 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1174</guid><dc:creator>Mohamad Halabi</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1174</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2011/05/04/devlifestyle-may-2011-event-materials.aspx#comments</comments><description>&lt;p&gt;WCF Session (by Mohamad Halabi): &lt;a href="http://www.devlifestyle.net/media/p/1173/download.aspx"&gt;http://www.devlifestyle.net/media/p/1173/download.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1174" width="1" height="1"&gt;</description></item><item><title>Silverlight 4.0 Tutorial (10 of N): Working with the PathListBox</title><link>http://www.devlifestyle.net/blogs/articles/archive/2011/02/19/silverlight-4-0-tutorial-10-of-n-working-with-the-pathlistbox.aspx</link><pubDate>Sat, 19 Feb 2011 09:34:47 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1168</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1168</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2011/02/19/silverlight-4-0-tutorial-10-of-n-working-with-the-pathlistbox.aspx#comments</comments><description>&lt;p&gt;Continuing our RegistrationBooth Application, In this post we will make a change to the way we display the list of attendees. Currently we display them in a standard ListBox, we will replace this with a PathListBox, the PathListBox is a new customized control that comes with Blend SDK.&lt;/p&gt;  &lt;p&gt;From its name this control is a list box however its elements are placed on whatever path you draw so instead of having our attendees placed vertically in the ListBox we will have our attendees placed along the path we will draw, let’s start by deleting the existing ListBox.&lt;/p&gt;  &lt;p&gt;First thing is to draw the path on which we will display the attendees, we will draw a big arc and place it in the left corner, drag an arc shape from the assets window&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_72CB82EE.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Drawing an arc" border="0" alt="Drawing an arc" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_62DC3E2A.png" width="360" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Drop it on the left column and set the StartAngle to 0 and the EndAngle to 180 to make the arc like a half ellipse&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_490807FB.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="2" border="0" alt="2" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_0F84F804.png" width="204" height="425" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To convert this into a PathListBox, right click on the arc and select Path-&amp;gt;Make Layout Path&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_41106599.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Make Layout Path" border="0" alt="Make Layout Path" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_40A432A4.png" width="435" height="138" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;A PathListBox will be added to the page, rename it to lstAttendees&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_1C12A520.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="the attendees PathListBox" border="0" alt="the attendees PathListBox" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_6DB91F72.png" width="280" height="63" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We will bind the &lt;em&gt;ItemsSource&lt;/em&gt; property of the PathListBox to our attendees DomainDataSource control &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_6D4CEC7D.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Binding the ItemsSource property" border="0" alt="Binding the ItemsSource property" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_3A7CE609.png" width="484" height="453" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Next we will change the &lt;em&gt;ItemTemplate &lt;/em&gt;property, we already have a DataTemplate defined for the attendees in the local resources, so we will bind to this template&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_31ACDDBD.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Bindin the ItemTemplate" border="0" alt="Bindin the ItemTemplate" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_thumb_5F00_3140AAC8.png" width="371" height="170" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We will also set the &lt;em&gt;Capacity &lt;/em&gt;property to 4, this property determines the number of items shown on the Path. &lt;/p&gt;  &lt;p&gt;Set the &lt;em&gt;Start&lt;/em&gt; property to 20%, this property determines the distance from the start of the Layout Path to place the first item.&lt;/p&gt;  &lt;p&gt;Set the &lt;em&gt;Span &lt;/em&gt;property to 80%, this property determines the percentage of the Layout Path that participates in layout.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_57A28E13.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="LayoutPath Properties" border="0" alt="LayoutPath Properties" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_thumb_5F00_4244D8AB.png" width="340" height="386" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Let’s run the application and see what we have till now, you will see 4 attendees placed over the layout path we created.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_01A28C3C.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="The list of attendees placed over the arc" border="0" alt="The list of attendees placed over the arc" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_thumb_5F00_7F195A7D.png" width="421" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To see the rest of the attendees we need to add scrolling to the PathListBox, this will require some coding but Luckily for us the Expression Blend team has already done this in the PathListBoxUtils library which is a collection of behaviors, controls and extensions for the PathListBox, you can download it from the &lt;a href="http://expressionblend.codeplex.com/" target="_blank"&gt;Expression Blend Codeplex site&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;First we will add two buttons one above the PathListBox we will name it &lt;em&gt;BackButton &lt;/em&gt;and one below the PathListBox we will name it &lt;em&gt;ForwardButton. &lt;/em&gt;we need to wire these two buttons to move backward/forward through the PathListBox items. to do this we will use a behavior that comes with the &lt;em&gt;PathListBoxUtils &lt;/em&gt;library.&lt;/p&gt;  &lt;p&gt;Drag the &lt;em&gt;PathListBoxScrollBehavior &lt;/em&gt;and drop it over our PathListBox&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_63282585.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="PathListBoxScrollBehavior" border="0" alt="PathListBoxScrollBehavior" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_thumb_5F00_696EFC13.png" width="436" height="190" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;From the properties of the &lt;em&gt;PathListBoxScrollBehavior &lt;/em&gt;add an &lt;em&gt;EventTrigger&lt;/em&gt; for the &lt;em&gt;DecrementCommand, &lt;/em&gt;set the &lt;em&gt;SourceObject &lt;/em&gt;to the &lt;em&gt;BackButton &lt;/em&gt;and set the &lt;em&gt;EventName &lt;/em&gt;to &lt;em&gt;Click.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_01FE9964.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="PathListBoxScrollBehavior DecrementCommand" border="0" alt="PathListBoxScrollBehavior DecrementCommand" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_thumb_5F00_2F7FB927.png" width="337" height="208" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Add an &lt;em&gt;EventTrigger&lt;/em&gt; for the &lt;em&gt;IncrementCommand, &lt;/em&gt;set the &lt;em&gt;SourceObject &lt;/em&gt;to the &lt;em&gt;ForwardButton &lt;/em&gt;and set the &lt;em&gt;EventName &lt;/em&gt;to &lt;em&gt;Click.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_1A2203BF.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="PathListBoxScrollBehavior IncrementCommand" border="0" alt="PathListBoxScrollBehavior IncrementCommand" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_thumb_5F00_19B5D0CA.png" width="336" height="204" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Add an &lt;em&gt;EventTrigger&lt;/em&gt; for the &lt;em&gt;ScrollSelectedCommand, &lt;/em&gt;set the &lt;em&gt;EventName &lt;/em&gt;to &lt;em&gt;SelectionChanged.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/12_5F00_4736F08D.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="PathListBoxScrollBehavior ScrollSelectedCommand" border="0" alt="PathListBoxScrollBehavior ScrollSelectedCommand" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/12_5F00_thumb_5F00_3FAB8120.png" width="337" height="208" /&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;We will associate an easing function with this behavior so that the scrolling looks more fancy.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/13_5F00_06287129.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Easing function" border="0" alt="Easing function" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/13_5F00_thumb_5F00_05BC3E34.png" width="339" height="178" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Run the application and click the forward button to see the scrolling in action&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/14_5F00_4519F1C4.png" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="PathListBox scrolling" border="0" alt="PathListBox scrolling" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/14_5F00_thumb_5F00_14A36D4E.png" width="304" height="344" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can download the source code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-10.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;See you in the next post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1168" width="1" height="1"&gt;</description></item><item><title>Silverlight 4.0 Tutorial (11 of N): Roulette Behavior</title><link>http://www.devlifestyle.net/blogs/articles/archive/2011/02/19/silverlight-4-0-tutorial-11-of-n-roulette-behavior.aspx</link><pubDate>Sat, 19 Feb 2011 09:33:01 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1167</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1167</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2011/02/19/silverlight-4-0-tutorial-11-of-n-roulette-behavior.aspx#comments</comments><description>&lt;p&gt;Continuing our RegistrationBooth Application… &lt;/p&gt;  &lt;p&gt;In most of the offline events we hold, there are some giveaways for the audience (most of the time the prize is XBOX). Picking a winner is manual process where we collect the feedback forms, put it in a big box/bag, shake the box/bag and turn it upside down multiple times to make sure that the forms are scrambled enough so that when we pick a form it will be a random one &lt;img style="border-bottom-style:none;border-left-style:none;border-top-style:none;border-right-style:none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/wlEmoticon_2D00_smile_5F00_2607E687.png" /&gt;, not the best process I know.&lt;/p&gt;  &lt;p&gt;So in this post we will add to our RegistrationBooth application the ability to perform a random draw. we already have our attendees listed in a &lt;em&gt;PathListBox&lt;/em&gt;, wouldn’t it be nice if this list can spin like a roulette till it stops at the lucky winner, let’s see how we can implement this. I thought it’s better if we implement this feature as a behavior so that we can easily apply it to any &lt;em&gt;PathListBox&lt;/em&gt;, I will call this behavior &lt;strong&gt;RouletteBehavior&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;To create a behavior we need to derive from the abstract class &lt;em&gt;Bahavior&amp;lt;T&amp;gt;&lt;/em&gt; available in the System.Windows.Interactivity assembly, where T is the control or UI Element that you will attach this behavior to. in our case our behavior will derive from &lt;strong&gt;Bahavior&amp;lt;PathListBox&amp;gt;&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6762bcaf-710a-4740-ade7-dc50597dd674" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RouletteBehavior&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;Behavior&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;PathListBox&lt;/span&gt;&amp;gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    {&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;What properties this behavior will expose? first there should be a way to start the roulette, for maximum usability we will add a property &lt;strong&gt;StartCommand&lt;/strong&gt; of type &lt;em&gt;ICommand&lt;/em&gt;, so that users of this behavior can use any type of trigger to start the roulette&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e0962ef-48e6-4829-aed8-ae5b37c5f8e7" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; Gets a command that starts the roulette animation.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ICommand&lt;/span&gt; StartCommand&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;We need another property to determine how long the roulette will spin, so we will add a property &lt;strong&gt;Duration &lt;/strong&gt;of type &lt;em&gt;Duration&lt;/em&gt;, I will make this property a &lt;em&gt;DependencyProperty&lt;/em&gt; to make it open for any advanced scenario that the users of this behavior might want to implement. &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4964a5d4-9a7b-4711-93fd-c5c89578bce1" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;      &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; Gets or sets the approximate duration of the roulette.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;      &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Duration&lt;/span&gt; Duration&lt;/li&gt; &lt;li&gt;      {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;          &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;Duration&lt;/span&gt;)&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.GetValue(&lt;span style="color:#2b91af;"&gt;RouletteBehavior&lt;/span&gt;.DurationProperty); }&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.SetValue(&lt;span style="color:#2b91af;"&gt;RouletteBehavior&lt;/span&gt;.DurationProperty, &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;); }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;      }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;      &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DependencyProperty&lt;/span&gt; DurationProperty =&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#2b91af;"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color:#a31515;"&gt;&amp;quot;Duration&amp;quot;&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;Duration&lt;/span&gt;), &lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;RouletteBehavior&lt;/span&gt;), &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;          &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PropertyMetadata&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Duration&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TimeSpan&lt;/span&gt;(0, 0, 1))));&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;To be able to customize the spinning speed we will expose a property called &lt;strong&gt;Speed&lt;/strong&gt; (of type &lt;em&gt;integer&lt;/em&gt;) that determines the speed of spinning it terms of items/second&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:547b317a-78f1-4c81-a081-c52c92dd6a85" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; Gets or sets the speed of the roulette (Items/Sec).&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; Speed&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;)&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.GetValue(&lt;span style="color:#2b91af;"&gt;RouletteBehavior&lt;/span&gt;.SpeedProperty); }&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.SetValue(&lt;span style="color:#2b91af;"&gt;RouletteBehavior&lt;/span&gt;.SpeedProperty, &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;); }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DependencyProperty&lt;/span&gt; SpeedProperty =&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color:#a31515;"&gt;&amp;quot;Speed&amp;quot;&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;), &lt;span style="color:#0000ff;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;RouletteBehavior&lt;/span&gt;), &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PropertyMetadata&lt;/span&gt;(5));&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;There are two protected method that we need to override, &lt;strong&gt;OnAttached&lt;/strong&gt; and &lt;strong&gt;OnDetaching &lt;/strong&gt;these methods are called when attaching and detaching the behavior to a &lt;em&gt;PathListBox&lt;/em&gt;, the &lt;strong&gt;AssociatedObject&lt;/strong&gt; property of the Behavior gives you access to the &lt;em&gt;PathListBox&lt;/em&gt; you are attaching the behavior to, so what we do is we change the &lt;strong&gt;WrapItems&lt;/strong&gt; property of the &lt;em&gt;PathListBox &lt;/em&gt;when attaching the behavior and we set it back to the original value when detaching the behavior&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:25e8d5fd-a6cf-42cd-8355-6a869fc9872d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnAttached()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;base&lt;/span&gt;.OnAttached();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    _originalWrapItems = AssociatedObject.WrapItems;&lt;/li&gt; &lt;li&gt;    AssociatedObject.WrapItems = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;}&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnDetaching()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;base&lt;/span&gt;.OnDetaching();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    AssociatedObject.WrapItems = _originalWrapItems;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;To create the spinning animation we will need a storyboard, so we will add a member variable of type &lt;em&gt;Storyboard&lt;/em&gt; to our behavior class and in the constructor we will initialize the storyboard and attach a method called &lt;strong&gt;StartRoulette&lt;/strong&gt; to the &lt;strong&gt;StartCommand&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:71e37783-aa11-45bf-9490-09cc184ffa7e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; RouletteBehavior()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.StartCommand = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ActionCommand&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.StartRoulette);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.rouletteAnimationStoryboard = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Storyboard&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The &lt;em&gt;&lt;strong&gt;StartRoulette&lt;/strong&gt;&lt;/em&gt; method contains the logic for animating the &lt;em&gt;PathListBox&lt;/em&gt; items, we do this by creating a &lt;em&gt;DoubleAnimation&lt;/em&gt; to animate the &lt;strong&gt;Start&lt;/strong&gt; property of the LayoutPath of the &lt;em&gt;PathListBox&lt;/em&gt; (currently this behavior supports only one layout path), based on the list items count, the &lt;strong&gt;Speed&lt;/strong&gt; property, the &lt;strong&gt;Duration&lt;/strong&gt; and a generated random number we calculate the final value of the &lt;em&gt;Start&lt;/em&gt; property that we will assign to the &lt;em&gt;&lt;strong&gt;To&lt;/strong&gt; &lt;/em&gt;property of the animation. &lt;/p&gt;  &lt;p&gt;We assign a Circle out easing function to the animation so that the speed of spinning is decreased over the duration of the animation till it stops.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2b9438af-a26b-4014-920b-41bf040785fd" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; StartRoulette()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;PathListBox&lt;/span&gt; pathListBox = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.AssociatedObject &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PathListBox&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; itemsCount = pathListBox.Items.Count;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (pathListBox == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; || pathListBox.Items == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; || itemsCount &amp;lt;= 1)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;            &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#008000;"&gt;//Support one layout path only?&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;PropertyPath&lt;/span&gt; propertyPath = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PropertyPath&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;(ec:PathListBox.LayoutPaths)[{0}].(ec:LayoutPath.Start)&amp;quot;&lt;/span&gt;, 0));&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;DoubleAnimation&lt;/span&gt; startPropertyAnimation = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DoubleAnimation&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;Storyboard&lt;/span&gt;.SetTarget(startPropertyAnimation, pathListBox);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;Storyboard&lt;/span&gt;.SetTargetProperty(startPropertyAnimation, propertyPath);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.rouletteAnimationStoryboard.Stop();&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.rouletteAnimationStoryboard.Children.Clear();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.rouletteAnimationStoryboard.Children.Add(startPropertyAnimation);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; randomOffset = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Random&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;Environment&lt;/span&gt;.TickCount).Next(1, 100);&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;Duration&lt;/span&gt; calculatedDuration = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Duration;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; nIterations = 1;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Duration.TimeSpan.TotalSeconds &amp;lt;= 1)&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                calculatedDuration = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Duration&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TimeSpan&lt;/span&gt;(0, 0, 1));&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            nIterations = ((&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;)calculatedDuration.TimeSpan.TotalSeconds * &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Speed) / itemsCount;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (nIterations &amp;lt; 1)&lt;/li&gt; &lt;li&gt;                nIterations = 1;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            startPropertyAnimation.Duration = calculatedDuration;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            startPropertyAnimation.To = (&lt;span style="color:#0000ff;"&gt;double&lt;/span&gt;)(100 * nIterations + randomOffset) / 100.0;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; easing = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CircleEase&lt;/span&gt;();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            easing.EasingMode = &lt;span style="color:#2b91af;"&gt;EasingMode&lt;/span&gt;.EaseOut;&lt;/li&gt; &lt;li&gt;            startPropertyAnimation.EasingFunction = easing;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.rouletteAnimationStoryboard.Begin();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;If we try this now the items will spin (the items are not actually spinning we are changing &lt;strong&gt;Start&lt;/strong&gt; property of the layout path and that makes it look like spinning). but we didn’t specify yet how we will select the winning item, so what we need to do is that while the items are virtually spinning we need to change the selected item or more specifically change the &lt;strong&gt;SelectedIndex&lt;/strong&gt; property. The problem is that we need to keep changing the &lt;strong&gt;SelectedIndex&lt;/strong&gt; value as long as the &lt;strong&gt;Start&lt;/strong&gt; property value is changing, how we do this by binding the two properties. so we will add the following code to the &lt;strong&gt;OnAttached&lt;/strong&gt; method&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:05b5a0fd-0b8f-4484-ac0a-7ef4153da20e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#2b91af;"&gt;Binding&lt;/span&gt; binding = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Binding&lt;/span&gt;();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;PropertyPath&lt;/span&gt; propertyPath = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PropertyPath&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;LayoutPaths[0].Start&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;            binding.Path = propertyPath;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            binding.RelativeSource = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RelativeSource&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;RelativeSourceMode&lt;/span&gt;.Self);&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; converter = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;StartToIndexConverter&lt;/span&gt;(AssociatedObject);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            binding.Converter = converter;&lt;/li&gt; &lt;li&gt;            binding.Mode = &lt;span style="color:#2b91af;"&gt;BindingMode&lt;/span&gt;.TwoWay;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            AssociatedObject.SetBinding(&lt;span style="color:#2b91af;"&gt;ListBox&lt;/span&gt;.SelectedIndexProperty, binding);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The code binds the &lt;strong&gt;SelectedIndex &lt;/strong&gt;property to the &lt;strong&gt;Start&lt;/strong&gt; property of the first &lt;em&gt;LayoutPath &lt;/em&gt;(this behavior supports 1 &lt;em&gt;LayoutPath&lt;/em&gt;), we need a custom &lt;em&gt;IValueConverter&lt;/em&gt; to convert the value of the &lt;strong&gt;Start&lt;/strong&gt; property to a correct &lt;strong&gt;SelectedIndex &lt;/strong&gt;property that’s where the &lt;em&gt;StartToIndexConverter &lt;/em&gt;comes into play, the two functions that we need to implement in the IValueConverter interface are shown below &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f37c78a3-ae19-45c1-8893-f6ec13609085" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; Convert(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; value, &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; parameter, System.Globalization.&lt;span style="color:#2b91af;"&gt;CultureInfo&lt;/span&gt; culture)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; 0;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; index = 0;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt; capacity = 0;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;double&lt;/span&gt;.IsNaN(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.LayoutPaths[0].Capacity))&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                capacity = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.Items.Count;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                capacity = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.LayoutPaths[0].Capacity;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt; start = (&lt;span style="color:#0000ff;"&gt;double&lt;/span&gt;)value;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt; shift = _previousValue - start;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt; spacing = (&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.LayoutPaths[0].Span / capacity);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;Debug&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;&amp;quot;Current Start:{0}&amp;quot;&lt;/span&gt;, start.ToString());&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;Math&lt;/span&gt;.Abs(shift) &amp;gt; spacing)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                _previousValue = start;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (shift &amp;gt; 0)&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.SelectedIndex &amp;gt;= (&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.Items.Count - 1))&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                        index = 0;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                        index = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.SelectedIndex + 1;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.SelectedIndex &amp;lt;= 0)&lt;/li&gt; &lt;li&gt;                        index = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.Items.Count - 1;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                        index = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.SelectedIndex - 1;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                index = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.SelectedIndex;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;PathListBoxItem&lt;/span&gt; itemToBeSelected = (&lt;span style="color:#2b91af;"&gt;PathListBoxItem&lt;/span&gt;)&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.ItemContainerGenerator.ContainerFromIndex(index);&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (itemToBeSelected != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; !itemToBeSelected.IsArranged)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (shift &amp;gt; 0)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    index = GetFirstArrangedIndex(0);&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    index = GetLastArrangedIndex(0);&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; index;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; ConvertBack(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; value, &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; parameter, System.Globalization.&lt;span style="color:#2b91af;"&gt;CultureInfo&lt;/span&gt; culture)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._pathListBox.LayoutPaths[0].Start;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Basically what this conversion does is that if the &lt;strong&gt;Start &lt;/strong&gt;value is increased/decreased by an amount that’s greater than the spacing between the items, the converter increments/decrements the &lt;strong&gt;SelectedIndex &lt;/strong&gt;value to move to the next/previous item. we need to make sure that &lt;strong&gt;SelectedIndex &lt;/strong&gt;value remains within the range of the items that are actually visible on the Path that’s why we are checking the &lt;strong&gt;PathListBoxItem.IsArranged&lt;/strong&gt; property.&lt;/p&gt;  &lt;p&gt;Once we finish the Behavior, you can drag it from the Assets window and drop it on your &lt;em&gt;PathListBox, &lt;/em&gt;then you can change its properties accordingly &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_5007E4AF.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="RouletteBehavior properties" border="0" alt="RouletteBehavior properties" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_2EA83F13.png" width="279" height="386" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;PS: This behavior will not work correctly if you are using &lt;strong&gt;PathListBoxScrollBehavior.ScrollSelectedCommand&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can download the RegistrationBooth from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-11.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;And you can download a Demo for using the &lt;strong&gt;RouletteBehavior&lt;/strong&gt; from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RouletteBehaviorDemo.zip" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1167" width="1" height="1"&gt;</description></item><item><title>Silverlight 4.0 Tutorial (12 of N): Collecting Attendees Feedback using Windows Phone 7</title><link>http://www.devlifestyle.net/blogs/articles/archive/2011/02/19/silverlight-4-0-tutorial-12-of-n-collecting-attendees-feedback-using-windows-phone-7.aspx</link><pubDate>Sat, 19 Feb 2011 09:29:23 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1166</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1166</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2011/02/19/silverlight-4-0-tutorial-12-of-n-collecting-attendees-feedback-using-windows-phone-7.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://mosalem.blogspot.com/2010/09/silverlight-40-tutorial-index.html"&gt;You can find a list of the previous tutorial posts here&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Continuing our RegistrationBooth Application…&lt;/p&gt;  &lt;p&gt;It’s very important to collect the attendees feedback to help us improve the future sessions/events we might organize, we can go ahead and implement this functionality in the RegistrationBooth application. but in this post we will take a different approach, we will implement a Windows Phone 7 application that attendees can use on their phones to submit their feedback. Luckily for us Windows Phone 7 uses Silverlight as its development platform (along with XNA), the Silverlight version on Windows Phone is not the same one as the desktop version, think of this as a compact version that fits the phone capabilities. &lt;/p&gt;  &lt;p&gt;Before we start creating the phone application, first let’s think how we will bring the data to the phone, in the case of the Silverlight application we used WCF RIA services (DomainService) which provided rich client experience for the Silverlight application, Unfortunately this type of rich client experience is not available “yet” for windows phone applications. &lt;/p&gt;  &lt;p&gt;When we were creating the DomainService we had the option to expose OData end point.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_01203786.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Exposing OData end point for the Domain Service" border="0" alt="Exposing OData end point for the Domain Service" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_7777C94F.png" width="460" height="242" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If life was peachy we would just add a new OData endpoint to the Domain service we have and consume this service from Windows Phone, unfortunately the OData endpoint exposed from the RIA Service lacks important feature (query options) so we will not be able to make use of an OData endpoint over the RIA service, the solution is to create a new WCF data service, we will call it &lt;strong&gt;RegistrationBoothDataService&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_769F6365.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Add a new WCF Data Service" border="0" alt="Add a new WCF Data Service" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_561823B3.png" width="528" height="113" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Change the Data Service to use our ADO.NET entity model and in the &lt;em&gt;InitializeService &lt;/em&gt;method enable access to all the entities, the service should look like the following&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b77b86c0-a999-4af1-bb2c-0579f6fd3464" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RegistrationBoothDataService&lt;/span&gt; :&lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;DataService&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;RegistrationBoothDBEntities&lt;/span&gt;&amp;gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; InitializeService&lt;br /&gt;         (&lt;span style="color:#2b91af;"&gt;DataServiceConfiguration&lt;/span&gt; config)&lt;br /&gt;     {&lt;br /&gt;         config.SetEntitySetAccessRule(&lt;span style="color:#a31515;"&gt;&amp;quot;*&amp;quot;&lt;/span&gt;,&lt;br /&gt;             &lt;span style="color:#2b91af;"&gt;EntitySetRights&lt;/span&gt;.All);&lt;br /&gt;         config.SetServiceOperationAccessRule(&lt;span style="color:#a31515;"&gt;&amp;quot;*&amp;quot;&lt;/span&gt;, &lt;br /&gt;             &lt;span style="color:#2b91af;"&gt;ServiceOperationRights&lt;/span&gt;.All);&lt;br /&gt;         config.DataServiceBehavior.MaxProtocolVersion =&lt;br /&gt;             &lt;span style="color:#2b91af;"&gt;DataServiceProtocolVersion&lt;/span&gt;.V2;&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Now build the project and give it a try and navigate to the following URL&lt;/p&gt;  &lt;p&gt;&lt;a title="http://localhost:57263/RegistrationBoothDataService.svc/" href="http://localhost:57263/RegistrationBoothDataService.svc/"&gt;http://localhost:57263/RegistrationBoothDataService.svc/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You will see AtomPub feed containing the names of all the entities exposed by the DomainService, if you want to see the records of a certain entity just append &lt;em&gt;entityname&lt;/em&gt; to the above URL, for example to see all the attendees go to the following URL&lt;/p&gt;  &lt;p&gt;&lt;a title="http://localhost:57263/RegistrationBoothDataService.svc/Attendees" href="http://localhost:57263/RegistrationBoothDataService.svc/Attendees"&gt;http://localhost:57263/RegistrationBoothDataService.svc/Attendees&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s what we need to do to configure the service on the server side.&lt;/p&gt;  &lt;p&gt;Now moving to the client (Phone) we need to add a new project (for the Windows Phone 7 development tools go to &lt;a href="http://developer.windowsphone.com"&gt;http://developer.windowsphone.com&lt;/a&gt;) We will choose the &lt;em&gt;Windows Phone Panorama Application &lt;/em&gt;project type, later we will see why we choose that.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_1C9513BC.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Creating a Windows Phone Panorama Application" border="0" alt="Creating a Windows Phone Panorama Application" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_7C0DD409.png" width="484" height="85" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To consume the OData service from the windows phone project we need to download the OData client library for Windows Phone 7 (&lt;a title="odata.codeplex.com" href="http://odata.codeplex.com"&gt;http://odata.codeplex.com&lt;/a&gt;), when you download this library you will have the assembly System.Data.Services.Client.dll, Add Reference to this dll in the windows phone project, and you will have a command line tool DataSvcUtil.exe that we will use to generate a proxy class for the OData service, so we will run the command line tool passing the service URL &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f563f002-6df4-402e-bb00-b6ce1a35e409" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;DataSvcUtil /uri:http:&lt;span style="color:#008000;"&gt;//localhost:57263/RegistrationBoothDataService.svc/ /out:.&amp;#92;RegistrationBoothDataModel.cs /Version:2.0 /DataServiceCollection&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Once we have this class, we will add it to the windows phone project.&lt;/p&gt;  &lt;p&gt;So why we chose the panoramic application? or what is a panoramic application anyway? &lt;a href="http://msdn.microsoft.com/en-us/library/ff941104(v=vs.92).aspx" target="_blank"&gt;according to MSDN&lt;/a&gt; “panoramic applications offer a unique way to view controls, data, and services by using a long horizontal canvas that extends beyond the confines of the screen”&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_62399DDA.jpg" target="_blank"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Panorama Application" border="0" alt="Panorama Application" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_3307B243.jpg" width="484" height="320" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So how we will implement our application UI as a panorama application? we will&amp;#160; display the time slots horizontally and the sessions vertically, so the user will see the time slot in the header and below it a list of sessions, and by scrolling horizontally the user will move to the subsequent time slots and below each one the list of sessions in that time slot.&lt;/p&gt;  &lt;p&gt;If you inspect the panorama application project we created, you will find that VS created a sample project with organized structure, where you have view models located in the &lt;em&gt;ViewModels&lt;/em&gt; folder and the view models contain some sample data, and the XAML pages (views) are bound to these view models, we will follow the same structure in our application. &lt;/p&gt;  &lt;p&gt;To communicate with the data service we need to define a DataServiceContext we will define this in the Application class &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:33c4347e-0844-48ee-8d90-fa1ffd27b044" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#008000;"&gt;//App.xaml.cs&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt; ServiceUri = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;http://localhost:57263/RegistrationBoothDataService.svc/&amp;quot;&lt;/span&gt;);&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; AttendeeID { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;br /&gt;        &lt;br /&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RegistrationBoothDataService&lt;/span&gt; context;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RegistrationBoothDataService&lt;/span&gt; DataServiceContext&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (context == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;             context = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RegistrationBoothDataService&lt;/span&gt;(ServiceUri);&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; context;&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The first page will be the &lt;strong&gt;Login.xaml&lt;/strong&gt;, for the sake of simplicity we will ask the user to enter the attendee Id only &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_4B2B1C9E.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Login Page" border="0" alt="Login Page" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_45DC35ED.png" width="346" height="245" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The code behind is pretty straightforward, in the page constructor we initialize a &lt;strong&gt;DataServiceCollection&lt;/strong&gt; of Attendees&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4227e7a3-f47f-4c4e-b5ee-b56d9da8b0ea" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; attendeesUri = &lt;span style="color:#a31515;"&gt;&amp;quot;/Attendees?$filter=Id eq {0}&amp;quot;&lt;/span&gt;;&lt;br /&gt; &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt;&amp;gt; attendeesEntities;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Login()&lt;br /&gt; {&lt;br /&gt;     InitializeComponent();&lt;br /&gt;     attendeesEntities = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt;&amp;gt;(&lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.DataServiceContext);&lt;br /&gt;     attendeesEntities.LoadCompleted += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt;&amp;gt;(attendeesEntities_LoadCompleted);&lt;br /&gt;     &lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;When the user clicks the login button we populate this collection by a query that filters the attendees based on the supplied attendee id &amp;quot;/Attendees?$filter=Id eq {0}&amp;quot;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e5db76bb-b8d6-4d5f-bd98-3c18954d832e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; LoginButton_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;br /&gt; {&lt;br /&gt;     attendeesEntities.LoadAsync(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(attendeesUri,AttendeeID.Text), &lt;span style="color:#2b91af;"&gt;UriKind&lt;/span&gt;.Relative));&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Once the query is loaded we check to see if there’s any attendee returned in the result, if there is an attendee we save the &lt;strong&gt;AttendeeID&lt;/strong&gt; and navigate to the next page&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a448f36b-c2f3-4eee-83ff-6c3d0100147a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; attendeesEntities_LoadCompleted(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt; e)&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (attendeesEntities.Count != 1)&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color:#a31515;"&gt;&amp;quot;Invalid id&amp;quot;&lt;/span&gt;);&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.AttendeeID = attendeesEntities[0].Id;&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.NavigationService.Navigate(&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;/MainPage.xaml&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af;"&gt;UriKind&lt;/span&gt;.Relative));&lt;br /&gt;     }&lt;br /&gt;                 &lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The next page &lt;strong&gt;MainPage.xaml&lt;/strong&gt; will display the sessions in a panorama view as we described earlier. before we build the UI let’s first create the view model, the first view model is the &lt;strong&gt;TimeSlotViewModel&lt;/strong&gt; which contains two properties the &lt;strong&gt;TimeSlotHeader&lt;/strong&gt; and a collection of Sessions, the view model also implements the &lt;strong&gt;INotifyPropertyChanged&lt;/strong&gt; interface&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3a2e1ec4-0e35-4b41-afc8-b513cf9dd16f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TimeSlotViewModel&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; TimeSlotViewModel(&lt;span style="color:#2b91af;"&gt;TimeSlot&lt;/span&gt; timeSlotEntity)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.TimeSlotHeader = &lt;span style="color:#2b91af;"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;{0:HH:mm tt} - {1:HH:mm tt}&amp;quot;&lt;/span&gt;, timeSlotEntity.StartTime, timeSlotEntity.EndTime);&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Sessions = timeSlotEntity.Sessions;&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;Collection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Session&lt;/span&gt;&amp;gt; sessions;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Collection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Session&lt;/span&gt;&amp;gt; Sessions&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.sessions; }&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.sessions = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;Sessions&amp;quot;&lt;/span&gt;);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; timeSlotHeader;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; TimeSlotHeader&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;&lt;br /&gt;         { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.timeSlotHeader; }&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.timeSlotHeader = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;TimeSlotHeader&amp;quot;&lt;/span&gt;);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;event&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PropertyChangedEventHandler&lt;/span&gt; PropertyChanged;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; NotifyPropertyChanged(&lt;span style="color:#2b91af;"&gt;String&lt;/span&gt; propertyName)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;PropertyChangedEventHandler&lt;/span&gt; handler = PropertyChanged;&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != handler)&lt;br /&gt;         {&lt;br /&gt;             handler(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PropertyChangedEventArgs&lt;/span&gt;(propertyName));&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Another view model we have is the &lt;strong&gt;MainViewModel&lt;/strong&gt;, this is the view model that the &lt;strong&gt;MainPage.xaml&lt;/strong&gt; will bind to, it has an &lt;strong&gt;ObservableCollection&lt;/strong&gt; of &lt;strong&gt;TimeSlotViewModel&lt;/strong&gt; objects, we populate this collection by performing a query against the DataService using the Uri &lt;em&gt;“/TimeSlots?$expand=Sessions/Speakers”&lt;/em&gt; this query expands the &lt;strong&gt;TimeSlot&lt;/strong&gt; entity to retrieve the associated Sessions and Speakers entities as well&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0a0df828-7239-4ec8-978b-578621028a29" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MainViewModel&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt; timeSlotsUri = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;/TimeSlots?$expand=Sessions/Speakers&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af;"&gt;UriKind&lt;/span&gt;.Relative);&lt;br /&gt;         &lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;TimeSlot&lt;/span&gt;&amp;gt; timeSlotsEntities;&lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;TimeSlotViewModel&lt;/span&gt;&amp;gt; timeSlots;&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; MainViewModel()&lt;br /&gt;     {&lt;br /&gt;         timeSlotsEntities = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;TimeSlot&lt;/span&gt;&amp;gt;(&lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.DataServiceContext);&lt;br /&gt;         timeSlotsEntities.LoadCompleted += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt;&amp;gt;(timeSlotsEntities_LoadCompleted);&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.TimeSlots = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;TimeSlotViewModel&lt;/span&gt;&amp;gt;();&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;TimeSlotViewModel&lt;/span&gt;&amp;gt; TimeSlots&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.timeSlots; }&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.timeSlots = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;TimeSlots&amp;quot;&lt;/span&gt;);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; IsDataLoaded&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;;&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; LoadData()&lt;br /&gt;     {&lt;br /&gt;         timeSlotsEntities.LoadAsync(timeSlotsUri);&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.IsDataLoaded = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; timeSlotsEntities_LoadCompleted(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; timeSlot &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; timeSlotsEntities)&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; tsViewModel = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TimeSlotViewModel&lt;/span&gt;(timeSlot);&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.TimeSlots.Add(tsViewModel);&lt;br /&gt;         }&lt;br /&gt;     }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The &lt;strong&gt;MainPage.xaml&lt;/strong&gt; contains the Panorama control whose &lt;strong&gt;ItemsSource &lt;/strong&gt;property is bound to the &lt;strong&gt;TimeSlots&lt;/strong&gt; property of the &lt;strong&gt;MainViewModel, &lt;/strong&gt;each panorama Item contains a ListBox that displays the Sessions available in that TimeSlot&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4da1d347-d30e-4693-813c-acece55e7a16" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Transparent&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;local&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DisplayNameConverter&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;displayNameConverter&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.Resources&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Panorama&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Title&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Select the Session&amp;quot;&lt;/span&gt; &lt;br /&gt;                          &lt;span style="color:#ff0000;"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TimeSlots}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Panorama.Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ImageBrush&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; ImageSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;PanoramaBackground.png&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Panorama.Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Panorama.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PanoramaItem&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Header&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TimeSlotHeader}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot; &amp;gt;&lt;/span&gt;&lt;br /&gt;                         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PanoramaItem.HeaderTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; PhoneTextLargeStyle}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PanoramaItem.HeaderTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,0,-12,0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Sessions}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; SelectionChanged&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;OnSelectionChanged&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;br /&gt;                             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,0,0,17&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;432&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;                                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Title}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt; &lt;br /&gt;                                            &lt;span style="color:#ff0000;"&gt; Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; PhoneTextLargeStyle}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                                 &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Speakers}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&amp;gt;            &lt;/span&gt;&lt;br /&gt;                                     &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;                        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                                             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; .,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Converter&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;={&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; displayNameConverter}}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt; &lt;br /&gt;                                                            &lt;span style="color:#ff0000;"&gt; Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; PhoneTextSubtleStyle}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;                                         &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                                     &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                                 &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PanoramaItem&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Panorama.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;controls&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Panorama&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The code behind the &lt;strong&gt;MainPage.xaml &lt;/strong&gt;will set the DataContext of the page to an instance of the &lt;strong&gt;MainViewModel &lt;/strong&gt;class, we will load the View Model data in the Load Event of the page, on the &lt;strong&gt;SelectionChanged&lt;/strong&gt; event of the sessions &lt;strong&gt;ListBox &lt;/strong&gt;we will navigate to the session evaluation page &lt;strong&gt;SessionEval.xaml&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d84acec6-70b8-4324-a250-4cba8b1f7a63" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MainPage&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;PhoneApplicationPage&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;MainViewModel&lt;/span&gt; ViewModel = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MainViewModel&lt;/span&gt;();&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; MainPage()&lt;br /&gt;     {&lt;br /&gt;         InitializeComponent();&lt;br /&gt;         DataContext = ViewModel;&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Loaded += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RoutedEventHandler&lt;/span&gt;(MainPage_Loaded);&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; MainPage_Loaded(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!ViewModel.IsDataLoaded)&lt;br /&gt;         {&lt;br /&gt;             ViewModel.LoadData();&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnSelectionChanged(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;SelectionChangedEventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; selector = (&lt;span style="color:#2b91af;"&gt;Selector&lt;/span&gt;)sender;&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (selector.SelectedIndex == -1)&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;br /&gt;         &lt;span style="color:#2b91af;"&gt;Session&lt;/span&gt; session = selector.SelectedItem &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Session&lt;/span&gt;;&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.NavigationService.Navigate(&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;/SessionEval.xaml?sessionId=&amp;quot;&lt;/span&gt; + session.Id, &lt;span style="color:#2b91af;"&gt;UriKind&lt;/span&gt;.Relative));&lt;br /&gt;         selector.SelectedIndex = -1;&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The view model for the &lt;strong&gt;SessionEval.xaml &lt;/strong&gt;page is called &lt;strong&gt;SessionEvalViewModel &lt;/strong&gt;this view model has a punch of propertyies we have a &lt;strong&gt;DataServiceCollection&lt;/strong&gt; of &lt;strong&gt;EvalCriteria&lt;/strong&gt; entities which contains the different evaluation criteria, and we have another &lt;strong&gt;DataServiceCollection&lt;/strong&gt; of &lt;strong&gt;SessionEvaluation&lt;/strong&gt; entities which contains the evaluation value for each criteria per session per attendee. there is another &lt;strong&gt;ObservableCollection &lt;/strong&gt;of &lt;strong&gt;EvalCriteriaInfo&lt;/strong&gt; objects, this collection is the one that is exposed to the UI. &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:06051234-92d7-4f15-83d2-5325b578acdf" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; evalCriteriaUrl = &lt;span style="color:#a31515;"&gt;&amp;quot;/EvalCriterias&amp;quot;&lt;/span&gt;;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;readonly&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; sessionEvalUrl = &lt;span style="color:#a31515;"&gt;&amp;quot;/SessionEvaluations?$filter=SessionId eq {0} and AttendeeId eq {1}&amp;quot;&lt;/span&gt;;&lt;span style="color:#008000;"&gt;//, UriKind.Relative);&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;EvalCriteria&lt;/span&gt;&amp;gt; evalCriteriaEntities;&lt;br /&gt; &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;SessionEvaluation&lt;/span&gt;&amp;gt; sessionEvalEntities;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; bEvalsLoaded = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; _sessionId;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; bCriteriaLoaded = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;br /&gt; &lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;EvalCriteriaInfo&lt;/span&gt;&amp;gt; _evaluations;&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; SessionEvalViewModel()&lt;br /&gt; {            &lt;br /&gt;         _evaluations = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;EvalCriteriaInfo&lt;/span&gt;&amp;gt;();&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; &lt;span style="color:#0000ff;"&gt;#region&lt;/span&gt; Properties&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ObservableCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;EvalCriteriaInfo&lt;/span&gt;&amp;gt; Evaluations&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; _evaluations; }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;     {&lt;br /&gt;         _evaluations = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;         NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;Evaluations&amp;quot;&lt;/span&gt;);&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; IsDataLoaded&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;;&lt;br /&gt; }&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;#endregion&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;the &lt;strong&gt;EvalCriteriaInfo&lt;/strong&gt; class is a helper class that implements the &lt;strong&gt;INotifyPropertyChanged&lt;/strong&gt; interface&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:36a27c17-4b36-428c-9857-a800446c1423" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EvalCriteriaInfo&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; _evalCriteriaTitle;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; _evalCriteriaId;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; _evaluationValue;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; EvalCriteriaTitle {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; _evalCriteriaTitle; }&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;br /&gt;         { &lt;br /&gt;             _evalCriteriaTitle = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;             NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;EvalCriteriaTitle&amp;quot;&lt;/span&gt;);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; EvaluationValue&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; _evaluationValue; }&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;         {&lt;br /&gt;             _evaluationValue = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;             NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;EvaluationValue&amp;quot;&lt;/span&gt;);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; EvalCriteriaId&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; _evalCriteriaId; }&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;br /&gt;         {&lt;br /&gt;             _evalCriteriaId = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;             NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;EvalCriteriaId&amp;quot;&lt;/span&gt;);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt;       &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;SessionEvaluation&lt;/span&gt; SessionEvaluationEntity;&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;#region&lt;/span&gt; INotifyPropertyChanged Implementation&lt;br /&gt;     &lt;span style="color:#008000;"&gt;/**/&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;#endregion&lt;/span&gt;&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The &lt;strong&gt;LoadData&lt;/strong&gt; method of the view model, loads the &lt;strong&gt;EvalCriteria&lt;/strong&gt; and &lt;strong&gt;SessionEvaluation &lt;/strong&gt;collections and save them in the Application object&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cc70d913-5b8c-4f46-a114-2cc4db9d2f3a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; LoadData(&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; sessionId)&lt;br /&gt; {&lt;br /&gt;     _sessionId = sessionId;&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.EvalCriteriaEntities == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;     {&lt;br /&gt;         evalCriteriaEntities = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;EvalCriteria&lt;/span&gt;&amp;gt;(&lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.DataServiceContext);&lt;br /&gt;         evalCriteriaEntities.LoadCompleted += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt;&amp;gt;(evalCriteriaEntities_LoadCompleted);&lt;br /&gt;         evalCriteriaEntities.LoadAsync(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(evalCriteriaUrl, &lt;span style="color:#2b91af;"&gt;UriKind&lt;/span&gt;.Relative));&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.evalCriteriaEntities = &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.EvalCriteriaEntities;&lt;br /&gt;         bCriteriaLoaded = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!&lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.SessionEvaluationEntities.ContainsKey(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._sessionId))&lt;br /&gt;     {&lt;br /&gt;         sessionEvalEntities = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;SessionEvaluation&lt;/span&gt;&amp;gt;(&lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.DataServiceContext);&lt;br /&gt;         sessionEvalEntities.LoadCompleted += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt;&amp;gt;(sessionEvalEntities_LoadCompleted);&lt;br /&gt;         sessionEvalEntities.LoadAsync(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(sessionEvalUrl, sessionId, &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.AttendeeID), &lt;span style="color:#2b91af;"&gt;UriKind&lt;/span&gt;.Relative));&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.sessionEvalEntities = &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.SessionEvaluationEntities[&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;._sessionId];&lt;br /&gt;         bEvalsLoaded = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.IsDataLoaded = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;     populate();&lt;br /&gt; }&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; evalCriteriaEntities_LoadCompleted(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt; e)&lt;br /&gt; {&lt;br /&gt;     bCriteriaLoaded = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.EvalCriteriaEntities = evalCriteriaEntities;&lt;br /&gt;     populate(); &lt;br /&gt; }&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; sessionEvalEntities_LoadCompleted(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;LoadCompletedEventArgs&lt;/span&gt; e)&lt;br /&gt; {&lt;br /&gt;     bEvalsLoaded = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.SessionEvaluationEntities.Add(_sessionId,sessionEvalEntities);&lt;br /&gt;     populate(); &lt;br /&gt; }&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; populate()&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!bEvalsLoaded || !bCriteriaLoaded)&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;br /&gt;             &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; evalCriterion &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; evalCriteriaEntities)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; evalInfo = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EvalCriteriaInfo&lt;/span&gt;();&lt;br /&gt;         evalInfo.EvalCriteriaId = evalCriterion.EvalCriterionId;&lt;br /&gt;         evalInfo.EvalCriteriaTitle = evalCriterion.EvalCriterionText;&lt;br /&gt;                                 &lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; sessionEval &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; sessionEvalEntities)&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (sessionEval.EvalCriterionId == evalCriterion.EvalCriterionId)&lt;br /&gt;             {&lt;br /&gt;                 evalInfo.EvaluationValue = sessionEval.Evaluation-1;&lt;br /&gt;                 evalInfo.SessionEvaluationEntity  = sessionEval;&lt;br /&gt;             }&lt;br /&gt;         }&lt;br /&gt;                 &lt;br /&gt;         Evaluations.Add(evalInfo);  &lt;br /&gt;     }&lt;br /&gt;     NotifyPropertyChanged(&lt;span style="color:#a31515;"&gt;&amp;quot;Evaluations&amp;quot;&lt;/span&gt;);&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The &lt;strong&gt;Save&lt;/strong&gt; method will update the corresponding &lt;strong&gt;SessionEvaluation &lt;/strong&gt;entity if there’s an existing one, or it will add a new &lt;strong&gt;SessionEvaluation &lt;/strong&gt;entity, the changes are pushed back to the Data Service by calling the DataServiceContext &lt;strong&gt;BeginSaveChanges &lt;/strong&gt;method&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:23ba10d0-6d11-4338-acd1-9d0608f85bfe" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Save()&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; eval &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Evaluations)&lt;br /&gt;             {&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (eval.SessionEvaluationEntity != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;                 {&lt;br /&gt;                     eval.SessionEvaluationEntity.Evaluation = eval.EvaluationValue + 1;&lt;br /&gt;                     &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.DataServiceContext.UpdateObject(eval.SessionEvaluationEntity);&lt;br /&gt;                 }&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;                 {&lt;br /&gt;                     &lt;span style="color:#2b91af;"&gt;SessionEvaluation&lt;/span&gt; sessionEval = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;SessionEvaluation&lt;/span&gt;();&lt;br /&gt;                     sessionEval.AttendeeId = &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.AttendeeID;&lt;br /&gt;                     sessionEval.EvalCriterionId = eval.EvalCriteriaId;&lt;br /&gt;                     sessionEval.Evaluation = eval.EvaluationValue+1;&lt;br /&gt;                     sessionEval.SessionId = _sessionId;&lt;br /&gt;                     &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.DataServiceContext.AddObject(&lt;span style="color:#a31515;"&gt;&amp;quot;SessionEvaluations&amp;quot;&lt;/span&gt;, sessionEval);&lt;br /&gt;                 }&lt;br /&gt;             }&lt;br /&gt;             &lt;span style="color:#2b91af;"&gt;App&lt;/span&gt;.DataServiceContext.BeginSaveChanges(OnSaveCompleted, &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;);&lt;br /&gt;         }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The code behind in the &lt;strong&gt;SessionEval &lt;/strong&gt;page will set the DataContext of the page to an instance of the &lt;strong&gt;SessionEvalViewModel&lt;/strong&gt; class, we will load the View Model data in the NavigateTo event handler the page. When we click the Save button we call the &lt;strong&gt;Save &lt;/strong&gt;method of the view model&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cefe403b-1724-4778-a379-442e22e28760" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;SessionEval&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;PhoneApplicationPage&lt;/span&gt;&lt;br /&gt; {&lt;br /&gt;     &lt;span style="color:#2b91af;"&gt;SessionEvalViewModel&lt;/span&gt; viewModel=&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;SessionEvalViewModel&lt;/span&gt;(); &lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; SessionEval()&lt;br /&gt;     {&lt;br /&gt;         InitializeComponent();&lt;br /&gt;         DataContext = viewModel;&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnNavigatedTo(&lt;span style="color:#2b91af;"&gt;NavigationEventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; strIndex = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.NavigationContext.QueryString[&lt;span style="color:#a31515;"&gt;&amp;quot;sessionId&amp;quot;&lt;/span&gt;];&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; sessionId = &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;.Parse(strIndex);&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!viewModel.IsDataLoaded)&lt;br /&gt;         {&lt;br /&gt;             viewModel.LoadData(sessionId);&lt;br /&gt;         }&lt;br /&gt;     }&lt;br /&gt;     &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnSave(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;     {&lt;br /&gt;         &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.viewModel.Save();&lt;br /&gt;     }&lt;br /&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The &lt;strong&gt;SessionEval.xaml &lt;/strong&gt;page contains a ListBox that is bound to the &lt;strong&gt;Evaluations &lt;/strong&gt;collection, each list item will have a group of radio buttons that display the evaluation values.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5aaad32c-dc07-4c17-a229-3892f486f6ce" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,0,-12,0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;lstEvaluations&amp;quot;&lt;/span&gt; &lt;br /&gt;            &lt;span style="color:#ff0000;"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Evaluations&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay}&amp;quot; &amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,0,0,17&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;432&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; EvalCriteriaTitle}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt; &lt;br /&gt;                                &lt;span style="color:#ff0000;"&gt; Style&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; PhoneTextLargeStyle}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; SelectedIndex&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; EvaluationValue&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay}&amp;quot;&lt;/span&gt;&lt;br /&gt;                            &lt;span style="color:#ff0000;"&gt; ItemContainerStyle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; RadioButtonListItemStyle}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBoxItem&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBoxItem&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;2&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBoxItem&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;3&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBoxItem&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;4&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;             &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ListBox&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;You can build and run the project to see the application in action&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_4503D003.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Main page displaying the Sessions in Panorama control" border="0" alt="Main page displaying the Sessions in Panorama control" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_2669DF5A.png" width="388" height="713" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_3865FD1A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="Session evaluation page" border="0" alt="Session evaluation page" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_thumb_5F00_01A8A216.png" width="380" height="685" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can download the source code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-12.zip" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1166" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/WindowsPhone7/default.aspx">WindowsPhone7</category></item><item><title>Special Registration Code For TechEd Dubai 2011</title><link>http://www.devlifestyle.net/blogs/articles/archive/2011/01/10/special-registration-code-for-teched-dubai-2011.aspx</link><pubDate>Tue, 11 Jan 2011 00:23:00 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1164</guid><dc:creator>Mohamad Halabi</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1164</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2011/01/10/special-registration-code-for-teched-dubai-2011.aspx#comments</comments><description>&lt;p&gt;Dear Devlifestyle Members,&lt;/p&gt;
&lt;p&gt;Devlifestyle has a Special Registration Code that you can use to register yourself as a Delegate attendee for Microsoft Tech&amp;middot;Ed Middle East 2011.&lt;/p&gt;
&lt;h2&gt;&lt;span style="font-family:&amp;#39;Verdana&amp;#39;,&amp;#39;sans-serif&amp;#39;;font-size:8.5pt;"&gt;For the month of January, a 10% discount on the Saver Registration Fee of $950&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Below is a link to download a copy of a flowchart explaining the registration process and what is to be expected:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.devlifestyle.net/media/p/1163/download.aspx"&gt;http://www.devlifestyle.net/media/p/1163/download.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p align="center" style="text-align:center;"&gt;Special Registration Code:&lt;br /&gt;&lt;strong style="font-size:16pt;"&gt;4C82024D&lt;/strong&gt;&lt;/p&gt;
&lt;p style="color:red;"&gt;&lt;strong&gt;Please Note: &lt;/strong&gt;Ensure that you complete your registration on or before the expiry date of Monday, January 31, 2011.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1164" width="1" height="1"&gt;</description></item><item><title>MS Open Door Azure Session Materials</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/11/08/ms-open-door-azure-session-materials.aspx</link><pubDate>Mon, 08 Nov 2010 18:47:00 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1161</guid><dc:creator>Mohamad Halabi</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1161</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/11/08/ms-open-door-azure-session-materials.aspx#comments</comments><description>&lt;p&gt;Download Microsoft Open Door Azure Session Materials:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target="_blank" href="http://www.devlifestyle.net/media/p/1157/download.aspx"&gt;Slides&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Demos: &lt;a target="_blank" href="http://www.devlifestyle.net/media/p/1158/download.aspx"&gt;Part1&lt;/a&gt;, &lt;a target="_blank" href="http://www.devlifestyle.net/media/p/1159/download.aspx"&gt;Part2&lt;/a&gt;, &lt;a target="_blank" href="http://www.devlifestyle.net/media/p/1160/download.aspx"&gt;Part3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1161" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Azure/default.aspx">Azure</category></item><item><title>Silverlight 4.0 Tutorial (9 of N): Using the WebCam as a Barcode Scanner</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/11/02/silverlight-4-0-tutorial-9-of-n-using-the-webcam-as-a-barcode-scanner.aspx</link><pubDate>Tue, 02 Nov 2010 18:31:51 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1156</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1156</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/11/02/silverlight-4-0-tutorial-9-of-n-using-the-webcam-as-a-barcode-scanner.aspx#comments</comments><description>&lt;p&gt;Continuing our RegistrationBooth Application, we want to allow registered users to evaluate sessions, we don’t have a credentials store in our application so to identify the registered attendees we will use a simpler approach, in &lt;a href="http://mosalem.blogspot.com/2010/06/silverlight-40-tutorial-2-of-n.html" target="_blank"&gt;part2&lt;/a&gt; we allowed printing a name tag for registered attendees, this name tag contains a barcode of the attendee id, in this post we will see how can we use the new Silverlight 4.0 WebCam functionality to be able to scan/read barcodes and extract the attendee id to identify the corresponding attendee.&lt;/p&gt;  &lt;p&gt;During PDC09 Keynote, Scott Guthrie demonstrated a Silverlight Application that scans a book ISBN barcode and passes this ISBN to Amazon web service to retrieve the book information, we will reuse the code from this sample which can be downloaded from &lt;a href="http://www.silverlight.net/community/samples/silverlight-4/barcode-scanner/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;This sample actually uses a code from a &lt;a href="http://www.codeproject.com/KB/graphics/BarcodeImaging3.aspx"&gt;CodeProject Article&lt;/a&gt; (by Berend Engelbrecht) that detects barcodes inside an image. the code is located in the file BarcodeImaging.cs, so we will copy this file to our project.&lt;/p&gt;  &lt;p&gt;The sample also has another class BarcodeCapture that derives from &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.media.videosink(VS.95).aspx" target="_blank"&gt;VideoSink&lt;/a&gt;, according to MSDN &lt;em&gt;“To obtain video information from a video input device in Silverlight, you derive a custom video sink from VideoSink” &lt;/em&gt;, the important method to override in this class is &lt;em&gt;OnSample&lt;/em&gt; which is called when the video device captures a complete video sample. the code in this method calls the BarcodeImaging method that scans the current sample bitmap for a barcode, if a barcode is found the BarcodeCapture class fires a custom event &lt;em&gt;BarcodeDetected&lt;/em&gt; that propagates the detected barcode. so we will need to copy the BarcodeCapture.cs file to our project.&lt;/p&gt;  &lt;p&gt;On the UI we will have two components, the first one is a rectangle that we will display the webcam stream inside it.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bb01e261-7815-474e-a360-fa4dc7bd0c9f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Border&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;nameTagScannerArea&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Padding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;400&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.RowSpan&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; greenBrush}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; CornerRadius&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;30&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; d&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;IsHidden&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt; &amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#a31515;"&gt;       &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#a31515;"&gt;           &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;14.667&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Foreground&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;White&amp;quot; &amp;gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Place your name tag infront of the camera&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#a31515;"&gt;           &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Rectangle&lt;/span&gt; &lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;barcodeScanner&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Fill&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;White&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;400&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;300&amp;quot;    &lt;/span&gt;     &lt;span style="color:#0000ff;"&gt; /&amp;gt;            &lt;/span&gt;&lt;span style="color:#a31515;"&gt;      &lt;/span&gt;&lt;br /&gt;      &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#a31515;"&gt;   &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Border&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The second UI component is another rectangle that will be shown when a barcode is detected, the rectangle will display a simple welcome message to the user, we will add more functionality later.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ba55b9be-8dc6-459f-b1aa-36d7a0c4e303" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Border&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;welcomeArea&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Padding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;150&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.RowSpan&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; orangeBrush}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; CornerRadius&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;30&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt; &amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#a31515;"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Horizontal&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#a31515;"&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;14.667&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Foreground&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;White&amp;quot; &amp;gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Welcome &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;    &lt;/span&gt;&lt;span style="color:#a31515;"&gt;      &lt;/span&gt;&lt;br /&gt;          &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;userName&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;14.667&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Foreground&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;White&amp;quot; &amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;    &lt;/span&gt;&lt;span style="color:#a31515;"&gt;      &lt;/span&gt;&lt;br /&gt;          &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color:#a31515;"&gt;   &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Border&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;We will add two new visual states, the first one is “ScanningNameTag” in this state we display the barcode scanning area and the attendee list, here’s how the UI looks like in this state&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_47142DD8.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="ScanningNameTag State" border="0" alt="ScanningNameTag State" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_4AD1D2A8.png" width="484" height="278" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The button “Back” moves the UI back to the Default state by using a MoveToStateAction behavior&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_2D00_5_5F00_2D2FD1DC.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="MoveToStateAction behavior to go to the Default State" border="0" alt="MoveToStateAction behavior to go to the Default State" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_2D00_5_5F00_thumb_5F00_140451D7.png" width="273" height="398" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The second state is “WelcomeAttendee”, in this state we show the welcome area and the attendee list, here’s how the UI looks like in this state&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_167D5DC8.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="WelcomeAttendee State" border="0" alt="WelcomeAttendee State" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_4BC6702D.png" width="484" height="278" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see we added a Good Bye Button (btnLogout), we will add a MoveToStateAction behavior to this button so that when we click it we move to the Default state&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_07565921.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="The logout button takes us back to the default state" border="0" alt="The logout button takes us back to the default state" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_1C182BD4.png" width="263" height="395" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;when we click the&amp;#160; “Login” button, we will start the cam and move to the “ScanningNameTag” state&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a08038b3-1c1b-4193-90bf-1f5e11ccd473" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnLogin_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (ActivateCamera())&lt;br /&gt;             {&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (m_Capture == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;                 {&lt;br /&gt;                     m_Capture = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;BarcodeCapture&lt;/span&gt;();&lt;br /&gt;                     m_Capture.BarcodeDetected += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;BarcodeEventArgs&lt;/span&gt;&amp;gt;(OnBarcodeDetected);&lt;br /&gt;                     m_Capture.CaptureSource = m_CaptureSource;&lt;br /&gt;                 }&lt;br /&gt;                 &lt;span style="color:#2b91af;"&gt;VisualStateManager&lt;/span&gt;.GoToState(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;ScanningNameTag&amp;quot;&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;);&lt;br /&gt;             }&lt;br /&gt;         }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The code first activates the camera to start capturing by calling the &lt;em&gt;ActivateCamera&lt;/em&gt; function shown below &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:520db820-ef48-466c-b044-8dde826e63c9" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt;&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; ActivateCamera()&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (m_CaptureSource == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;             {&lt;br /&gt;                 m_CaptureSource = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CaptureSource&lt;/span&gt;();&lt;br /&gt;                 m_CaptureSource.VideoCaptureDevice = &lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.GetDefaultVideoCaptureDevice();&lt;br /&gt; &lt;br /&gt;                 &lt;span style="color:#2b91af;"&gt;VideoBrush&lt;/span&gt; previewBrush = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;VideoBrush&lt;/span&gt;();&lt;br /&gt;                 previewBrush.Stretch = &lt;span style="color:#2b91af;"&gt;Stretch&lt;/span&gt;.Uniform;&lt;br /&gt;                 previewBrush.SetSource(m_CaptureSource);&lt;br /&gt;                 barcodeScanner.Fill = previewBrush;&lt;br /&gt; &lt;br /&gt;                 &lt;span style="color:#2b91af;"&gt;Size&lt;/span&gt; diff = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Size&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;double&lt;/span&gt;.MaxValue, &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt;.MaxValue);&lt;br /&gt;                 &lt;span style="color:#2b91af;"&gt;Size&lt;/span&gt; wantedSize = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Size&lt;/span&gt;(640, 480);&lt;br /&gt;                 &lt;span style="color:#2b91af;"&gt;VideoFormat&lt;/span&gt; bestFormat = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;VideoFormat&lt;/span&gt; format &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; m_CaptureSource.VideoCaptureDevice.SupportedFormats)&lt;br /&gt;                 {&lt;br /&gt;                     &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt; x = &lt;span style="color:#2b91af;"&gt;Math&lt;/span&gt;.Abs(format.PixelWidth - wantedSize.Width);&lt;br /&gt;                     &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt; y = &lt;span style="color:#2b91af;"&gt;Math&lt;/span&gt;.Abs(format.PixelHeight - wantedSize.Height);&lt;br /&gt; &lt;br /&gt;                     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (x &amp;lt; diff.Width &amp;amp;&amp;amp; y &amp;lt; diff.Height)&lt;br /&gt;                     {&lt;br /&gt;                         bestFormat = format;&lt;br /&gt;                         diff.Width = x;&lt;br /&gt;                         diff.Height = y;&lt;br /&gt;                     }&lt;br /&gt;                 }&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (bestFormat != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;                 {&lt;br /&gt;                     m_CaptureSource.VideoCaptureDevice.DesiredFormat = bestFormat;&lt;br /&gt;                 }&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.RequestDeviceAccess() || &lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.AllowedDeviceAccess)&lt;br /&gt;                 {&lt;br /&gt;                     m_CaptureSource.Start();&lt;br /&gt;                     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;                 }&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;                     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;br /&gt;             }&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;br /&gt;         }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;after starting the camera we create an instance of our VideoSink (BarcodeCapture) and link the capture source with our video sink, we must also register to the event &lt;em&gt;BarcodeDetected &lt;/em&gt;to be notified when the BarcodeCapture video sink detects a barcode in the image.&lt;/p&gt;  &lt;p&gt;Here is the event handler for the &lt;em&gt;BarcodeDetected&lt;/em&gt; event&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:34453b0b-6769-4703-9458-f445f65e8aa6" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;"&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; OnBarcodeDetected(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;BarcodeEventArgs&lt;/span&gt; e)&lt;br /&gt;         {&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (e.Barcode.Length &amp;lt; 8)&lt;span style="color:#008000;"&gt;//barcode formate is ATTXXXXX&lt;/span&gt;&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; attendeeID=0;&lt;br /&gt;             &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!&lt;span style="color:#2b91af;"&gt;Int32&lt;/span&gt;.TryParse(e.Barcode.Substring(3, 5), &lt;span style="color:#0000ff;"&gt;out&lt;/span&gt; attendeeID))&lt;br /&gt;                 &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;             Dispatcher.BeginInvoke(&lt;span style="color:#0000ff;"&gt;delegate&lt;/span&gt;()&lt;br /&gt;             {&lt;br /&gt;                 &lt;span style="color:#2b91af;"&gt;RegistrationDomainContext&lt;/span&gt; context = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.Resources[&lt;span style="color:#a31515;"&gt;&amp;quot;registrationDomainContext&amp;quot;&lt;/span&gt;] &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;RegistrationDomainContext&lt;/span&gt;;&lt;br /&gt;                 context.Load(context.GetAttendeeQuery(attendeeID),&lt;br /&gt;                         &lt;span style="color:#0000ff;"&gt;delegate&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;LoadOperation&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt;&amp;gt; loadOperation)&lt;br /&gt;                         {&lt;br /&gt;                             m_CaptureSource.Stop();&lt;br /&gt;                             m_Capture.Clear();&lt;br /&gt;                             &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; attendee &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; loadOperation.Entities)&lt;br /&gt;                             {&lt;br /&gt;                                 lblUserName.Text = &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot; {0} {1}&amp;quot;&lt;/span&gt;, attendee.FirstName ,attendee.LastName);&lt;br /&gt;                                 &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;br /&gt;                             }&lt;br /&gt;                             &lt;span style="color:#2b91af;"&gt;VisualStateManager&lt;/span&gt;.GoToState(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;WelcomeAttendee&amp;quot;&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;);&lt;br /&gt;                         },&lt;br /&gt;                         &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;);&lt;br /&gt;             });&lt;br /&gt;         }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;First We validate the barcode format, then we call a new domain service method that retrieves the attendee based on the id, note that we are using &lt;em&gt;Dispatcher.BeginInvoke&lt;/em&gt; method so that our code runs on the main UI thread.&lt;/p&gt;  &lt;p&gt;Let’s run the application, click on the Login button, the webcam will start, hold the name tag in front of the webcam, you may need to move the name tag closer/way from the webcam till it picks the barcode&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_6C99973A.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Barcode scanning through the web cam" border="0" alt="Barcode scanning through the web cam" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_5C79E10F.png" width="484" height="404" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once the barcode is detected, the application will move to the WelcomeAttendee state&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_20E5E41D.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="5" border="0" alt="5" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_4C4A0517.png" width="484" height="192" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Note: i used the &lt;a href="http://silverlightbarcode.codeplex.com/" target="_blank"&gt;Silverlight Barcode Library&lt;/a&gt; to generate the barcode, cause the previous method we used (the font 3 of 9) was not recognized by &lt;a href="http://www.codeproject.com/KB/graphics/BarcodeImaging3.aspx" target="_blank"&gt;Berend&lt;/a&gt; library&lt;/p&gt;  &lt;p&gt;You can download the source code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-9.zip" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;See you in the next post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1156" width="1" height="1"&gt;</description></item><item><title>Silverlight 4.0 Tutorial (8 of N): Fluid Layouts</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/09/08/silverlight-4-0-tutorial-8-of-n-fluid-layouts.aspx</link><pubDate>Thu, 09 Sep 2010 03:00:00 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1152</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1152</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/09/08/silverlight-4-0-tutorial-8-of-n-fluid-layouts.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Read Previous Posts: &lt;strong&gt;&lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx"&gt;Part1&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx"&gt;Part2&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-3-of-n-working-with-the-dataform-control.aspx"&gt;Part3&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-4-of-n-listbox-itemtemplate.aspx"&gt;Part4&lt;/a&gt;&lt;/strong&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-5-of-n-more-blend.aspx"&gt;Part5&lt;/a&gt;&lt;strong&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-6-of-n-working-with-the-itemscontrol.aspx"&gt;Part6&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/09/04/silverlight-4-0-tutorial-7-of-n-visual-states.aspx" target="_blank"&gt;Part7&lt;/a&gt;&lt;/strong&gt;&lt;/strong&gt;&lt;a href="http://mosalem.blogspot.com/2010/09/silverlight-40-tutorial-7-of-n-visual.html"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In our last &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/09/04/silverlight-4-0-tutorial-7-of-n-visual-states.aspx"&gt;post&lt;/a&gt; we implemented visual states for our application, you may have noticed in the States tab in Blend the Default Transition section&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_0CF302DE.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Default Transition" border="0" alt="Default Transition" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_0B42370A.png" width="405" height="49" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;the default transition is applied when moving from any state to any other state. &lt;/p&gt;  &lt;p&gt;- You can create transitions between any pair of states, for each transition you specify how long it will take (transition duration) and the easing function to be used. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_69E2916D.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="State Transitions" border="0" alt="State Transitions" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_32B90374.png" width="484" height="94" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;the easing function makes the animations look real, so instead of the linear interpolations of the values that change between states you can choose the appropriate easing function to interpolate the values, there are many easing functions in Blend (quadratics, cubic, bounce, elastic, etc.)&amp;#160; and you can even code your own easing function. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_7E38312B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Easing Functions" border="0" alt="Easing Functions" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_thumb_5F00_2E12D2ED.png" width="251" height="374" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- You can see a preview of the state transitions by turning on the transition preview (click on the icon highlighted in the below image)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_11B56B00.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Transition Preview" border="0" alt="Transition Preview" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_1DD6E527.png" width="484" height="81" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;by turning on the transition preview whenever you change the selected state in the states tab the corresponding transition will be played.&lt;/p&gt;  &lt;p&gt;- We can employ these transitions in our application, but the problem is that the properties we change in the different states (Visibility, RowSpan) are discrete properties that cannot be smoothly interpolated. the solution Microsoft offers for this is Fluid Layout, what is Fluid Layout? according to The &lt;a href="http://blogs.msdn.com/b/expression/archive/2010/03/16/dynamic-layout-and-transitions-in-expression-blend-4.aspx"&gt;Expression team blog&lt;/a&gt;&lt;em&gt;&amp;#160; &lt;/em&gt;” an engine that would take a layout snapshot before the state change, take another layout snapshot after the state change, and create a smooth morph between the start and end positions, employing the duration and EasingFunction of the user’s choosing.”&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_1F58013B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Fluid Layout" border="0" alt="Fluid Layout" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_4B28552A.png" width="484" height="72" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can turn on the Fluid Layout by clicking the icon highlighted in the image above.&lt;/p&gt;  &lt;p&gt;- Let’s use this new feature in our application, we will turn the fluid layout on, and change the default transition to use BackInOut easing function with duration one second&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_086909F2.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="BackInOut Easing Function" border="0" alt="BackInOut Easing Function" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_thumb_5F00_14F6B70E.png" width="328" height="106" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- If you turn the transition preview on, you can see the transition effect immediately while you change the selected state in the States tab.&lt;/p&gt;  &lt;p&gt;- Run the application to see the transition in action.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_537C04B4.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="8" border="0" alt="8" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_thumb_5F00_0E3387BE.png" width="484" height="212" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;See you in the next post.&lt;/p&gt;  &lt;p&gt;Download the source code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/REgistrationBooth-8.zip" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1152" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4.0 Tutorial (7 of N): Visual States</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/09/04/silverlight-4-0-tutorial-7-of-n-visual-states.aspx</link><pubDate>Sat, 04 Sep 2010 07:26:19 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1149</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1149</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/09/04/silverlight-4-0-tutorial-7-of-n-visual-states.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Read Previous Posts: &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx"&gt;Part1&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx"&gt;Part2&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-3-of-n-working-with-the-dataform-control.aspx"&gt;Part3&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-4-of-n-listbox-itemtemplate.aspx"&gt;Part4&lt;/a&gt;&lt;/strong&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-5-of-n-more-blend.aspx" target="_blank"&gt;Part5&lt;/a&gt;&lt;strong&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-6-of-n-working-with-the-itemscontrol.aspx" target="_blank"&gt;Part6&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Continuing our registration booth application, i did some changes to the application UI, here’s how the application look like right now&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_4226D881.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Final Application UI" border="0" alt="Final Application UI" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_4C2B53DF.png" width="484" height="228" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- As you can see i removed the navigation features in the application, we will keep it as a one simple xaml page, i also changed some colors (excuse my poor color picking skills).&lt;/p&gt;  &lt;p&gt;- After looking at the UI i think that the agenda is not taking enough space, the lower DataForm is taking more space while this DataForm is needed only when someone wants to register, the focus of the default UI should be the agenda and the registered attendees, so we need to make the DataForm invisible and show it on demand, this is pretty easy to do, first i will add a button to view/hide the DataForm.&lt;/p&gt;  &lt;p&gt;- I will add a new column to the LayoutRoot grid and put the button inside this column, i will also add a simple rotate transform for this button&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/14_5F00_5CC34ECD.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Rotate Transform" border="0" alt="Rotate Transform" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/14_5F00_thumb_5F00_512D918E.png" width="267" height="148" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- The button should look like this&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/15_5F00_7B99C2AB.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="15" border="0" alt="15" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/15_5F00_thumb_5F00_68E4C8F4.png" width="176" height="364" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- First we need to hide the lower DataForm and expand the agenda to span two rows, then in the button event handler we need to show the DataForm and change the agenda back to span one row only. we can write the code immediately in the button click event handler or we can make use of Visual States (more details on States &lt;a href="http://www.interact-sw.co.uk/iangblog/2008/06/10/visual-state"&gt;here&lt;/a&gt;), apparently our form has two states the first state (the default one) is when we are showing the attendees list and the event agenda; the second state is when we are showing the attendees list, event agenda and the DataForm.&lt;/p&gt;  &lt;p&gt;- In Blend you can easily create these two states, in one of the tool windows in Blend (the one that has the projects tab) you will find a tab called States&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_336C06CF.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Visual States" border="0" alt="Visual States" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_27D64990.png" width="344" height="177" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- The states tab is empty because we don’t have states yet, to add state you can click the small icon (surrounded by red rectangle in the image above) the tooltip on the icon says “Add state group”, a state groups is just a way to group states together. so we will click this icon to add a new state group&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_2E1D201E.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="New VisualStateGroup" border="0" alt="New VisualStateGroup" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_5FA88DB3.png" width="319" height="140" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- As you can see in the image above, the new state group is called VisualStateGroup you can change the name if you want to; We will add two states in this group (by clicking on the icon surrounded by red rectangle), we will name them &lt;em&gt;Default &lt;/em&gt;and &lt;em&gt;Register.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_38021189.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Two States" border="0" alt="Two States" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_thumb_5F00_0C51478D.png" width="287" height="167" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- Starting with the &lt;em&gt;Default&lt;/em&gt; state, in this state the DataForm should be hidden and the agenda should span two rows, to do this all you need is to select the &lt;em&gt;Default&lt;/em&gt; state and do the necessary changes in the UI, whatever you change in the UI is saved in this state, as you can see at the top of the designer window a message saying that &lt;em&gt;state recording is on&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_6BCA07DA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="state recording is on" border="0" alt="state recording is on" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_thumb_5F00_566C5272.png" width="218" height="68" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- So select the &lt;em&gt;Default&lt;/em&gt; state and change the Visibility of the stack panel that contains the DataForm and the colored rectangle (rectAttendeeDataFormContainer) to collapsed, and for the agenda items control change its RowSpan property to 2 &lt;/p&gt;  &lt;p&gt;- Select the &lt;em&gt;Register &lt;/em&gt;state and change the Visibility of the stack panel that contains the DataForm and the colored rectangle (rectAttendeeDataFormContainer) to visible, and for the agenda items control change its RowSpan property to 1, for the register button change its visibility to collapsed.&lt;/p&gt;  &lt;p&gt;- Now we need to start the application in the Default state, to do this add the following line of code in the constructor of the page &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:040d55f9-a1bf-4cd0-af12-9a634da63bf4" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; Home()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            InitializeComponent();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;VisualStateManager&lt;/span&gt;.GoToState(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;Default&amp;quot;&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;We use the VisualStateManager (the component responsible for managing the different states) to go to the &lt;em&gt;Default &lt;/em&gt;state&lt;/p&gt;  &lt;p&gt;- On clicking the button we will go to the &lt;em&gt;Register&lt;/em&gt; state, we can do this by calling the &lt;em&gt;VisualStateManger.GoToState &lt;/em&gt;method in the button event handler; another way of doing this if you do not want to write code is to use &lt;a href="http://blogs.msdn.com/b/expression/archive/2009/03/23/an-introduction-to-behaviors-triggers-and-actions.aspx"&gt;Blend behaviors&lt;/a&gt;, under the Assets tab select Behaviors, you will find a behavior called &lt;em&gt;GoToStateAction&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_7CCE35BD.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Behaviors" border="0" alt="Behaviors" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_thumb_5F00_6E2389D8.png" width="439" height="218" /&gt;&lt;/a&gt; &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;- &lt;/em&gt;Drag and drop this behavior on the button, go to the properties of the behavior you will see that this behavior action will be triggered by the button click event; you have to choose the &lt;em&gt;Register&lt;/em&gt; state from the dropdown list&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_095BE2DA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="GoToStateAction behavior properties" border="0" alt="GoToStateAction behavior properties" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_thumb_5F00_419A59F2.png" width="271" height="404" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- Run the application, initially the DataForm is hidden because we are in the Default state, click on the Register button to go to the &lt;em&gt;Register &lt;/em&gt;state, the DataForm will be shown&lt;/p&gt;  &lt;p&gt;- After the user registers a new attendee we should go back to the default state, we can do this by using the &lt;em&gt;GoToStateAction &lt;/em&gt;behavior we used earlier, drag and drop this behavior over the DataForm, change the properties of the behavior by setting the EventName to EditEnded and the StateName to &lt;em&gt;Default&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/image_5F00_47E13080.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://www.devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/image_5F00_thumb_5F00_203AB456.png" width="270" height="370" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Try the application again, click the Register button, the application will go the Register state. enter the necessary information and click Ok, the application will go back to the Default state.&lt;/p&gt;  &lt;p&gt;That’s it for this post, we will continue in the next one.&lt;/p&gt;  &lt;p&gt;Download the source code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-7.zip"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1149" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4.0 Tutorial (6 of N): Working with the ItemsControl</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-6-of-n-working-with-the-itemscontrol.aspx</link><pubDate>Mon, 09 Aug 2010 11:09:55 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1145</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1145</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-6-of-n-working-with-the-itemscontrol.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Read Previous Posts: &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx"&gt;Part1&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx"&gt;Part2&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-3-of-n-working-with-the-dataform-control.aspx"&gt;Part3&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-4-of-n-listbox-itemtemplate.aspx"&gt;Part4&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-5-of-n-more-blend.aspx" target="_blank"&gt;Part5&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In this part of the series we will build the event agenda&lt;/p&gt;  &lt;p&gt;- First let’s try to make some room on the UI for the agenda, add a new row to the &lt;strong&gt;LayoutRoot&lt;/strong&gt; grid, make sure that the attendees ListBox has &lt;strong&gt;RowSpan=2, &lt;/strong&gt;then move the DataForm to the lower right cell, we will display the agenda in the upper right cell, Now our home page should look like the following&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_0D5DC057.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Home page" border="0" alt="Home page" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_313671E4.png" width="442" height="261" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- To build the agenda let’s recall our data model, we have a table &lt;strong&gt;TimeSlot &lt;/strong&gt;that contains the different time slots in the event, each session is assigned to one time slot and each time slot can have one or more session.&lt;/p&gt;  &lt;p&gt;- We will need to retrieve all the time slots along with the sessions in each time slot, to do this go to the RegistrationDomainService.cs file in the RegistrationBooth.Web project, change the &lt;strong&gt;GetTimeSlots &lt;/strong&gt;method as follows&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e540c396-e239-4348-abc8-20c7384e1265" class="wlWriterSmartContent"&gt;   &lt;div style="border-bottom:#000080 1px solid;border-left:#000080 1px solid;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;color:#000;font-size:10pt;border-top:#000080 1px solid;border-right:#000080 1px solid;"&gt;     &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt;       &lt;ol style="padding-bottom:0px;margin:0px;padding-left:5px;padding-right:0px;background:#ffffff;padding-top:0px;"&gt;         &lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IQueryable&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;TimeSlot&lt;/span&gt;&amp;gt; GetTimeSlots() &lt;/li&gt;          &lt;li style="background:#f3f3f3;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { &lt;/li&gt;          &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.ObjectContext.TimeSlots.Include(&lt;span style="color:#a31515;"&gt;&amp;quot;Sessions&amp;quot;&lt;/span&gt;); &lt;/li&gt;          &lt;li style="background:#f3f3f3;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/li&gt;       &lt;/ol&gt;     &lt;/div&gt;   &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- You will need also to make a small change in the RegistrationDomainService.metadata.cs file, find the &lt;strong&gt;TimeSlotMetadata &lt;/strong&gt;class and add the attribute &lt;strong&gt;[Include] &lt;/strong&gt;to&lt;strong&gt; &lt;/strong&gt;the property &lt;strong&gt;Sessions &lt;/strong&gt;as follows&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6bfe8971-56a1-41e9-94e1-19e7d7e223cc" class="wlWriterSmartContent"&gt;   &lt;div style="border-bottom:#000080 1px solid;border-left:#000080 1px solid;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;color:#000;font-size:10pt;border-top:#000080 1px solid;border-right:#000080 1px solid;"&gt;     &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt;       &lt;ol style="padding-bottom:0px;margin:0px;padding-left:5px;padding-right:0px;background:#ffffff;padding-top:0px;"&gt;         &lt;li&gt;[&lt;span style="color:#2b91af;"&gt;Include&lt;/span&gt;] &lt;/li&gt;          &lt;li style="background:#f3f3f3;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EntityCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Session&lt;/span&gt;&amp;gt; Sessions { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; } &lt;/li&gt;       &lt;/ol&gt;     &lt;/div&gt;   &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- Now back to Home.xaml in Visual Studio, from the Data Sources Tool window click the down arrow beside the &lt;strong&gt;TimeSlot &lt;/strong&gt;entity,&amp;#160; select “None” for the control used to render this entity as we will create a custom UI to represent this entity, drag and drop the &lt;strong&gt;TimeSlot &lt;/strong&gt;entity on the page, this will create the &lt;strong&gt;DomainDataSource &lt;/strong&gt;control, rename it to &lt;strong&gt;timeSlotDomainDataSource&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_28666998.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Data Sources" border="0" alt="Data Sources" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_0706C3FC.png" width="244" height="298" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- Switch back to Blend, from the assets tool window add the ItemsControl to the Home.xaml page, place it in the top right cell, rename it to &lt;strong&gt;icAgenda&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;- Right click the items control, select &lt;em&gt;Auto Size-&amp;gt;Fill.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;- &lt;/em&gt;Right click the items control, select &lt;em&gt;Data bind ItemsSource to Data, &lt;/em&gt;in the &lt;em&gt;Create Date Binding&lt;/em&gt; dialog box go to the &lt;em&gt;Element Property&lt;/em&gt; tab select the &lt;strong&gt;timeSlotDomainDataSource&lt;/strong&gt; element from the left list box and select the &lt;strong&gt;Data &lt;/strong&gt;property from the right list box.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_6CC65AD7.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Create Data Binding" border="0" alt="Create Data Binding" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_69D0F624.png" width="454" height="427" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;-&amp;#160; Right click the items control, select &lt;em&gt;Edit Additional Templates –&amp;gt; Edit Generated Items (ItemTemplate) –&amp;gt; Create Empty.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_5E0B8925.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Create ItemTemplate" border="0" alt="Create ItemTemplate" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_2ACF4FBC.png" width="454" height="84" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- In the &lt;em&gt;Create DataTemplate Resource &lt;/em&gt;dialog, set the key to &lt;strong&gt;timeSlotDataTemplate, &lt;/strong&gt;click Ok, Blend will switch to the design of the ItemTemplate which initially contain empty grid.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_41AE2138.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Create DataTemplate Resource " border="0" alt="Create DataTemplate Resource " src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_46442BF2.png" width="465" height="253" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Use the designer to add a column to the grid as follows&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_2C03C2CE.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Grid" border="0" alt="Grid" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_thumb_5F00_518D402F.png" width="369" height="421" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- In the left column add a Rectangle, set the &lt;strong&gt;Fill &lt;/strong&gt;property to white solid color brush, set the &lt;strong&gt;RadiusX&lt;/strong&gt; and &lt;strong&gt;RadiusY&lt;/strong&gt; properties to 10 to have a rounded rectangle, increase the width of the rectangle to overlap the right column (as shown below)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_0167E1F1.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Rounded Rectabgle " border="0" alt="Rounded Rectabgle " src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_thumb_5F00_6DDA824F.png" width="229" height="98" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Add another rectangle to the right column, set the &lt;strong&gt;Fill &lt;/strong&gt;property to white solid color brush, set the &lt;strong&gt;RadiusX&lt;/strong&gt; and &lt;strong&gt;RadiusY&lt;/strong&gt; properties to 10 to have a rounded rectangle, right click the rectangle select &lt;em&gt;Auto Size-&amp;gt;Fill, &lt;/em&gt;the data template should look like the below image&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_104F110B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="DataTemplate" border="0" alt="DataTemplate" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_thumb_5F00_1D48F11C.png" width="454" height="128" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- In the left column rectangle we will display the time slot start and end times (ex: 09:00 –10:00), to do this add a &lt;strong&gt;StackPanel &lt;/strong&gt;to this column, set the &lt;strong&gt;Orientation&lt;/strong&gt; to Horizontal, in the &lt;strong&gt;StackPanel&lt;/strong&gt; add 3 TextBlocks, set the Text of the middle one to “ – “, set the Text of the first one to a binding to the &lt;strong&gt;StartTime &lt;/strong&gt;property, set the Text of the third one to a binding to the &lt;strong&gt;EndTime &lt;/strong&gt;property, for both bindings use a &lt;strong&gt;StringFormat&lt;/strong&gt;=’HH:mm tt’ to display the time only, the markup for the TextBlocks is shown below&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8aa14dd9-394a-4d9c-89f4-e4598bb9d120" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; StartTime&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; StringFormat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;#39;HH:mm tt&amp;#39;}&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot; - &amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; EndTime&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; StringFormat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;#39;HH:mm tt&amp;#39;}&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- in the right column we will display all the sessions in the corresponding TimeSlot, to do this add &lt;strong&gt;ItemsControl&lt;/strong&gt; to the right column, name it &lt;strong&gt;icSessions,&lt;/strong&gt; set its &lt;strong&gt;ItemsSource &lt;/strong&gt;property to binding to the &lt;strong&gt;Sessions&lt;/strong&gt; Property.&lt;/p&gt;  &lt;p&gt;- Right click the &lt;strong&gt;icSessions&lt;/strong&gt; control, select&amp;#160; &lt;em&gt;Edit Additional Templates –&amp;gt; Edit Generated Items (ItemTemplate) –&amp;gt; Create Empty.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;- In the &lt;em&gt;Create DataTemplate Resource &lt;/em&gt;dialog, set the key to &lt;strong&gt;sessionDataTemplate, &lt;/strong&gt;click Ok, Blend will switch to the design of the ItemTemplate which initially contain empty grid.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_70538E40.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Create Data Template Resource" border="0" alt="Create Data Template Resource" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_thumb_5F00_080AC5A7.png" width="464" height="254" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- We will create a small template for the session that shows the session title, location and description, so use three textblocks and bind them to the &lt;strong&gt;Title &lt;/strong&gt;and &lt;strong&gt;Location &lt;/strong&gt;and&lt;strong&gt; Description &lt;/strong&gt;properties respectively, the xaml of the &lt;strong&gt;sessionDateTemplate&lt;/strong&gt; is shown below &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ed7911b9-b992-4a59-a841-98d5260225e7" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#a31515;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;sessionDataTemplate&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10,0,0,20&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt; &lt;span style="color:#ff0000;"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Horizontal&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot; &amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;16&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Title}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#ff0000;"&gt;TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;400&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;16&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot; - &amp;quot;/&amp;gt;    &lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;16&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Location}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;  &lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Description}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#ff0000;"&gt;Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;400&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Left&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- Try and run the application, i already have two time slots in my database, the first time slot has two sessions and the second has one session, the UI will look like the following&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_202E3002.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="the ItemsControl doesn&amp;#39;t scroll" border="0" alt="the ItemsControl doesn&amp;#39;t scroll" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_thumb_5F00_3DC00B01.png" width="484" height="253" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- As you can see the problem is that the ItemsControl doesn’t provide scrolling, we have to change the Template of the ItemsControl to support this, &lt;a href="http://www.silverlightshow.net/tips/How-to-add-scrollbars-to-ItemsControl.aspx" target="_blank"&gt;this is a pretty easy task&lt;/a&gt;, right click the &lt;strong&gt;icSessions &lt;/strong&gt;control, select &lt;em&gt;Edit Template-&amp;gt; Create Empty&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_1B1BCC86.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Edit ItemsControl Template " border="0" alt="Edit ItemsControl Template " src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_thumb_5F00_585C814D.png" width="343" height="69" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- In the &lt;em&gt;Create Control Template Resource&lt;/em&gt; name it &lt;strong&gt;ItemsControlScrollableControlTemplate&lt;/strong&gt; and click Ok&lt;/p&gt;  &lt;p&gt;- Use the following xaml for this template&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c5bc1492-92c3-4ede-b80d-569f106b83a0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;ItemsControlScrollableControlTemplate&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;ItemsControl&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ScrollViewer&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;ScrollViewer&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Padding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TemplateBinding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Padding}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; BorderThickness&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ItemsPresenter&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ScrollViewer&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ControlTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- We need also to use the same template for the outer ItemsControl (&lt;strong&gt;icAgenda&lt;/strong&gt;), to do this right click the control, select &lt;em&gt;Edit Template-&amp;gt; Apply Resource-&amp;gt; &lt;/em&gt;&amp;#160;&lt;em&gt;ItemsControlScrollableControlTemplate &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/13_5F00_7013B8B3.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Apply Control Template" border="0" alt="Apply Control Template" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/13_5F00_thumb_5F00_63A5958A.png" width="369" height="104" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Run the application, you can now scroll both the inner and the outer ItemsControl&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/14_5F00_26353103.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Scrollable ItemsControl" border="0" alt="Scrollable ItemsControl" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/14_5F00_thumb_5F00_0324BF93.png" width="454" height="152" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;See you in the next post&lt;/p&gt;  &lt;p&gt;You can download the code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-6.zip"&gt;Here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1145" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4.0 Tutorial (5 of N): More Blend!</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-5-of-n-more-blend.aspx</link><pubDate>Mon, 09 Aug 2010 11:05:57 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1142</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1142</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-5-of-n-more-blend.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Read Previous Posts: &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx" target="_blank"&gt;Part1&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx" target="_blank"&gt;Part2&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-3-of-n-working-with-the-dataform-control.aspx" target="_blank"&gt;Part3&lt;/a&gt;, &lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-4-of-n-listbox-itemtemplate.aspx" target="_blank"&gt;Part4&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Continuing our series for building a registration booth application using Silverlight 4.0, in this post we will continue working with Expression Blend&lt;/p&gt;  &lt;p&gt;- Open Home.xaml, select the &lt;strong&gt;LayoutRoot&lt;/strong&gt; grid in the Objects and Timeline window, set the &lt;strong&gt;Width&lt;/strong&gt; and &lt;strong&gt;Height &lt;/strong&gt;properties to &lt;strong&gt;Auto &lt;/strong&gt;so that the grid takes all the screen size.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_60117A57.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Set to Auto" border="0" alt="Set to Auto" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_691E05D8.png" width="281" height="93" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- Now we will change the background color of the page, select the &lt;strong&gt;LayoutRoot &lt;/strong&gt;grid, go to the &lt;strong&gt;Background&lt;/strong&gt; property and select the &lt;strong&gt;Gradient Brush&lt;/strong&gt; option.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_55247342.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Gradient Brush Editor" border="0" alt="Gradient Brush Editor" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_0AD9B89D.png" width="259" height="135" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- The Gradient brush we will use will have three gradient stops, you can click on the gradient bar (below the color mixer) to add a gradient stop at the specified offset, to remove a gradient stop click, hold, and drag your mouse off the gradient bar. for each gradient stop you can specify the color (RGB, Alpha).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_7BC2D9C2.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Creating Gradient Brush" border="0" alt="Creating Gradient Brush" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_0058E47D.png" width="264" height="355" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- The xaml for the grid background will be as follows. &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8afe62c4-f633-45ac-b057-bffc14b897bd" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;       &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; EndPoint&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.5,0.998&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; StartPoint&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.5,0&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;GradientStop&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Color&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;#FF052744&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Offset&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;GradientStop&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Color&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;#FF052744&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Offset&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.02&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;GradientStop&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Color&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;#7F256FB7&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Offset&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;       &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;LinearGradientBrush&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- We will do another change, we will change the font of the &lt;strong&gt;TextBlocks, &lt;/strong&gt;to do this add a &lt;strong&gt;TextBlock&lt;/strong&gt; to the Home.xaml page, right click the &lt;strong&gt;TextBlock, &lt;/strong&gt;select &lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;em&gt;Edit Style-&amp;gt; Create Empty &lt;/em&gt;a dialog box will appear to allow you to change the properties of the new style resource, Choosing the &lt;em&gt;Apply to all&lt;/em&gt; means that this style will be applied to all the text blocks (this is a new feature in Silverlight called implicit styles).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_2BBD0577.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Create Style" border="0" alt="Create Style" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_345D5E03.png" width="465" height="252" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;-&lt;/strong&gt; change the font family to Freestyle script and the font size to 30pt.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_00B4F1A5.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Font" border="0" alt="Font" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_6D93C4F8.png" width="337" height="221" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Run the application, you will see that the TextBlocks inside the ListBox didn’t change, this is due to a &lt;strike&gt;limitation&lt;/strike&gt; design issue related to the DateTemplate (more details in &lt;a href="http://mosalem.blogspot.com/2010/07/silverlight-40-implicit-styles-not-so.html" target="_blank"&gt;this post&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;- To resolve this we need to define the implicit style inside the data template, so move the style definition from the Page.Resources to the Grid.Resources section inside the data template. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_10E0B99E.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="DateTemplate Implicit Style" border="0" alt="DateTemplate Implicit Style" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_thumb_5F00_4514E2E4.png" width="484" height="138" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- We need also to change the style of the labels inside the DataForm, the DataField control that we use inside the DataForm NewItemTemplate renders a Label control for the display name not a TextBlock so we will add a style with the same properties that we used in the previous style but we will set the TargetType property to the value “dataInput:Label” which represent the Label control defined in the System.Windows.Controls.Data.Input assembly (don’t forget to add xml prefix “dataInput” in the page tag), the NewItemTemplate definition should be as follows.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_7C7AF412.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="NewItemTemplate Style" border="0" alt="NewItemTemplate Style" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_thumb_5F00_1AE534FC.png" width="484" height="170" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it for this post, see you in the next post&lt;/p&gt;  &lt;p&gt;You can download the code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-5.zip" target="_blank"&gt;Here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1142" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4.0 Tutorial (4 of N): ListBox ItemTemplate</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-4-of-n-listbox-itemtemplate.aspx</link><pubDate>Mon, 09 Aug 2010 10:57:47 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1139</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1139</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-4-of-n-listbox-itemtemplate.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx" target="_blank"&gt;Read Part 1&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx" target="_blank"&gt;Read Part 2&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-3-of-n-working-with-the-dataform-control.aspx" target="_blank"&gt;Read Part 3&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Continuing our &lt;strong&gt;RegistrationBooth&lt;/strong&gt; Application, if you take a look at what we ended with you will find that the attendees data grid that we have is not user friendly, our application should be more attractive to the users, so we will get rid of the data grid and we will use a List box that has a custom template for displaying attendees, in this post we will start using Blend to assist in designing the application UI&lt;/p&gt;  &lt;p&gt;- Right click the xaml file in Visual Studio and choose &lt;strong&gt;Open in Expression Blend&lt;/strong&gt;, this will open your solution in Blend.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_43E79BB1.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Open in Epression Blend" border="0" alt="Open in Epression Blend" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_40860409.png" width="384" height="148" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Delete the &lt;strong&gt;attendeeDataGrid &lt;/strong&gt;from the &lt;strong&gt;Home.xaml &lt;/strong&gt;file.&lt;/p&gt;  &lt;p&gt;- We will change the layout of the form we will use a grid with two columns the width of the first one is about third of the screen width and we will put the list box in this column, and the second column take the remaining screen width and this is where we will put the attendees data form.&lt;/p&gt;  &lt;p&gt;- To do this, go to the Objects and Timeline window (if not visible go to Menu Window-&amp;gt;Objects and Timeline), select the &lt;strong&gt;LayoutRoot &lt;/strong&gt;Grid, the grid will be highlighted on the design surface (or the art board in the designers lingo), you can see also a small grid icon located in the top left corner of the grid, and you can see two semi-transparent lines one horizontal and one vertical, if you move the mouse over any of these lines, a line will be drawn across the grid and once you click.. a row/column definition will be added to the grid, so you can easily add columns/rows using this way. so we will add a column to this grid, the column should take about the third of the grid width. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_2B47D894.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Grid Rows and Columns" border="0" alt="Grid Rows and Columns" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_69CD263A.png" width="144" height="114" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- We will move the &lt;strong&gt;StackPanel&lt;/strong&gt; that contains the new attendee data form (&lt;strong&gt;dfAttendee&lt;/strong&gt;) and the button to the right column, to do this select the &lt;strong&gt;StackPanel&lt;/strong&gt; in the Objects and Timeline window, go to the properties window and find the &lt;strong&gt;Column &lt;/strong&gt;property under the &lt;strong&gt;Layout&lt;/strong&gt; category and set it to 1, this will move the &lt;strong&gt;StackPanel &lt;/strong&gt;to the right column.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;To easily find properties in the properties window you can use the&amp;#160; search textbox in that window which allows you to type any text and the properties window will be filtered to show the properties that start with the text you wrote in the search text box&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_0CADE7EB.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Properties window search textbox" border="0" alt="Properties window search textbox" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_0AFD1C17.png" width="283" height="181" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- To add a ListBox, expand the assets window by clicking on the right arrow located in the bottom of the tools window, drag and drop a ListBox control into the left hand side column&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_7E22C5F8.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Assets Window" border="0" alt="Assets Window" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_7AC12E50.png" width="484" height="187" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Select the ListBox, by pressing the “V” key or selecting the Selection tool from the tools window.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_2B080307.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="5" border="0" alt="5" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_7118C01A.png" width="109" height="97" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- From the tools window, set the Name of the ListBox to be &lt;strong&gt;lstAttendees, &lt;/strong&gt;then right click the ListBox &lt;strong&gt;Auto Size-&amp;gt;Fill &lt;/strong&gt;to make the ListBox fills the whole column area.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_21CBC7C6.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Change Size to Fill" border="0" alt="Change Size to Fill" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_thumb_5F00_201AFBF2.png" width="389" height="243" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- To add the data binding, right click the ListBox&lt;strong&gt;, &lt;/strong&gt;select “Data bind ItemsSource to Data…”, the data binding dialog will appear, go to the Element Property tab, select the &lt;strong&gt;attendeeDomainDataSource &lt;/strong&gt;from the scene elements list on the left, and select the &lt;strong&gt;Data &lt;/strong&gt;property from the Properties&lt;strong&gt; &lt;/strong&gt;list on the right.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_251D39A1.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Create Data Binding" border="0" alt="Create Data Binding" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_thumb_5F00_3C683E12.png" width="484" height="195" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- If you run the application now, you will find the items in the ListBox is rendered as string that contains the name of the class and the ID, this is because we didn’t specify to the ListBox how we want to render the ListBox Item, to do this we need to set the &lt;strong&gt;ItemTemplate&lt;/strong&gt; property.&lt;/p&gt;  &lt;p&gt;- To do this, right click the &lt;strong&gt;ListBox Edit Additional Template –&amp;gt; Edit Generated Items (ItemTemplate)-&amp;gt; Create Empty&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_6FC4016E.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Edit ListBox ItemTemplate" border="0" alt="Edit ListBox ItemTemplate" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_thumb_5F00_2F21B4FF.png" width="484" height="80" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- In the &lt;strong&gt;Create DataTemplate&lt;/strong&gt;&amp;#160;&lt;strong&gt;Resource &lt;/strong&gt;Dialog, name it &lt;strong&gt;attendeeDateTemplate, &lt;/strong&gt;once you click Ok,&lt;strong&gt; &lt;/strong&gt;Blend will allow you to design the &lt;strong&gt;DataTemplate &lt;/strong&gt;which will determine the UI used to display the &lt;strong&gt;Attendee &lt;/strong&gt;object.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_5C36A1CD.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Create DataTemplate Resource" border="0" alt="Create DataTemplate Resource" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_thumb_5F00_06A2D2EB.png" width="472" height="258" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- A new empty design surface will be shown that represents the &lt;strong&gt;DataTemplate&lt;/strong&gt;, initially there’s only empty grid as you can in the &lt;strong&gt;Objects and Timeline&lt;/strong&gt; window. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_73EDD933.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Empty DataTemplate" border="0" alt="Empty DataTemplate" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_thumb_5F00_6C6269C6.png" width="244" height="135" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can go back to the page design by clicking on the Up arrow in the &lt;strong&gt;Objects and Timeline&lt;/strong&gt; window or by clicking on the ListBox name (&lt;strong&gt;lstAttendees&lt;/strong&gt;) in the breadcrumb menu at top of the design surface&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_12581A1D.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Editing the DataTemplate" border="0" alt="Editing the DataTemplate" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_thumb_5F00_43E387B2.png" width="228" height="59" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- We will create a simple UI for the attendee, where we&amp;#39;ll display the image, last name, first name and company, the xaml for the &lt;strong&gt;DataTemplate&lt;/strong&gt; is shown below&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:840c7895-c076-468b-9a22-74bcdae1268d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;attendeeDataTemplate&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; d&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;DesignWidth&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;320&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; d&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;DesignHeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;112&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.3*&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.3*&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.3*&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.35*&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0.65*&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Image&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Source&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=Photo,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Converter&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;={&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; imageConverter}}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.RowSpan&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; MaxWidth&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;110&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; MaxHeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;110&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Company}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Email}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Horizontal&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,8&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FirstName}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,8,0,16&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot; &amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,8&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextWrapping&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Wrap&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; LastName}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- Note how the text blocks are bound to the different properties of the &lt;strong&gt;Attendee&lt;/strong&gt; class, and the Image control is bound to the &lt;strong&gt;Photo&lt;/strong&gt; property using the &lt;strong&gt;ImageConverter&lt;/strong&gt; we used before.&lt;/p&gt;  &lt;p&gt;-&amp;#160; Run the application and see how the list box looks like.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/12_5F00_03413B43.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="The ListBox in action" border="0" alt="The ListBox in action" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/12_5F00_thumb_5F00_773F4B0E.png" width="454" height="138" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;See you in the next post :)&lt;/p&gt;  &lt;p&gt;You can download the code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth.-4.zip" target="_blank"&gt;Here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1139" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4.0 Tutorial (3 of N): Working with the DataForm Control</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-3-of-n-working-with-the-dataform-control.aspx</link><pubDate>Mon, 09 Aug 2010 10:53:37 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1136</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1136</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-3-of-n-working-with-the-dataform-control.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx" target="_blank"&gt;Read Part 1&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx" target="_blank"&gt;Read Part 2&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Continuing our &lt;strong&gt;RegistrationBooth&lt;/strong&gt; Application, in the previous post we ended having a data grid that displays all the attendees, and a user control to add a new attendee.&lt;/p&gt;  &lt;p&gt;The user control for adding a new attendee didn’t contain any validation logic, of course this is a bad practice, in this post we will add the necessary validation when creating adding new attendees.&lt;/p&gt;  &lt;p&gt;- First we will need to define our validation logic for the &lt;strong&gt;Attendee &lt;/strong&gt;entity, if you remember our first post when we created the Domain Service class we choose to create metadata classes for our entities, you can read more about metadata classes in the RIA services documentation (&lt;a href="http://msdn.microsoft.com/en-us/library/ee707339(v=VS.91).aspx" target="_blank"&gt;How To Add Metadata Classes&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_53443BC3.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="3" border="0" alt="3" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_3A18BBBE.png" width="460" height="552" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- In the &lt;strong&gt;RegistrationBooth.Web &lt;/strong&gt;project the file &lt;strong&gt;RegistrationDomainService.metadata.cs &lt;/strong&gt;contains the metadata classes, we will change the &lt;strong&gt;AttendeeMetadata &lt;/strong&gt;class to add some validation attributes to the different Attendee properties, you can read more about validation attributes at &lt;a href="http://msdn.microsoft.com/en-us/library/ee707335(VS.91).aspx" target="_blank"&gt;How To Validate Data&lt;/a&gt;, the final &lt;strong&gt;AttendeeMetadata &lt;/strong&gt;should be as follows&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2727fd23-63f7-4ffd-a5db-dcadef6b905b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;internal&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;sealed&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;AttendeeMetadata&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; AttendeeMetadata()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            [&lt;span style="color:#2b91af;"&gt;Required&lt;/span&gt;(ErrorMessage = &lt;span style="color:#a31515;"&gt;&amp;quot;You must enter company name&amp;quot;&lt;/span&gt;, AllowEmptyStrings = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;)]&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            [&lt;span style="color:#2b91af;"&gt;Display&lt;/span&gt;( Name=&lt;span style="color:#a31515;"&gt;&amp;quot;Company Name&amp;quot;&lt;/span&gt;,Description=&lt;span style="color:#a31515;"&gt;&amp;quot;Name of your company&amp;quot;&lt;/span&gt;)]&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Company { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt; CreationDate { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            [&lt;span style="color:#2b91af;"&gt;Required&lt;/span&gt;(ErrorMessage = &lt;span style="color:#a31515;"&gt;&amp;quot;You must enter email&amp;quot;&lt;/span&gt;, AllowEmptyStrings = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;)]&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            [&lt;span style="color:#2b91af;"&gt;Display&lt;/span&gt;( Name = &lt;span style="color:#a31515;"&gt;&amp;quot;Email&amp;quot;&lt;/span&gt;,Description=&lt;span style="color:#a31515;"&gt;&amp;quot;your Email Address&amp;quot;&lt;/span&gt;)]&lt;/li&gt; &lt;li&gt;            [&lt;span style="color:#2b91af;"&gt;RegularExpression&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;@&amp;quot;&amp;#92;w+([-+.&amp;#39;]&amp;#92;w+)*@&amp;#92;w+([-.]&amp;#92;w+)*&amp;#92;.&amp;#92;w+([-.]&amp;#92;w+)*&amp;quot;&lt;/span&gt;, ErrorMessage=&lt;span style="color:#a31515;"&gt;&amp;quot;Invalid email format&amp;quot;&lt;/span&gt;)] &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Email { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            [&lt;span style="color:#2b91af;"&gt;Required&lt;/span&gt;(ErrorMessage=&lt;span style="color:#a31515;"&gt;&amp;quot;You must enter first name&amp;quot;&lt;/span&gt;,AllowEmptyStrings=&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;)]&lt;/li&gt; &lt;li&gt;            [&lt;span style="color:#2b91af;"&gt;Display&lt;/span&gt;( Name = &lt;span style="color:#a31515;"&gt;&amp;quot;First Name&amp;quot;&lt;/span&gt;,Description=&lt;span style="color:#a31515;"&gt;&amp;quot;Your First Name&amp;quot;&lt;/span&gt;)]&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; FirstName { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; Id { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            [&lt;span style="color:#2b91af;"&gt;Required&lt;/span&gt;(ErrorMessage = &lt;span style="color:#a31515;"&gt;&amp;quot;You must enter last name&amp;quot;&lt;/span&gt;, AllowEmptyStrings = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;)]&lt;/li&gt; &lt;li&gt;            [&lt;span style="color:#2b91af;"&gt;Display&lt;/span&gt;( Name = &lt;span style="color:#a31515;"&gt;&amp;quot;Last Name&amp;quot;&lt;/span&gt;,Description=&lt;span style="color:#a31515;"&gt;&amp;quot;Your Last Name&amp;quot;&lt;/span&gt;)]&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; LastName { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] Photo { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EntityCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;SessionAttendee&lt;/span&gt;&amp;gt; SessionAttendees { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- We added &lt;strong&gt;RequriedAttribute &lt;/strong&gt;for the required properties and specified the error messages that should appear if a required property is missing, the &lt;strong&gt;DisplayAttribute &lt;/strong&gt;is used to provide the name (that is used as the label of the corresponding control) and the description (which appears as a ToolTip against the corresponding control), we also used a &lt;strong&gt;RegularExpressionAttribute &lt;/strong&gt;for the email property to make sure that the users enter only valid email addresses.&lt;/p&gt;  &lt;p&gt;- These metadata classes are automatically copied to the Silverlight project and compiled as part of the Silverlight application, to see this go to the &lt;strong&gt;RegistrationBooth &lt;/strong&gt;project and show all the files, you will find a folder called &lt;strong&gt;Generated_Code, &lt;/strong&gt;inside this folder you will find a file &lt;strong&gt;RegistrationBooth.Web.g.cs&lt;/strong&gt; that contains all the classes defined on the server and shared by the client, this sharing of code allows the validation that we specified by the attributes to run directly on the client side. &lt;/p&gt;  &lt;p&gt;- Now our entity class has the necessary metadata required for validation, let’s see how we will make use of this in creating our UI.&lt;/p&gt;  &lt;p&gt;- We will use the &lt;strong&gt;DataForm&lt;/strong&gt; control, the &lt;strong&gt;DataForm &lt;/strong&gt;control can read the data annotations specified on the object class that this control is bound to. &lt;/p&gt;  &lt;p&gt;- So to start open &lt;strong&gt;Home.xaml&lt;/strong&gt; and delete the user control and the Save button, also delete the &lt;strong&gt;btnSave_Click &lt;/strong&gt;method.&lt;/p&gt;  &lt;p&gt;- From the toolbox drag and drop a &lt;strong&gt;DataForm&lt;/strong&gt; control on the page, name it &lt;strong&gt;dfAttendee&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;- Set the &lt;strong&gt;ItemsSource&lt;/strong&gt; property to a binding to the element &lt;strong&gt;attendeeDomainDataSource &lt;/strong&gt;and the Path is the &lt;strong&gt;Data &lt;/strong&gt;property&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_77597085.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="DataForm ItemsSource Binding" border="0" alt="DataForm ItemsSource Binding" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_7CC7E129.png" width="482" height="273" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Because we will use the &lt;strong&gt;DataForm&lt;/strong&gt; only for adding new items, we need to show only the save button, we can control what buttons (Add, Edit, Delete, Navigation, etc) should appear on the &lt;strong&gt;DataForm&lt;/strong&gt; using the &lt;strong&gt;CommandButtonsVisibility&lt;/strong&gt; property, so we will set this property to &lt;strong&gt;Commit.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;- &lt;/strong&gt;To&lt;strong&gt; &lt;/strong&gt;make the &lt;strong&gt;DataForm&lt;/strong&gt; open in “AddNew” mode, write the following line of code in the &lt;strong&gt;Page_Loaded&lt;/strong&gt; event handler &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b51c0879-5ffb-4f35-983d-f1f5d7efbd77" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Page_Loaded(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            dataForm1.AddNewItem();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- The &lt;strong&gt;DataForm&lt;/strong&gt; control can automatically create a UI based on the properties of the entity that it’s bound too, but we will not use this default template because for the &lt;strong&gt;Photo &lt;/strong&gt;property of the &lt;strong&gt;Attendee &lt;/strong&gt;class we need to make use of the Web Cam to capture the image, so we will create a custom template for Adding Items, in the &lt;strong&gt;DataForm &lt;/strong&gt;control you can specify different template for each mode so you can have a template for the view, template for the edit and a template for adding new item, in our case we need only the new item template.&lt;/p&gt;  &lt;p&gt;- We will copy the same controls we had in the &lt;strong&gt;RegisterAttendee &lt;/strong&gt;user control, we will bound the text boxes to the corresponding attendee properties, we will put each text box inside a &lt;strong&gt;DataField.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;- &lt;/strong&gt;The complete markup of the &lt;strong&gt;DataForm &lt;/strong&gt;is shown below&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2e25e038-4f99-4071-83d7-57bb6b88ad3f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataForm&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;dfAttendee&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; CommandButtonsVisibility&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Commit&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;             &lt;span style="color:#ff0000;"&gt; ItemsSource&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; ElementName&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=attendeeDomainDataSource,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=Data}&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                  &lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;273&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;545&amp;quot;&lt;/span&gt;          &lt;span style="color:#0000ff;"&gt; &amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataForm.NewItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;25*&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;   &lt;span style="color:#a31515;"&gt;                            &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot; &amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,12,0,0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FirstName&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay}&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li&gt;                &lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;120&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot; &amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt; &lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,12,0,0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; LastName&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay}&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li&gt;                &lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;120&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;2&amp;quot; &amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt; &lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,12,0,0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Email&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay}&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li&gt;                &lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;120&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;3&amp;quot; &amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox&lt;/span&gt; &lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;23&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Left&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,12,0,0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Company&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay}&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li&gt;                &lt;span style="color:#ff0000;"&gt; VerticalAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Top&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;120&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;dfPhoto&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;4&amp;quot; &amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;20*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;10*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;20*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Rectangle&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;videoStream&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot; &amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Rectangle&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ToggleButton&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;30&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,41,0,62&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;btnStart&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;btnStart_Click&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Start&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ToggleButton&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;30&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0,77,0,26&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;btnCapture&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;btnCapture_Click&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Capture&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Image&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;capturedImage&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Source&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=Photo,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Mode&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=TwoWay,&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Converter&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;={&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; imageConverter}}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Column&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;2&amp;quot; &amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Image&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataField&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataForm.NewItemTemplate&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;toolkit&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;DataForm&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- if you examine the &lt;strong&gt;Image &lt;/strong&gt;control at the end of the template you can see that this control is bound to the &lt;strong&gt;Photo &lt;/strong&gt;property and it uses the &lt;strong&gt;ImageConverter&lt;/strong&gt; class to do the conversion, we introduced the &lt;strong&gt;ImageConverter&lt;/strong&gt; class in the first post and we implemented the &lt;strong&gt;Convert&lt;/strong&gt; method that converts the &lt;strong&gt;Photo &lt;/strong&gt;property which is a byte array to a bitmap that can be displayed in the Image control, now when we are adding a new item there will be already an image in the Image control (that we will capture using the web cam) so now we need to convert the bitmap from the Image control to a byte array that will be assigned to the &lt;strong&gt;Photo &lt;/strong&gt;property, so we need to implement the second method of the Converter which is the &lt;strong&gt;ConvertBack &lt;/strong&gt;method&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:573301e8-dc2b-4059-86a3-f355daae4341" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; ConvertBack(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; value, &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; parameter, &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            System.Globalization.&lt;span style="color:#2b91af;"&gt;CultureInfo&lt;/span&gt; culture)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;             &lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; bitmap = value &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;WriteableBitmap&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; img = bitmap.ToImage();&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] ba;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; encoder = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PngEncoder&lt;/span&gt;();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;MemoryStream&lt;/span&gt; stream = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MemoryStream&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;            encoder.Encode(img, stream);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            ba = stream.ToArray();&lt;/li&gt; &lt;li&gt;            stream.Close();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; ba;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- Now we need to write the event handlers for the two buttons (btnStart, btnCapture) which are inside the new item template, the code is shown below.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:474bf1bf-a4eb-4974-abb4-7a1d76f32266" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnStart_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            ToggleButton btnStart = sender &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; ToggleButton;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (btnStart.IsChecked.Value)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                StartWebcam();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                btnStart.Content = &lt;span style="color:#a31515;"&gt;&amp;quot;Stop&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                StopWebcam();&lt;/li&gt; &lt;li&gt;                btnStart.Content = &lt;span style="color:#a31515;"&gt;&amp;quot;Start&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CaptureSource&lt;/span&gt; cs = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnCapture_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            cs.CaptureImageAsync();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; StartWebcam()&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.AllowedDeviceAccess ||&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.RequestDeviceAccess())&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#2b91af;"&gt;VideoCaptureDevice&lt;/span&gt; vcd = &lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.GetDefaultVideoCaptureDevice();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != vcd)&lt;/li&gt; &lt;li&gt;                {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    cs = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CaptureSource&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;                    cs.VideoCaptureDevice = vcd;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    cs.Start();&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#2b91af;"&gt;VideoBrush&lt;/span&gt; videoBrush = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;VideoBrush&lt;/span&gt;();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    videoBrush.Stretch = &lt;span style="color:#2b91af;"&gt;Stretch&lt;/span&gt;.UniformToFill;&lt;/li&gt; &lt;li&gt;                    videoBrush.SetSource(cs);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#2b91af;"&gt;Rectangle&lt;/span&gt; videoStream = dfAttendee.FindNameInContent(&lt;span style="color:#a31515;"&gt;&amp;quot;videoStream&amp;quot;&lt;/span&gt;) &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Rectangle&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    videoStream.Fill = videoBrush;&lt;/li&gt; &lt;li&gt;                    cs.CaptureImageCompleted += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;CaptureImageCompletedEventArgs&lt;/span&gt;&amp;gt;(cs_CaptureImageCompleted);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                }&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                {&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#2b91af;"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color:#a31515;"&gt;&amp;quot;Error initializing Webcam&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                }&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; StopWebcam()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != cs)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                cs.Stop();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; cs_CaptureImageCompleted(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;CaptureImageCompletedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;Image&lt;/span&gt; capturedImage = dfAttendee.FindNameInContent(&lt;span style="color:#a31515;"&gt;&amp;quot;capturedImage&amp;quot;&lt;/span&gt;) &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Image&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;            capturedImage.Source = e.Result;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- The code is almost identical to the code that we had inside the user control, except for the way we access the controls inside the template, for example the rectangle that displays the live stream of the web cam (videoStream) to get a reference to this rectangle we use the &lt;strong&gt;DataForm &lt;/strong&gt;method &lt;strong&gt;FindNameInContent. &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;- As we mentioned previously to push the changes done locally to the server we need to call the domain data source &lt;strong&gt;SubmitChanges &lt;/strong&gt;method, so whenever we click the Ok button in the &lt;strong&gt;DataForm &lt;/strong&gt;we will call the &lt;strong&gt;SubmitChanges &lt;/strong&gt;method to immediately submit the new attendee to the server, we can do this by adding an event handler to the &lt;strong&gt;DataForm EditEnded&lt;/strong&gt; event, as shown below&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9d7012d4-5b83-4ab1-831e-416b341a6320" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; dfAttendee_EditEnded(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;DataFormEditEndedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (e.EditAction == &lt;span style="color:#2b91af;"&gt;DataFormEditAction&lt;/span&gt;.Commit)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                attendeeDomainDataSource.SubmitChanges();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- Run the application and examine the labels of the controls and the tooltip that shows the description of each property.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_4FD27E4E.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Automatic Description Tooltip" border="0" alt="Automatic Description Tooltip" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_58DF09CF.png" width="424" height="139" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Try to save without entering any data to see the client side validation in action.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_733EFCE6.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Automatic Validation" border="0" alt="Automatic Validation" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_32307D82.png" width="424" height="214" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- The only thing missing is printing the name tag for the attendee, to do this add event handler for the domain data source &lt;strong&gt;SubmittedChanges &lt;/strong&gt;event, this event is called after the &lt;strong&gt;SubmitChanges&lt;/strong&gt; method is executed at the server, in this event handler we check to see if the attendee was successfully saved then we print the name tag, the code is shown below&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:df5552f9-73a5-4873-8b55-2dc7bc7b6648" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt; newAttendee;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; attendeeDomainDataSource_SubmittedChanges(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;SubmittedChangesEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (e.ChangeSet.AddedEntities.Count &amp;gt; 0 &amp;amp;&amp;amp; e.HasError ==&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                newAttendee = e.ChangeSet.AddedEntities[0] &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (newAttendee != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;                {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt; document = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;                    document.PrintPage += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; System.&lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;PrintPageEventArgs&lt;/span&gt;&amp;gt;(document_PrintPage);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    document.Print(&lt;span style="color:#a31515;"&gt;&amp;quot;Attendee_&amp;quot;&lt;/span&gt; + newAttendee.Id);&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- Unfortunately this code will not work, you will get Exception “Dialogs must be user-initiated” this is a Silverlight 4 built-in security measure (read more &lt;a href="http://msdn.microsoft.com/en-us/library/cc972657(VS.95).aspx" target="_blank"&gt;here&lt;/a&gt;), to resolve this issue we will change our code to show a button once the attendee is saved and we will move the printing code to this button &lt;strong&gt;Click&lt;/strong&gt; event handler, the modified code is shown below&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6cf4a9a2-fb02-40ed-b2fb-e3819b909d4f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Content&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Print Name Tag&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;200&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                   &lt;span style="color:#ff0000;"&gt; Click&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;btnPrintNameTag_Click&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;btnPrintNameTag&amp;quot;&lt;/span&gt; &lt;/li&gt; &lt;li&gt;                   &lt;span style="color:#ff0000;"&gt; Visibility&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Collapsed&amp;quot; &amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Button&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:eb0d8193-3990-43f0-ba59-c031ea7641bd" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt; newAttendee;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; attendeeDomainDataSource_SubmittedChanges(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;SubmittedChangesEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (e.ChangeSet.AddedEntities.Count &amp;gt; 0 &amp;amp;&amp;amp; e.HasError ==&lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                newAttendee = e.ChangeSet.AddedEntities[0] &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (newAttendee != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;                {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    btnPrintNameTag.Visibility = &lt;span style="color:#2b91af;"&gt;Visibility&lt;/span&gt;.Visible;&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnPrintNameTag_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt; document = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;            document.PrintPage += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; System.&lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;PrintPageEventArgs&lt;/span&gt;&amp;gt;(document_PrintPage);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            document.Print(&lt;span style="color:#a31515;"&gt;&amp;quot;Attendee_&amp;quot;&lt;/span&gt; + newAttendee.Id);&lt;/li&gt; &lt;li&gt;            btnPrintNameTag.Visibility = &lt;span style="color:#2b91af;"&gt;Visibility&lt;/span&gt;.Collapsed;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;That’s all for this post, next time we will continue :).&lt;/p&gt;  &lt;p&gt;You can download the code from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-3.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1136" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4.0 Tutorial (2 of N)</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx</link><pubDate>Mon, 09 Aug 2010 10:48:04 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1134</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1134</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-2-of-n.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;&lt;a href="http://devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx" target="_blank"&gt;Read Part 1 here&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Continuing our &lt;strong&gt;RegistrationBooth&lt;/strong&gt; Application, in the previous post we ended having a data grid that displays all the attendees, let’s now implement the interface for registering a new attendee&lt;/p&gt;  &lt;p&gt;- We will create a user control for registering a new attendee, right click the &lt;strong&gt;Views&lt;/strong&gt; folder in the&lt;strong&gt; RegistrationBooth &lt;/strong&gt;project, select add new item, choose &lt;strong&gt;Silverlight User Control &lt;/strong&gt;and name it &lt;strong&gt;RegisterAttendee.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;- &lt;/strong&gt;Use the VS designer to add two columns for the &lt;strong&gt;LayoutRoot &lt;/strong&gt;grid, one for the labels of the controls and the other for the controls, create also five rows for the different properties.&lt;/p&gt;  &lt;p&gt;- Add the four labels and four text boxes to the first four rows of the grid, these controls will be used for the FirstName, LastName, Email and company properties.&lt;/p&gt;  &lt;p&gt;- The fifth row will be for the photo, will use the Silverlight 4.0 new feature that allows us to access the webcam, so add a “Photo” label in the first column of this row, and in the second column add a Grid with three columns, put a rectangle in the first column, the second column should contain a &lt;strong&gt;ToggleButton&lt;/strong&gt; (&lt;strong&gt;Start) &lt;/strong&gt;and &lt;strong&gt;Capture&lt;/strong&gt; button, and put image control in the third column.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;- &lt;/strong&gt;What we will do is that:&lt;/p&gt;  &lt;p&gt;1- When the user clicks the &lt;strong&gt;Start&lt;/strong&gt; button, we will start displaying the video stream coming from the default web cam attached and display this video stream in the left rectangle.&lt;/p&gt;  &lt;p&gt;2- When the users clicks the &lt;strong&gt;Capture&lt;/strong&gt; button we will take a snapshot of the web cam video stream and display it in the image control to use it as a picture of the attendee&lt;/p&gt;  &lt;p&gt;- The final UI should look like the following&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/15_5F00_731976FF.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="15" border="0" alt="15" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/15_5F00_thumb_5F00_111784F4.png" width="244" height="191" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- Add events handlers for the &lt;strong&gt;Start&lt;/strong&gt; and &lt;strong&gt;Capture&lt;/strong&gt; buttons click events&lt;/p&gt;  &lt;p&gt;- Modify the code to be as follows &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b4ed8c9c-eb68-4a08-8abb-ffcc4ef6b1ba" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:400px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CaptureSource&lt;/span&gt; cs = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnStart_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (btnStart.IsChecked.Value)&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                StartWebcam();&lt;/li&gt; &lt;li&gt;                btnStart.Content = &lt;span style="color:#a31515;"&gt;&amp;quot;Stop&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                StopWebcam();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                btnStart.Content = &lt;span style="color:#a31515;"&gt;&amp;quot;Start&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnCapture_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            cs.CaptureImageAsync();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; StartWebcam()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.AllowedDeviceAccess || &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.RequestDeviceAccess())&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#2b91af;"&gt;VideoCaptureDevice&lt;/span&gt; vcd = &lt;span style="color:#2b91af;"&gt;CaptureDeviceConfiguration&lt;/span&gt;.GetDefaultVideoCaptureDevice();&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != vcd)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                {&lt;/li&gt; &lt;li&gt;                    cs = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;CaptureSource&lt;/span&gt;();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    cs.VideoCaptureDevice = vcd;&lt;/li&gt; &lt;li&gt;                    cs.Start();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#2b91af;"&gt;VideoBrush&lt;/span&gt; videoBrush = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;VideoBrush&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;                    videoBrush.Stretch = &lt;span style="color:#2b91af;"&gt;Stretch&lt;/span&gt;.UniformToFill;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    videoBrush.SetSource(cs);&lt;/li&gt; &lt;li&gt;                    videoStream.Fill = videoBrush;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    cs.CaptureImageCompleted += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;CaptureImageCompletedEventArgs&lt;/span&gt;&amp;gt;(cs_CaptureImageCompleted);&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#2b91af;"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="color:#a31515;"&gt;&amp;quot;Error initializing Webcam&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; StopWebcam()&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt; != cs)&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                cs.Stop();&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; cs_CaptureImageCompleted(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;CaptureImageCompletedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            capturedImage.Source = e.Result;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- The code is pretty easy,first we request access to the device this will prompt the user requesting his approval for the webcam, after that we initialize a new &lt;strong&gt;CaptureSource &lt;/strong&gt;object and set its &lt;strong&gt;VideoCaptureDevice&lt;/strong&gt; to the default device, then we create a new &lt;strong&gt;VideoBrush&lt;/strong&gt; that uses the capture source we created, then we use this brush to paint the rectangle, we also attach an event handler to the &lt;strong&gt;CaptureImageCompleted &lt;/strong&gt;event so that we set the our image control &lt;strong&gt;Source&lt;/strong&gt; to the image that we will capture (when we click the capture button).&lt;/p&gt;  &lt;p&gt;- Include the user control in the &lt;strong&gt;Home.xaml&lt;/strong&gt; page, put it below the data grid.&lt;/p&gt;  &lt;p&gt;- Build and run the application, you will be able to start/stop the web cam and capture an image to be displayed in the image control.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/26_5F00_103F1F0A.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="26" border="0" alt="26" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/26_5F00_thumb_5F00_3B370D0F.png" width="244" height="217" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- Let’s start writing the code that will actually saves the attendee to the database, add the following code to the &lt;strong&gt;RegisterAttendee&lt;/strong&gt; user control, this code define some properties that retrieves the values of the controls on the user control.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:384a788e-a6f0-421d-9ce2-fffc89647f4b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; FirstName { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; txtFirstName.Text; } }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; LastName { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; txtLastName.Text; } }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Company { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; txtCompany.Text; } }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Email { &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; txtEmail.Text; } }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] Photo&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (capturedImage.Source == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; bitmap = capturedImage.Source &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;WriteableBitmap&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; img = bitmap.ToImage();&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] ba;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; encoder = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PngEncoder&lt;/span&gt;();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#2b91af;"&gt;MemoryStream&lt;/span&gt; stream = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MemoryStream&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;                encoder.Encode(img, stream);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                ba = stream.ToArray();&lt;/li&gt; &lt;li&gt;                stream.Close();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; ba;&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- the &lt;strong&gt;Photo &lt;/strong&gt;property make use of the &lt;a href="http://imagetools.codeplex.com/" target="_blank"&gt;ImageTools for Silverlight&lt;/a&gt; library, so make sure to download these dlls and reference them in the project.&lt;/p&gt;  &lt;p&gt;- Back to the &lt;strong&gt;Home.xaml &lt;/strong&gt;page, add a button &lt;strong&gt;Save&lt;/strong&gt; below the user control.&lt;/p&gt;  &lt;p&gt;- Double click the Save button and add the following code to the &lt;strong&gt;Click&lt;/strong&gt; event handler&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0447885b-f4ae-4875-9782-8af37e993665" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnSave_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt; newAttendee = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt;();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            newAttendee.FirstName = ucNewAttendee.FirstName;&lt;/li&gt; &lt;li&gt;            newAttendee.LastName = ucNewAttendee.LastName;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            newAttendee.Company = ucNewAttendee.Company;&lt;/li&gt; &lt;li&gt;            newAttendee.Email = ucNewAttendee.Email;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            newAttendee.Photo = ucNewAttendee.Photo;&lt;/li&gt; &lt;li&gt;            newAttendee.CreationDate = &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;.Now;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            (attendeeDomainDataSource.Data &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DomainDataSourceView&lt;/span&gt;).Add(newAttendee);&lt;/li&gt; &lt;li&gt;            attendeeDomainDataSource.SubmitChanges();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- Build and run the application, try to register a new attendee with a photo, click the &lt;strong&gt;Save&lt;/strong&gt; button, the attendee should be saved and added to the data grid.&lt;/p&gt;  &lt;p&gt;- Another thing we need to do is to print a name tag for the newly registered attendee, we will use the new Silverlight 4.0 printing features.&lt;/p&gt;  &lt;p&gt;- What we have to do is to specify the UI that will be printed, here we will add a new user control to the &lt;strong&gt;Views&lt;/strong&gt; folder, will call it &lt;strong&gt;PrintNameTag, &lt;/strong&gt;in this user control we will display the Name of the user, the company and a barcode that we will be generated based on the attendee id. the markup of the user control is shown below&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:16d0e74e-53a2-4103-ae3f-a46814f9a8dd" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#a31515;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; x&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Background&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;White&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;60*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;60*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;RowDefinition&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Height&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;120*&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Orientation&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Horizontal&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; d&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;LayoutOverrides&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Height&amp;quot;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;24&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Name}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;24&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Company}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Bold&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Grid.Row&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; Barcode}&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;96&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; FontFamily&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Free 3 of 9&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt; TextAlignment&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Center&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    &lt;span style="color:#a31515;"&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- As you can see the &lt;strong&gt;TextBlocks &lt;/strong&gt;are bounded to the attendee’s different properties, the barcode is generated by using the font “Free 3 of 9” which can be downloaded for free, this font will automatically render the barcode stripes, you better use Expression Blend to change the &lt;strong&gt;TextBlock&lt;/strong&gt; font family to use “Free 3 of 9”, this way Blend will include the necessary build actions that pack the font in the xap file.&lt;/p&gt;  &lt;p&gt;- We are now done with the UI that will be printed, to invoke the actual printing, go back to &lt;strong&gt;Home.xaml, &lt;/strong&gt;change the btnSave_Click event handler as follows&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f8460ca8-aeea-41a8-b094-608f871b6003" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:&amp;#39;Courier New&amp;#39;, Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt; newAttendee;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; btnSave_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, System.Windows.&lt;span style="color:#2b91af;"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            newAttendee = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Attendee&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;            newAttendee.FirstName = ucNewAttendee.FirstName;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            newAttendee.LastName = ucNewAttendee.LastName;&lt;/li&gt; &lt;li&gt;            newAttendee.Company = ucNewAttendee.Company;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            newAttendee.Email = ucNewAttendee.Email;&lt;/li&gt; &lt;li&gt;            newAttendee.Photo = ucNewAttendee.Photo;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            newAttendee.CreationDate = &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;.Now;&lt;/li&gt; &lt;li&gt;            (attendeeDomainDataSource.Data &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DomainDataSourceView&lt;/span&gt;).Add(newAttendee);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            attendeeDomainDataSource.SubmitChanges();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt; document = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;            document.PrintPage += &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; System.&lt;span style="color:#2b91af;"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;PrintPageEventArgs&lt;/span&gt;&amp;gt;(document_PrintPage);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            document.Print(&lt;span style="color:#a31515;"&gt;&amp;quot;Attendee_&amp;quot;&lt;/span&gt; + newAttendee.Id);&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; document_PrintPage(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;PrintPageEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt; document = sender &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PrintDocument&lt;/span&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            e.PageVisual = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;PrintNameTag&lt;/span&gt;() { &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                DataContext = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; { &lt;/li&gt; &lt;li&gt;                                    Name =newAttendee.FirstName+&lt;span style="color:#a31515;"&gt;&amp;quot; &amp;quot;&lt;/span&gt;+newAttendee.LastName,&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                    Company=newAttendee.Company,&lt;/li&gt; &lt;li&gt;                                    Barcode = &lt;span style="color:#a31515;"&gt;&amp;quot;ATT&amp;quot;&lt;/span&gt; + newAttendee.Id.ToString(&lt;span style="color:#a31515;"&gt;&amp;quot;00000&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                } &lt;/li&gt; &lt;li&gt;            };&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;- First we create an instance of the &lt;strong&gt;PrintDocument&lt;/strong&gt; class which represents a document to be sent to the printer, we attach a handler to the event &lt;strong&gt;PrintPage.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;- The &lt;strong&gt;PrintPage &lt;/strong&gt;is called for each page that is going to be printed, in the handler we create an instance of the user control (which is the UI that will be printed) and set its &lt;strong&gt;DataContext &lt;/strong&gt;to an anonymous object that contains the needed properties (refer to this &lt;a href="http://mosalem.blogspot.com/2010/06/data-binding-to-anonymous-types-in.html" target="_blank"&gt;post&lt;/a&gt; to see how to enable binding to anonymous types in Silverlight), we assign the created user control to the property &lt;strong&gt;PageVisual&lt;/strong&gt; to indicate that this user control will be the source of the print UI.&lt;/p&gt;  &lt;p&gt;- Build and run the application, register a new attendee, you should get the print dialog to choose the printer, you can use the Microsoft XPS Document Writer for testing&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_6BEA14BA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="3" border="0" alt="3" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_78E3F4CB.png" width="244" height="148" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;in the next post we will continue building our application&lt;/p&gt;  &lt;p&gt;Download the application from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-2.zip" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt; &lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1134" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4.0 Tutorial (1 of N)</title><link>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx</link><pubDate>Mon, 09 Aug 2010 10:38:05 GMT</pubDate><guid isPermaLink="false">35025f3d-1125-4cb2-934c-01e5a7c5a480:1133</guid><dc:creator>Mohamed Mosallem</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.devlifestyle.net/blogs/articles/rsscomments.aspx?PostID=1133</wfw:commentRss><comments>http://www.devlifestyle.net/blogs/articles/archive/2010/08/09/silverlight-4-0-tutorial-1-of-n.aspx#comments</comments><description>&lt;p&gt;I will start writing a set of posts that can be used as a tutorial&amp;#160; for using Visual Studio 2010 and Blend 4.0 to build Silverlight 4.0 applications.&lt;/p&gt;  &lt;p&gt;so what is the application we are going to build??&lt;/p&gt;  &lt;h4&gt;Problem Statement&lt;/h4&gt;  &lt;p&gt;as part of our &lt;a href="http://www.devlifestyle.net/" target="_blank"&gt;community&lt;/a&gt; activities we hold many offline events, at the event we need to gather the attendees information(sort of onsite registration), give them feedback forms so that they can evaluate the sessions and also use these forms to select winners for the raffle draw.&lt;/p&gt;  &lt;p&gt;so i tried to create a simple application that we will host on a PC/Laptop at the event venue, we will call it the RegistrationBooth Application.&lt;/p&gt;  &lt;h4&gt;Solution&amp;#160; &lt;/h4&gt;  &lt;p&gt;the RegistrationBooth Application will:&lt;/p&gt;  &lt;p&gt;- Allows the user to register his/her information through a simple easy interface.&lt;/p&gt;  &lt;p&gt;- Automatically print a name tag for the user once registered.&lt;/p&gt;  &lt;p&gt;- displays a list of all the registered users.&lt;/p&gt;  &lt;p&gt;- displays the event agenda.&lt;/p&gt;  &lt;p&gt;- allows the users to easily evaluate the sessions they attended.&lt;/p&gt;  &lt;p&gt;- allows the user to print attendance certificate.&lt;/p&gt;  &lt;h4&gt;Building the Application&lt;/h4&gt;  &lt;p&gt;- So let’s create a new Silverlight project using the “Silverlight Business Application” template, let’s call it &lt;strong&gt;RegistrationBooth&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;- The first thing to do is to create our database, right click the App_Data folder in the &lt;strong&gt;RegistrationBooth.Web&lt;/strong&gt; project and add new item of type SQL Server Database, name it &lt;strong&gt;RegistrationBoothDB&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;- The database will contain tables for attendees, speakers, sessions and the intermediate tables that represent the n-n relationships between the different tables, the database diagram should be as follows&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_200A1E1B.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Database" border="0" alt="Database" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/1_5F00_thumb_5F00_756E3D3D.png" width="484" height="295" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- After creating the database we should create our data access layer, we will use ADO.NET Entity Framework for that, so let’s go to our &lt;strong&gt;RegistrationBooth.Web&lt;/strong&gt; project and add a new item of type ADO.NET Entity Data Model and name it &lt;strong&gt;RegistrationsModel&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;- Walk through the wizard to select the database we created earlier and select to include all the tables in the database, use &lt;strong&gt;RegistrationBoothDBModel&lt;/strong&gt; for the model name, the model should look like the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_45D01EB1.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="ADO.NET Entity Model" border="0" alt="ADO.NET Entity Model" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/2_5F00_thumb_5F00_1F219264.png" width="484" height="380" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- We now have a way to access our database (through the ADO.NET Entity Model) but we can use this only on the server side,&amp;#160; to be able to work with our database entities on the client side (Silverlight) we have to expose our ADO.NET Entity Model using WCF RIA Services, RIA Services is a special type of WCF Services that simplifies the development of n-tier Rich Internet Applications.&amp;#160; &lt;/p&gt;  &lt;p&gt;- In Silverlight you can create a Domain Service class which is a RIA service that exposes CRUD operations over your domain model.&lt;/p&gt;  &lt;p&gt;- So add a new Domain Service class to the &lt;strong&gt;RegistrationBooth.Web&lt;/strong&gt; project, name it &lt;strong&gt;RegistrationDomainService, &lt;/strong&gt;the wizard will allow you to choose the DataContext/ObjectContext class, in our case we will select the DataContext created by our ADO.NET Entity Model (you should see it in the drop down list once you built the application)&lt;/p&gt;  &lt;p&gt;- You will see a list of the data entities exposed through our data model, select all the entities and enable editing for all of them.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_15E55723.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="New Domain Service Class" border="0" alt="New Domain Service Class" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/3_5F00_thumb_5F00_7F4308DB.png" width="460" height="552" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- Examine the RegistrationDomainService.cs file, you will find that there are four methods (Get, Insert, Update, Delete) generated for each entity in the domain model.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_79F4222A.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="RegistrationDomainService.cs" border="0" alt="RegistrationDomainService.cs" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/4_5F00_thumb_5F00_5C32976B.png" width="484" height="198" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- At this point we have a database, data access layer (ADO.NET Entity Model) and a Domain Service class that exposes our model to the Silverlight client&lt;/p&gt;  &lt;p&gt;- Now let’s move to the client side and start to create our Silverlight application.&lt;/p&gt;  &lt;p&gt;- The first thing we want to display on our home page is a list of the attendees, we can do this easily using VS2010, open the Data Sources windows (from the menu Data-&amp;gt;Show Data Sources).&lt;/p&gt;  &lt;p&gt;- You will see the &lt;strong&gt;RegistrationDomainContext&lt;/strong&gt; which represents the &lt;strong&gt;RegistrationDomainService &lt;/strong&gt;we added earlier, as you can see inside &lt;strong&gt;RegistrationDomainContext&lt;/strong&gt;&amp;#160; you have all the different entities exposed by the domain service, and below each entity you can see the properties of this entity&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_4FC47442.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Data Sources Window" border="0" alt="Data Sources Window" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/5_5F00_thumb_5F00_20FEBBA0.png" width="237" height="415" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;- One important thing to take care of is the small down arrow beside each entity &lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="6" border="0" alt="6" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/6_5F00_2745922E.png" width="17" height="17" /&gt; , when you click this arrow you get a menu that allows you to: &lt;/p&gt;  &lt;p&gt;1. choose how to render this entity on the Page (DataGrid or DetailsView) &lt;/p&gt;  &lt;p&gt;2. Choose the query (or the Domain Service method) that you will use to retrieve this entity&lt;/p&gt;  &lt;p&gt;- Now to display our attendees click the down arrow, make sure that DataGrid is selected, we have only one option for the query (&lt;strong&gt;GetAttendeesQuery&lt;/strong&gt;) cause we only have one method in the Domain Service (&lt;strong&gt;GetAttendees&lt;/strong&gt;) that returns &lt;strong&gt;Attendee &lt;/strong&gt;entities.&lt;strong&gt; &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;- &lt;/strong&gt;Click the Down arrow beside the &lt;strong&gt;CreationDate &lt;/strong&gt;property and select &lt;strong&gt;TextBox &lt;/strong&gt;to make sure that this property is rendered into a&lt;strong&gt; DataGridTextColumn.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;- &lt;/strong&gt;Click the Down arrow beside the &lt;strong&gt;Photo &lt;/strong&gt;property and select&lt;strong&gt; Image.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;- Drag and Drop the Attendee entity on the &lt;strong&gt;Home.xaml&lt;/strong&gt; page (located in the Views folder), VS will create a DataGrid that contains columns for all the attributes of the Attendee. &lt;/p&gt;  &lt;p&gt;- From the properties window, go to the Columns property of the DataGrid and click the 3 dots button to open the Columns Editor dialog.&lt;/p&gt;  &lt;p&gt;- Re-order the columns (to be in he same order as shown below), and also increase the widths of the columns.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_38B5F306.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Collection Editor: Columns" border="0" alt="Collection Editor: Columns" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/7_5F00_thumb_5F00_4CCF0F8F.png" width="322" height="204" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;- We need to change the format of the CreationDate column, so select the column and go to the &lt;strong&gt;Binding &lt;/strong&gt;property, expand the Options panel and select the appropriate string format.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_64F279EA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Binding String Fomat" border="0" alt="Binding String Fomat" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/8_5F00_thumb_5F00_42BA6E64.png" width="484" height="229" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Run the application now, you will find the rows are displayed (supposing that you had populated the database manually), but the photos are not displayed, if you examine the xaml code for the Photo column you will find that this template column contains &lt;strong&gt;Image &lt;/strong&gt;control whose &lt;strong&gt;Source &lt;/strong&gt;property is bound directly to the &lt;strong&gt;Photo&lt;/strong&gt; attribute, there’s no direct conversion from byte arrays to bitmaps or images in Silverlight, so we need to write a converter to do this&lt;/p&gt;  &lt;p&gt;- A converter is a class that implements the &lt;strong&gt;IValueConverter&lt;/strong&gt; interface, so let’s add a new class to the Silverlight project (under the &lt;strong&gt;Helpers&lt;/strong&gt; folder), and call it &lt;strong&gt;ImageConverter, &lt;/strong&gt;the implementation is straightforward (as shown below)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_55FB2503.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="ImageConverter" border="0" alt="ImageConverter" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/9_5F00_thumb_5F00_38399A44.png" width="454" height="479" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- To use this converter, we will instantiate an instance from this class as application resource, so in the &lt;strong&gt;App.xaml&lt;/strong&gt; file inside the &lt;strong&gt;Application.Resources&lt;/strong&gt; property, define an instance of the converter and give it a key name&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_0424FAF1.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="ImageConverter Resource" border="0" alt="ImageConverter Resource" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/10_5F00_thumb_5F00_4382AE81.png" width="377" height="59" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- Now back to &lt;strong&gt;Home.xaml&lt;/strong&gt;, change the markup of the &lt;strong&gt;Image &lt;/strong&gt;control inside the Photo column to be as follows&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_22FB6ECF.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="11" border="0" alt="11" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/11_5F00_thumb_5F00_10467518.png" width="484" height="52" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;- If you run the application now you should be able to see the photos&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/12_5F00_689FF8ED.png" target="_blank"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="The Attendees DataGrid" border="0" alt="The Attendees DataGrid" src="http://devlifestyle.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/articles/12_5F00_thumb_5F00_1233C421.png" width="484" height="114" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;in the next post we will continue building our application&lt;/p&gt;  &lt;p&gt;Download the application from &lt;a href="http://cid-cbb3c32611bc50d4.office.live.com/self.aspx/Public/Silverlight%204.0%20Tutorial/RegistrationBooth-1.zip" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.devlifestyle.net/aggbug.aspx?PostID=1133" width="1" height="1"&gt;</description><category domain="http://www.devlifestyle.net/blogs/articles/archive/tags/Silverlight/default.aspx">Silverlight</category></item></channel></rss>
