<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7376718508560925815</id><updated>2024-10-25T01:16:48.951-07:00</updated><category term="XAML"/><category term="Lookless"/><category term="MVVM"/><category term="Silverlight"/><category term="Windows Phone"/><category term="C#"/><category term="Command"/><category term="Controls"/><category term="Custom Control"/><category term="Demos"/><category term="Event"/><category term="Expression Blend"/><category term="NotifyPropertyChanged"/><category term="PdfViewer"/><category term="Prism"/><category term="ScollViewer"/><category term="Telerik"/><category term="Thread"/><category term="WPF"/><title type='text'>Silverlight</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-4065146288899008887</id><published>2012-03-21T16:49:00.000-07:00</published><updated>2012-03-21T16:49:00.968-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Controls"/><category scheme="http://www.blogger.com/atom/ns#" term="PdfViewer"/><category scheme="http://www.blogger.com/atom/ns#" term="Telerik"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Introducing PDF Viewer for Silverlight/WPF</title><content type='html'>&lt;a href=&quot;http://blogs.telerik.com/SilverlightTeam/Posts/12-02-29/introducing-pdf-viewer-for-silverlight-wpf.aspx&quot;&gt;Introducing PDF Viewer for Silverlight/WPF&lt;/a&gt;: &lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;The long-awaited 2012 Q1 with the first official version of RadPdfViewer is already a fact! This is also the first release of the control for WPF, so don’t forget to check it out in the demos if you have missed it: &lt;a href=&quot;http://demos.telerik.com/wpf&quot;&gt;WPF&lt;/a&gt; and &lt;a href=&quot;http://demos.telerik.com/silverlight/#PdfViewer/FirstLook&quot;&gt;Silverlight&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;A big “Thank You” to all who tried using RadPdfViewer for Silverlight when it was still in a beta stage for providing such a valuable feedback on the control! We have come a long way with your help and hope that you will enjoy the improvements that the first official version brings out.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://blogs.telerik.com/Libraries/Nikolay_Atanasov/pdf_viewer_2.sflb?;decreaseOnly=true&quot; /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;br /&gt;For the past few months after we first introduced RadPdfViewer as Beta, we have managed to extend the list of supported PDF features in order to be able to show correctly intrinsic PDF files like the ones normally used in LOB applications. The ameliorations include a wider set of image formats and an extensible architecture for plugging in custom filters. The text rendering system was also rethought and improved to ensure&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt; the professional look of the document preview. We also managed to implement clipping and support for color spaces, further polishing the way PDF files are shown. Last but not least, if you use the control in Silverlight 5, you will now be able to print your documents faster and with less memory footprint, because the control now utilizes the vector printing of Silverlight 5.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;In the 2012 Q1 release an MVVM friendly API is introduced, which will help you integrate RadPdfViewer more easily. Following popular demand, the DocumentSource of RadPdfViewer has been implemented as a DependencyProperty, allowing data-binding to a Stream, a URI where a document can be found, or a string representing such a URI. For example, if Source is the property in your view-model which you wish to bind the content of the viewer to, you can do that as follows:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #f7f7ff;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aa4400; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;telerik:RadPdfViewer&lt;/span&gt; &lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;x:Name&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&quot;viewer&quot;&lt;/span&gt; &lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;DocumentSource&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #cc0000; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&quot;{Binding Source, Converter={StaticResource PdfDocumentSourceValueConverter}}&quot;&lt;/span&gt; &lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #f7f7ff;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;PdfDocumentSourceValueConverter is a static resource declared as:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;fixed&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;PdfDocumentSourceValueConverter&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;Key&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&quot;PdfDocumentSourceValueConverter&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;The toolbar that RadPdfViewer used in the beta has been implemented as a separate control now in order to allow customizations of the functionality provided to the end user.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;Here is an example of how a RadToolBar can be wired with the commands of the PdfViewer:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;telerik&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;RadToolBar&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; DataContext&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&quot;{&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;Binding&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; ElementName&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=pdfViewer,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; Path&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=Commands}&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;            …&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;telerik&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;RadToolBar&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;After setting the DataContext of the toolbar, you can proceed to fill in buttons bound to the commands of the viewer like this:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;controls&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;RadButton&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; Padding&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&quot;4&quot;&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; Command&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&quot;{&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;Binding&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; OpenPdfDocumentCommand&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;}&quot;&amp;gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;ToolTipService.ToolTip&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;                    &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;TextBlock&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; Text&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&quot;Open&quot; /&amp;gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;ToolTipService.ToolTip&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;Image&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; Source&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&quot;/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/open.png&quot;&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt; Stretch&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;=&quot;None&quot; /&amp;gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;controls&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;RadButton&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;In this way, you will get the same button that the navigation panel of RadPdfViewer had in the beta version. Only that this time, you can customize the tooltip and the icon or even change the command executed. If you would like to preserve the look of the PdfViewer from the Beta, you can open the demos and copy the content from there. Of course, you can implement other kind of UI just as easily.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;Now the experience you get with RadPdfViewer for Silverlight will be much closer to the desktop applications you use for viewing PDFs. What is more, you can build applications with similar look and functionality for Silverlight and WPF with minimal effort.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;segoe ui&#39;, sans-serif; font-size: 10pt; line-height: 115%;&quot;&gt;Happy developing! &lt;/span&gt;&lt;br /&gt;
&lt;img alt=&quot;&quot; src=&quot;http://blogs.telerik.com/Libraries/Silverlight_team/CTA_XAML_banner.sflb&quot; style=&quot;border-style: solid; border-width: 0px;&quot; usemap=&quot;http://blogs.telerik.com/SilverlightTeam/Posts.aspx#rade_img_map_1329429719090&quot; /&gt; &lt;map name=&quot;rade_img_map_1329429719090&quot;&gt; &lt;area coords=&quot;205,59,572,102&quot; href=&quot;http://www.telerik.com/account/free-trials/trial-product-versions/single-trial.aspx?pmvid=0&amp;amp;pid=601&quot; shape=&quot;RECT&quot;&gt;&lt;/area&gt; &lt;area coords=&quot;509,99,510,101&quot; shape=&quot;RECT&quot;&gt;&lt;/area&gt; &lt;area coords=&quot;39,108,597,151&quot; href=&quot;http://www.telerik.com/account/free-trials/trial-product-versions/single-trial.aspx?pmvid=0&amp;amp;pid=571&quot; shape=&quot;RECT&quot;&gt;&lt;/area&gt;&lt;/map&gt;</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/4065146288899008887/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/introducing-pdf-viewer-for.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/4065146288899008887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/4065146288899008887'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/introducing-pdf-viewer-for.html' title='Introducing PDF Viewer for Silverlight/WPF'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-4402748900263061706</id><published>2012-03-07T16:44:00.000-08:00</published><updated>2012-03-07T16:44:00.089-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ScollViewer"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>ScrollToBottom extension method in ScrollViewer - Silverlight 4</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ScrollViewer is one among the commonly used Silverlight control. When you develop Silverlight application, at some time, you&#39;ll come across using ScrollViewer. Using ScrollViewer is straightforward in most of the cases. In some scenarios (like displaying chat history messages, stock history update), we might want to bind values to elements inside the ScrollViewer and then scroll to the bottom in order to make the latest message appear in the visible region.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ScrollToBottom() is one among the several extension methods available for ScrollViewer which helps us to achieve scrolling vertically to the end of the ScrollViewer content. While using this ScrollToBottom() method some developers won&#39;t see the ScrollViewer scrolls upto the bottom. So, why it is like that what need to be done to make it work? Let us dive into the implementation of ScrollToBottom() method and find out the solution.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;Snippet 1: (ScrollToBottom() implementation)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;public static void ScrollToBottom(this ScrollViewer viewer)
{
   if (viewer == null)
   {
       throw new ArgumentNullException(&quot;viewer&quot;);
   }

   viewer.ScrollToVerticalOffset(viewer.ExtentHeight);
}&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;As most of us might guess, it scrolls the veritical offset to the &lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;height of the content inside the ScrollViewer. Actually the values for properties like ScrollViewer.ExtentHeight, ScrollViewer.VerticalOffset are not recalculated immediately. It seems that they placed such restrictions due to performance considerations.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We can force to recalculate and update values of related properties by calling the UpdateLayout() method of the ScrollViewer. Anyhow be sure to call the UpdateLayout() only required. Please view the remarks section &lt;/span&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.uielement.updatelayout(v=vs.95).aspx&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; at msdn documentation.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Ultimately, calling the UpdateLayout() method on the ScrollViewer before ScrollToBottom() is called will solve the obstacle.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Following is a sample snippet to help you understand the above specified scenario. Try executing the following snippet and inspect the value of ExtentHeight(and related properties) property by inserting the breakpoint in the call to UpdateLayout() method.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;Snippet 2:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;ScrollViewerTest.xaml&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;lt;UserControl x:Class=&quot;TestSilverlightApplication1.ScrollViewerTest&quot;
   xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
   xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
   xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
   xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
   mc:Ignorable=&quot;d&quot;
   d:DesignHeight=&quot;500&quot; d:DesignWidth=&quot;500&quot;&amp;gt;
   &amp;lt;Grid Background=&quot;DeepSkyBlue&quot;&amp;gt;
       &amp;lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;SkyBlue&quot; Height=&quot;300&quot; Width=&quot;400&quot;&amp;gt;
           &amp;lt;Grid.RowDefinitions&amp;gt;
               &amp;lt;RowDefinition&amp;gt;&amp;lt;/RowDefinition&amp;gt;
               &amp;lt;RowDefinition Height=&quot;Auto&quot;&amp;gt;&amp;lt;/RowDefinition&amp;gt;
               &amp;lt;RowDefinition Height=&quot;70&quot;&amp;gt;&amp;lt;/RowDefinition&amp;gt;
               &amp;lt;RowDefinition Height=&quot;Auto&quot;&amp;gt;&amp;lt;/RowDefinition&amp;gt;
               &amp;lt;RowDefinition Height=&quot;70&quot;&amp;gt;&amp;lt;/RowDefinition&amp;gt;
               &amp;lt;RowDefinition&amp;gt;&amp;lt;/RowDefinition&amp;gt;
           &amp;lt;/Grid.RowDefinitions&amp;gt;
           &amp;lt;StackPanel&amp;gt;
               &amp;lt;TextBlock Text=&quot;ScrollToBottom Check&quot; HorizontalAlignment=&quot;Center&quot; FontWeight=&quot;Bold&quot; &amp;gt;&amp;lt;/TextBlock&amp;gt;

           &amp;lt;/StackPanel&amp;gt;
           &amp;lt;TextBlock Grid.Row=&quot;1&quot; Text=&quot;Enter multiline text here......&quot;&amp;gt;&amp;lt;/TextBlock&amp;gt;
           &amp;lt;ScrollViewer Grid.Row=&quot;2&quot;&amp;gt;
               &amp;lt;TextBox AcceptsReturn=&quot;True&quot; Text=&quot;{Binding SampleTextString, Mode=TwoWay}&quot;&amp;gt;&amp;lt;/TextBox&amp;gt;
           &amp;lt;/ScrollViewer&amp;gt;
           &amp;lt;Button Content=&quot;...and click here....&quot; Click=&quot;ScrollDownCheck_Click&quot; Width=&quot;150&quot; Grid.Row=&quot;3&quot; Margin=&quot;10&quot;&amp;gt;&amp;lt;/Button&amp;gt;
           &amp;lt;ScrollViewer Grid.Row=&quot;4&quot; Name=&quot;TestScrollControl&quot;&amp;gt;
               &amp;lt;TextBox AcceptsReturn=&quot;True&quot; Name=&quot;TestTextBox&quot; Text=&quot;{Binding AlteredTextString}&quot;&amp;gt;&amp;lt;/TextBox&amp;gt;
           &amp;lt;/ScrollViewer&amp;gt;
       &amp;lt;/Grid&amp;gt;
   &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;ScrollViewerTest.xaml.cs&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;

namespace TestSilverlightApplication1
{
   public partial class ScrollViewerTest : UserControl, INotifyPropertyChanged
   {
       public ScrollViewerTest()
       {
           InitializeComponent();
           InitControls();
       }

       private string sampleTextString;

       public string SampleTextString
       {
           get { return sampleTextString; }
           set
           {
               sampleTextString = value;
               NotifyPropertyChanged(&quot;SampleTextString&quot;);
           }
       }

       private string alteredTextString;

       public string AlteredTextString
       {
           get { return alteredTextString; }
           set
           {
               alteredTextString = value;
               NotifyPropertyChanged(&quot;AlteredTextString&quot;);
           }
       }
       
       private void ScrollDownCheck_Click(object sender, RoutedEventArgs e)
       {
           ManipulateScrollDownCheck();
       }

       private void InitControls()
       {
           this.DataContext = this;
       }

       private void ManipulateScrollDownCheck()
       {
           this.AlteredTextString = this.SampleTextString;
           //Insert breakpoint here and validate the value of
           //ExtentHeight before and after the execution of UpdateLayout().
           TestScrollControl.UpdateLayout();
           TestScrollControl.ScrollToBottom();
       }

       #region INotifyPropertyChanged Members

       protected void NotifyPropertyChanged(string propertyName)
       {
           if (PropertyChanged != null)
           {
               PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
           }
       }

       public event PropertyChangedEventHandler PropertyChanged;

       #endregion
   }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You can infer from the above example that the call to UpdateLayout() is made before calling ScrollToBottom() and after assinging the value to the property bound to the content(UIElement contained inside the ScrollViewer) of the ScrollViewer. Since developers will face such problem only at certain workflows, call the UpdateLayout() only when you encounter that problem.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrolltoverticaloffset(v=vs.95).aspx&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrolltoverticaloffset(v=vs.95).aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrolltobottom.aspx&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrolltobottom.aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://epiinfo.svn.codeplex.com/svn/Silverlight.Controls.Toolkit/Controls.Toolkit/Common/ScrollViewerExtensions.cs&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;https://epiinfo.svn.codeplex.com/svn/Silverlight.Controls.Toolkit/Controls.Toolkit/Common/ScrollViewerExtensions.cs&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;img alt=&quot;&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/4734008815438417747-9173728025102255441?l=info.titodotnet.com&quot; width=&quot;1&quot; /&gt;&lt;/div&gt;
&lt;img height=&quot;1&quot; src=&quot;http://feeds.feedburner.com/~r/titodotnet/rss/~4/QXCY3u5WWnc&quot; width=&quot;1&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/4402748900263061706/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/scrolltobottom-extension-method-in.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/4402748900263061706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/4402748900263061706'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/scrolltobottom-extension-method-in.html' title='ScrollToBottom extension method in ScrollViewer - Silverlight 4'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-5826380616076353354</id><published>2012-03-04T04:40:00.000-08:00</published><updated>2012-03-04T04:40:28.334-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="NotifyPropertyChanged"/><category scheme="http://www.blogger.com/atom/ns#" term="Thread"/><title type='text'>Unauthorized access exception when value set for property using Secondary Thread - Silverlight</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Thinking about threading in Silverlight 4, we choose between the two options&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Background worker&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Managing thread manually&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Most of the time-consuming operations will be handled using the Background worker without blocking the UI. It ultimately executes in a separate thread. The main functions and events to know in Background worker are &lt;span style=&quot;color: #0b5394;&quot;&gt;DoWork&lt;/span&gt;, &lt;span style=&quot;color: #0b5394;&quot;&gt;RunWorkerCompleted &lt;/span&gt;and &lt;span style=&quot;color: #0b5394;&quot;&gt;RunWorkerAsync&lt;/span&gt;. As the name specifies we need to add the event handler for &lt;span style=&quot;color: #0b5394;&quot;&gt;DoWork &lt;/span&gt;event for doing the background operation. Add the handler for &lt;span style=&quot;color: #0b5394;&quot;&gt;RunWorkerCompleted &lt;/span&gt;to receive the operation completed notification.  &lt;span style=&quot;color: #0b5394;&quot;&gt;RunWorkerAsync &lt;/span&gt;method is to start the operation. The main thing to note is that we should not access directly access the UI objects from the &lt;span style=&quot;color: #0b5394;&quot;&gt;DoWork &lt;/span&gt;event.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Also there are times where we need to manage the threads manually. Since Silverlight runs in a Single threaded apartment (STA) application model and the default is the UI thread, accessing the UI objects from other thread leads to cross thread exception. Knowing this fact I worked with a secondary thread and updated a property in my ViewModel. In that scenario I got an exception and digging into the inner exception found out the cross thread exception. For understanding I&#39;ve created a sample scenario that raises exception.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Snippet 1&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;public partial class ThreadTest : UserControl, INotifyPropertyChanged
{      
  private string textValue;
  public string TextValue
  {
      get { return textValue; }
      set
      {
          textValue = value;
          NotifyPropertyChanged(&quot;TextValue&quot;);
      }
  }

  public ThreadTest()
  {
      InitializeComponent();

      InitControls();
  }

  private void InitControls()
  {
      this.DataContext = this;
  }

  private void Direct_Click(object sender, RoutedEventArgs e)
  {
      TextValue = &quot;direct text......&quot;;
  }

  private void UsingTask_Click(object sender, RoutedEventArgs e)
  {
      Thread secondaryThread = new Thread(SecondaryThreadWorker);
      secondaryThread.Start();
    
  }

  private void SecondaryThreadWorker()
  {
      TextValue = &quot;thread text.......&quot;;          
  }


  #region INotifyPropertyChanged Members

  protected void NotifyPropertyChanged(string propertyName)
  {
      PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  }

  public event PropertyChangedEventHandler PropertyChanged;

  #endregion
}&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Then examining the cause, realized that the specific property raises an property changed notification . Immediately recalled the excellent &lt;a href=&quot;http://10rem.net/blog/2012/01/10/threading-considerations-for-binding-and-change-notification-in-silverlight-5&quot;&gt;article&lt;/a&gt; from Pete Brown in his 10rem.net blog.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The following implementation does the trick.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Snippet 2 (Just replace the INotifyPropertyChanged implementation)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;#region INotifyPropertyChanged Members

protected void NotifyPropertyChanged(string propertyName)
{
  if (PropertyChanged != null)
  {
      if (Deployment.Current.Dispatcher.CheckAccess())
      {
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
      else
      {
          Deployment.Current.Dispatcher.BeginInvoke(() =&amp;gt;
          {
              PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          });
      }
  }
}

public event PropertyChangedEventHandler PropertyChanged;

#endregion&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When I typed &quot;&lt;span style=&quot;color: #0b5394;&quot;&gt;Deployment.Current.Dispatcher.&lt;/span&gt;&quot;, it didn&#39;t show up the &quot;&lt;span style=&quot;color: #0b5394;&quot;&gt;CheckAccess()&lt;/span&gt;&quot; method in the intellisense. But I verified it in the object which shows the existence of the method. So I manually typed the  &quot;&lt;span style=&quot;color: #0b5394;&quot;&gt;CheckAccess()&lt;/span&gt;&quot; method name and got complied without error.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;References&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://10rem.net/blog/2012/01/10/threading-considerations-for-binding-and-change-notification-in-silverlight-5&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;http://10rem.net/blog/2012/01/10/threading-considerations-for-binding-and-change-notification-in-silverlight-5&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;img alt=&quot;&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/4734008815438417747-1204776503008607230?l=info.titodotnet.com&quot; width=&quot;1&quot; /&gt;&lt;/div&gt;
&lt;img height=&quot;1&quot; src=&quot;http://feeds.feedburner.com/~r/titodotnet/rss/~4/kuqSfXFihkU&quot; width=&quot;1&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/5826380616076353354/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/unauthorized-access-exception-when.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/5826380616076353354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/5826380616076353354'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/unauthorized-access-exception-when.html' title='Unauthorized access exception when value set for property using Secondary Thread - Silverlight'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-7348922123187046605</id><published>2012-03-02T10:04:00.001-08:00</published><updated>2012-03-04T04:39:18.494-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight"/><title type='text'>silverlight 5: Slides and Code</title><content type='html'>&lt;br /&gt; Powerpoint Slides &lt;br /&gt;Attached to this post &lt;br /&gt; Demos and Examples &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/09/04/the-big-list-of-whats-new-or-improved-in-silverlight-5&quot;&gt;The Big List of What&#39;s New or Improved in Silverlight 5 - Pete Brown&#39;s 10rem.net&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2012/01/10/threading-considerations-for-binding-and-change-notification-in-silverlight-5&quot;&gt;Threading Considerations for Binding and Change Notification in Silverlight 5&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2012/02/07/creating-big-silverlight-windows-and-getting-monitor-resolutions-and-positions-with-pinvoke&quot;&gt;Creating Big Silverlight Windows and Getting Monitor Resolutions and Positions with PInvoke&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/13/silverlight-5-using-the-soundeffect-class-for-low-latency-sound-and-play-wav-files-in-silverlight&quot;&gt;Silverlight 5: Using the SoundEffect Class for Low-Latency Sound (and play WAV files in Silverlight)&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/13/silverlight-5-working-with-operating-system-windows&quot;&gt;Silverlight 5: Working with Operating System Windows&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/13/silverlight-5-working-with-implicit-templates&quot;&gt;Silverlight 5: Working with Implicit Templates&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/13/silverlight-5-debugging-bindings-with-xaml-breakpoints&quot;&gt;Silverlight 5: Debugging Bindings with Xaml Breakpoints&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/13/silverlight-5-supporting-double-and-even-triple-click-for-the-mouse&quot;&gt;Silverlight 5: Supporting Double and Even Triple Click for the Mouse&lt;/a&gt; &lt;br /&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/25/supporting-both-double-and-triple-click-in-silverlight-5&quot;&gt;Supporting both Double and Triple Click in Silverlight 5&lt;/a&gt; (article with the timer approach) &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/13/silverlight-5-advancements-in-text&quot;&gt;Silverlight 5: Advancements in Text&lt;/a&gt; &lt;br /&gt; My Book &lt;br /&gt;&lt;a href=&quot;http://manning.com/pbrown2/&quot;&gt;Silverlight 5 in Action&lt;/a&gt; &lt;br /&gt; Downloads &lt;br /&gt;&lt;a href=&quot;http://code.msdn.microsoft.com/3D-Housebuilder-demo-from-def4af04&quot;&gt;Download the 3D House Builder Demo Application&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://babylontoolkit.codeplex.com/&quot;&gt;See the Babylon 3d Engine on CodePlex&lt;/a&gt; &lt;br /&gt; Related Links &lt;br /&gt;&lt;a href=&quot;http://www.silverlight.net/getstarted/silverlight-5-beta/&quot;&gt;Silverlight 5 Page on Silverlight.net&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/04/13/announcing-the-silverlight-5-beta-release-and-the-silverlightnet-redesign&quot;&gt;Announcing the Silverlight 5 Beta Release and the Silverlight.net Redesign&lt;/a&gt; &lt;br /&gt; Previous Versions &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/05/23/slides-videos-and-downloads-from-my-tech-ed-atlanta-2011-and-recent-user-group-talks&quot;&gt;Slides, Videos, and Downloads from my Tech Ed Atlanta 2011 and Recent User Group Talks&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://10rem.net/blog/2011/10/25/updated-slides-and-demos-from-vslive-redmond-2011&quot;&gt;Updated Slides and Demos from VSLive Redmond 2011&lt;/a&gt; &lt;br /&gt;by  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;by @pete_brown</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/7348922123187046605/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/silverlight-5-slides-and-code.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/7348922123187046605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/7348922123187046605'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2012/03/silverlight-5-slides-and-code.html' title='silverlight 5: Slides and Code'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-471731524268082253</id><published>2011-11-06T01:43:00.000-07:00</published><updated>2011-11-06T01:43:59.128-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Prism"/><title type='text'>Prism/WPF/Silverlight - setting ItemsControl height and width to full view using DockPanel style</title><content type='html'>&lt;a href=&quot;http://www.global-webnet.com/Blog/post.aspx?id=31f82b99-157a-4014-8ded-8292c70652cc&quot;&gt;Prism/WPF/Silverlight - setting ItemsControl height and width to full view using DockPanel style&lt;/a&gt;: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Figure 2 is the &lt;strong&gt;MainRegionTopContentBottom&lt;/strong&gt; view that Prism will inject three views into (top, content and bottom).  When the view is inserted into the MainRegion ItemsControl of figure 1 below the &lt;strong&gt;MainRegionTopContentBottom&lt;/strong&gt; view is compressed vertically - we want it to fill the entire MainWindow.   &lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;&quot; height=&quot;466&quot; src=&quot;http://www.global-webnet.com/Blog/image.axd?picture=2011%2f11%2fItemsControlDockPanel001.JPG&quot; width=&quot;681&quot; /&gt;&lt;br /&gt;
Figure 1.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Wen we apply the ItemsControlDockedStyle (figure 3) to the MainRegion ItemsControl above we get expected results for the MainRegionTopContentBottom view (see below where the statusbar is at the bottom of the window) but not for the contents that are injected into its three regions - its ItemsControls also cause the contents to be compressed.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;&quot; height=&quot;712&quot; src=&quot;http://www.global-webnet.com/Blog/image.axd?picture=2011%2f11%2fItemsControlDockPanel003a.JPG&quot; width=&quot;686&quot; /&gt;&lt;br /&gt;
Figure 2.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;&quot; height=&quot;234&quot; src=&quot;http://www.global-webnet.com/Blog/image.axd?picture=2011%2f11%2fItemsControlDockPanel002.JPG&quot; width=&quot;687&quot; /&gt;&lt;br /&gt;
Figure 3.&lt;br /&gt;
&lt;br /&gt;
Once we apply the ItemsControlDocked style to each of the ItemsControl we get the expected behavior as shown in the image below: &lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;&quot; height=&quot;711&quot; src=&quot;http://www.global-webnet.com/Blog/image.axd?picture=2011%2f11%2fItemsControlDockPanel004.JPG&quot; width=&quot;684&quot; /&gt;&lt;br /&gt;
Figure 4.&lt;br /&gt;
&lt;br /&gt;
We can use the same view for both WPF Desktop and Silverlight with minor variation - for Silverlight we&#39;ll have to first install the Silverlight toolkit (&lt;a href=&quot;http://silverlight.codeplex.com/releases/view/74436&quot;&gt;available here for Silverlight 5&lt;/a&gt;) and then provide a reference to it in xaml as shown on line 4 of the image below:  &lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;&quot; src=&quot;http://www.global-webnet.com/Blog/image.axd?picture=2011%2f11%2fItemsControlDockPanel005.JPG&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
With the above styles we achieve the results we need for both our Desktop and Silverlight applications (which share the same code). &lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;&quot; height=&quot;642&quot; src=&quot;http://www.global-webnet.com/Blog/image.axd?picture=2011%2f11%2fItemsControlDockPanel006.JPG&quot; width=&quot;684&quot; /&gt;&lt;br /&gt;
Figure 5.</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/471731524268082253/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/11/prismwpfsilverlight-setting.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/471731524268082253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/471731524268082253'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/11/prismwpfsilverlight-setting.html' title='Prism/WPF/Silverlight - setting ItemsControl height and width to full view using DockPanel style'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-7198619314738672392</id><published>2011-09-13T07:58:00.000-07:00</published><updated>2011-09-13T07:58:26.152-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Command"/><category scheme="http://www.blogger.com/atom/ns#" term="Event"/><category scheme="http://www.blogger.com/atom/ns#" term="MVVM"/><title type='text'>Binding Events to Methods in the Silverlight MVVM View Models</title><content type='html'>

&lt;form action=&quot;View.aspx?display=Mobile&quot; id=&quot;aspnetForm&quot; method=&quot;post&quot; name=&quot;aspnetForm&quot;&gt;

&lt;div&gt;


&lt;/div&gt;
&lt;ul class=&quot;download&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codeproject.com/KB/silverlight/SilverlightEventBinding/EventBindingExample.zip&quot;&gt;Download example - 73.95 KB &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Introduction&lt;/h2&gt;
&lt;div class=&quot;abstract&quot;&gt;
&lt;span id=&quot;ctl00_MC_Top_ArticleDescr&quot;&gt;This article 
introduces a simple method to bind UI events to the corresponding 
methods in the MVVM view models in Silverlight applications.&lt;/span&gt;&lt;/div&gt;
&lt;h2&gt;
Background&lt;/h2&gt;
In order to fully conform to the &lt;a href=&quot;http://en.wikipedia.org/wiki/Model_View_ViewModel&quot;&gt;MVVM&lt;/a&gt;
 design pattern in Silverlight, we may want to move the event handling 
functions into the view models. Generally speaking, we have two types of
 UI components and two types of UI events in Silverlight applications.&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;UI controls like a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.controls.button%28v=vs.95%29.aspx&quot;&gt;Button&lt;/a&gt; have a property called &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.buttonbase.command%28v=vs.95%29.aspx&quot;&gt;Command&lt;/a&gt;. We can create a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.input.icommand.aspx&quot;&gt;command&lt;/a&gt;
 property in the view model to handle the click event of the button by 
binding this command property in the view model to the button control&#39;s 
command property in the XAML. For detailed information about the command
 bindings, you can take a look at my recent article, &quot;&lt;a href=&quot;http://www.codeproject.com/KB/silverlight/MVVMUtility.aspx&quot;&gt;Data and Command Bindings for Silverlight MVVM Applications&lt;/a&gt;&quot;. &lt;/li&gt;
&lt;li&gt;Unfortunately though, most of the UI events like &quot;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.uielement.mouseenter.aspx&quot;&gt;MouseEnter&lt;/a&gt;&quot;, &quot;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.uielement.mouseleave.aspx&quot;&gt;MouseLeave&lt;/a&gt;&quot;, and &quot;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.sizechanged%28v=vs.95%29.aspx&quot;&gt;SizeChanged&lt;/a&gt;&quot;, etc. do not have the corresponding &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.input.icommand%28v=vs.95%29.aspx&quot;&gt;Commands&lt;/a&gt;, we are unable to implement the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.input.icommand%28v=vs.95%29.aspx&quot;&gt;ICommand&lt;/a&gt; interface to handle these events in the MVVM view models. &lt;/li&gt;
&lt;/ul&gt;
&lt;span id=&quot;ctl00_MC_Top_ArticleDescr&quot;&gt;This article is to introduce a 
method to bind these events to the corresponding methods in the view 
models in Silverlight applications, so we can implement all the event 
handling functions in the view models, thus minimizing the code-behind 
files of the XAML views.&lt;/span&gt;&lt;br /&gt;


&lt;img alt=&quot;SolutionExplorer.JPG&quot; border=&quot;0&quot; height=&quot;490&quot; hspace=&quot;0&quot; src=&quot;http://www.codeproject.com/KB/silverlight/SilverlightEventBinding/SolutionExplorer.JPG&quot; style=&quot;height: 490px; width: 393px;&quot; width=&quot;393&quot; /&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;


The attached Visual Studio solution is developed in Visual Studio 2010 and Silverlight 4. This solution has two projects.&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;The &quot;&lt;code&gt;EventBindingExample&lt;/code&gt;&quot; project is the Silverlight 
application. In this project, I will be demonstrating how to bind UI 
events from the XAML views to the methods in the view models. &lt;/li&gt;
&lt;li&gt;The &quot;&lt;code&gt;EventBindingExampleWeb&lt;/code&gt;&quot; project is an ASP.NET project to host the Silverlight application. The Silverlight application is hosted in the &quot;&lt;em&gt;EventBindingExampleTestPage.aspx&lt;/em&gt;&quot; page. The &quot;&lt;code&gt;EventBindingExampleWeb&lt;/code&gt;&quot; project is the default Silverlight host web project created by the Visual Studio. &lt;/li&gt;
&lt;/ul&gt;
To use the event binding method in this article, you need the &quot;&lt;a href=&quot;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d197f51a-de07-4edf-9cba-1f1b4a22110d&amp;amp;displaylang=en&quot;&gt;Microsoft Expression Blend SDK&lt;/a&gt;&quot;.
 If you have not done so, you need to download the SDK and install it on
 your computer. In particular, to bind the UI events to the 
corresponding methods in the view models, you need to add a reference to
 the &quot;&lt;em&gt;Microsoft.Expression.Interactions.dll&lt;/em&gt;&quot;, which comes with the Blend SDK. You will also need to add a reference to the &quot;&lt;em&gt;System.Windows.Interactivity.dll&lt;/em&gt;&quot;.&lt;br /&gt;


After adding the references to these two DLLs, binding UI events to 
the methods in the Silverlight view models becomes very simple. We will 
now take a look at the implementations of the Silverlight project &quot;&lt;code&gt;EventBindingExample&lt;/code&gt;&quot; to find out how the event binding is achieved. We will first take a look at the view model.&lt;br /&gt;


&lt;h2&gt;
The View Model&lt;/h2&gt;
The &quot;&lt;code&gt;EventBindingExample&lt;/code&gt;&quot; project is a simple Silverlight application, which does not have a data model. The following is the view model class &quot;&lt;code&gt;MainPageViewModel&lt;/code&gt;&quot; implemented in the &quot;&lt;em&gt;ViewModels&lt;/em&gt;\&lt;em&gt;MainPageViewModel.cs&lt;/em&gt;&quot; file.&lt;br /&gt;


&lt;pre lang=&quot;cs&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Net;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows.Controls;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows.Documents;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows.Ink;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows.Input;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows.Media;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows.Media.Animation;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.Windows.Shapes;
&lt;span class=&quot;code-keyword&quot;&gt;using&lt;/span&gt; System.ComponentModel;
 
&lt;span class=&quot;code-keyword&quot;&gt;namespace&lt;/span&gt; EventBindingExample.ViewModels
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;class&lt;/span&gt; MainPageViewModel : INotifyPropertyChanged
    {
        &lt;span class=&quot;code-comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt; Implementation of INotifyPropertyChanged interface
&lt;/span&gt;        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged;
        &lt;span class=&quot;code-keyword&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;void&lt;/span&gt; NotifyPropertyChanged(&lt;span class=&quot;code-keyword&quot;&gt;string&lt;/span&gt; propertyName)
        {
            &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (PropertyChanged != &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;)
            {
                PropertyChanged(&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;, &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; PropertyChangedEventArgs(propertyName));
            }
        }
 
        &lt;span class=&quot;code-comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt; Properties
&lt;/span&gt;        &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;string&lt;/span&gt; displayText;
        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;string&lt;/span&gt; DisplayText
        {
            &lt;span class=&quot;code-keyword&quot;&gt;get&lt;/span&gt; { &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; displayText; }
            &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;set&lt;/span&gt;
            {
                displayText = value;
                NotifyPropertyChanged(&lt;span class=&quot;code-string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt;DisplayText&quot;&lt;/span&gt;);
            }
        }
 
        &lt;span class=&quot;code-comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt; Public methods
&lt;/span&gt;        &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;void&lt;/span&gt; WndSizeChanged(&lt;span class=&quot;code-keyword&quot;&gt;object&lt;/span&gt; sender, SizeChangedEventArgs e)
        {
            DisplayText = &lt;span class=&quot;code-string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt;Window height: &quot;&lt;/span&gt; + e.NewSize.Height.ToString()
                + &lt;span class=&quot;code-string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot;&gt; Window Width: &quot;&lt;/span&gt; + e.NewSize.Width.ToString();
        }
    }
}&lt;/pre&gt;
Besides implementing the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx&quot;&gt;INotifyPropertyChanged&lt;/a&gt; interface, it has a &lt;code&gt;public &lt;/code&gt;property and a &lt;code&gt;public &lt;/code&gt;method.&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;The property &quot;&lt;code&gt;DisplayText&lt;/code&gt;&quot; is a &lt;code&gt;string &lt;/code&gt;that will be bound to a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.aspx&quot;&gt;TextBlock&lt;/a&gt; in the XAML view to display the size information for the Silverlight window. &lt;/li&gt;
&lt;li&gt;The &lt;code&gt;public &lt;/code&gt;method &quot;&lt;code&gt;WndSizeChanged&lt;/code&gt;&quot; will be bound to the &quot;&lt;code&gt;SizeChanged&lt;/code&gt;&quot; event of the Silverlight window in the XAML view. This method takes the window size information from the &quot;&lt;code&gt;SizeChangedEventArgs&lt;/code&gt;&quot; input parameter and uses it to update the &quot;&lt;code&gt;DisplayText&lt;/code&gt;&quot; property. &lt;/li&gt;
&lt;/ul&gt;
Now let us take a look at how the view model is bound to the XAML view.&lt;br /&gt;


&lt;h2&gt;
The XAML View &quot;MainPage.xaml&quot;&lt;/h2&gt;
The XAML view that the view model class &quot;&lt;code&gt;MainPageViewModel&lt;/code&gt;&quot; is bound to is implemented in the &quot;&lt;em&gt;MainPage.xaml&lt;/em&gt;&quot; file:&lt;br /&gt;


&lt;pre lang=&quot;xml&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;UserControl&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;x:Class&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;EventBindingExample.MainPage&quot;&lt;/span&gt;
    &lt;span class=&quot;code-attribute&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;
    &lt;span class=&quot;code-attribute&quot;&gt;xmlns:x&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;
    &lt;span class=&quot;code-attribute&quot;&gt;xmlns:d&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;http://schemas.microsoft.com/expression/blend/2008&quot;&lt;/span&gt;
    &lt;span class=&quot;code-attribute&quot;&gt;xmlns:mc&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;&lt;/span&gt;
    &lt;span class=&quot;code-attribute&quot;&gt;xmlns:ei&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;http://schemas.microsoft.com/expression/2010/interactions&quot;&lt;/span&gt;
    &lt;span class=&quot;code-attribute&quot;&gt;xmlns:i&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;http://schemas.microsoft.com/expression/2010/interactivity&quot;&lt;/span&gt;
    &lt;span class=&quot;code-attribute&quot;&gt;mc:Ignorable&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;d&quot;&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;FontFamily&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;Verdana&quot;&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;FontWeight&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;SemiBold&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
 
    &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;i:Interaction.Triggers&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;i:EventTrigger&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;EventName&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;SizeChanged&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;ei:CallMethodAction&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;MethodName&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;WndSizeChanged&quot;&lt;/span&gt;
                &lt;span class=&quot;code-attribute&quot;&gt;TargetObject&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;{Binding}&quot;&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;i:EventTrigger&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;i:Interaction.Triggers&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
 
    &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;Grid&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;x:Name&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;LayoutRoot&quot;&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;Background&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;White&quot;&lt;/span&gt;
          &lt;span class=&quot;code-attribute&quot;&gt;VerticalAlignment&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;Center&quot;&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;HorizontalAlignment&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;Center&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;TextBlock&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;Foreground&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;Green&quot;&lt;/span&gt; &lt;span class=&quot;code-attribute&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;=&quot;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;{Binding Path=DisplayText}&quot;&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;Grid&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;code-leadattribute&quot;&gt;UserControl&lt;/span&gt;&lt;span class=&quot;code-keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
The &quot;&lt;code&gt;DisplayText&lt;/code&gt;&quot; property of the view model class is bound to a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.aspx&quot;&gt;TextBlock&lt;/a&gt; and the &quot;&lt;code&gt;WndSizeChanged&lt;/code&gt;&quot; method in the view model is bound to the &quot;&lt;code&gt;SizeChanged&lt;/code&gt;&quot;
 event of the Silverlight window. In order to make the event binding 
successful, the signature of the method in the view model needs to match
 exactly the signature required by the event handler &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms173171%28v=vs.80%29.aspx&quot;&gt;delegate&lt;/a&gt; of the bounding event. &lt;br /&gt;


Now, we finish this demo Silverlight application. Is it so simple? 
Will the event binding work? Yes, it works. We can now run the 
application.&lt;br /&gt;


&lt;h2&gt;
Run the Application&lt;/h2&gt;
Set the &quot;&lt;code&gt;EventBindingExampleWeb&lt;/code&gt;&quot; project as the start up project and set the &quot;&lt;em&gt;EventBindingExampleTestPage.aspx&lt;/em&gt;&quot; page as the start page, we can debug run the Silverlight application. When the application starts, the &quot;&lt;code&gt;SizeChanged&lt;/code&gt;&quot; event of the Silverlight window fires. This event triggers the method &quot;&lt;code&gt;WndSizeChanged&lt;/code&gt;&quot; in the view model to update the &quot;&lt;code&gt;DisplayText&lt;/code&gt;&quot; property, so the correct size of the window is displayed for you.&lt;br /&gt;

&lt;img alt=&quot;RunAppSmall.JPG&quot; border=&quot;0&quot; height=&quot;202&quot; hspace=&quot;0&quot; src=&quot;http://www.codeproject.com/KB/silverlight/SilverlightEventBinding/RunAppSmall.JPG&quot; style=&quot;height: 202px; width: 459px;&quot; width=&quot;459&quot; /&gt; 
If you change the size of the browser window, you can see that the 
displayed text is changed as you are changing the window size.&lt;br /&gt;

&lt;img alt=&quot;RunAppBig.JPG&quot; border=&quot;0&quot; height=&quot;310&quot; hspace=&quot;0&quot; src=&quot;http://www.codeproject.com/KB/silverlight/SilverlightEventBinding/RunAppBig.JPG&quot; style=&quot;height: 310px; width: 532px;&quot; width=&quot;532&quot; /&gt; 
&lt;h2&gt;
Conclusion&lt;/h2&gt;
This article demonstrated that we can bind events to the methods in 
the view models in Silverlight applications. In concluding this article,
 we will review the two important points when binding events to the 
methods in the view models in Silverlight applications.&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;To bind events to the view models in Silverlight applications, you need to use the functionalities provided by the &quot;&lt;a href=&quot;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d197f51a-de07-4edf-9cba-1f1b4a22110d&amp;amp;displaylang=en&quot;&gt;Microsoft Expression Blend SDK&lt;/a&gt;&quot;. In particular, you need to add references to the &quot;&lt;em&gt;Microsoft.Expression.Interactions.dll&lt;/em&gt;&quot; and the &quot;&lt;em&gt;System.Windows.Interactivity.dll&lt;/em&gt;&quot; in your project. &lt;/li&gt;
&lt;li&gt;In order to make the event binding successful, the signature of the 
method in the view model needs to match exactly the signature required 
by the event handler delegate of the bounding event. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Points of Interest&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;This simple article introduced a method to bind events to the 
corresponding methods in the MVVM view models in Silverlight 
applications. &lt;/li&gt;
&lt;li&gt;The method introduced in this article is simple. But it is 
significant in developing Silverlight MVVM applications because when 
combined with &lt;a href=&quot;http://www.codeproject.com/KB/silverlight/MVVMUtility.aspx&quot;&gt;command binding&lt;/a&gt;, we can almost eliminate all the code-behind methods in the XAML views to better conform to the MVVM pattern. &lt;/li&gt;
&lt;li&gt;According to &lt;a href=&quot;http://www.amazon.com/Silverlight-4-Action-Pete-Brown/dp/1935182374&quot;&gt;Pete Brown&lt;/a&gt;,
 the method introduced in this article may be slightly slower than 
implementing the event handlers in the code-behind files of the XAML 
views, because this method uses &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/f7ykdhsy%28v=VS.100%29.aspx&quot;&gt;reflection&lt;/a&gt;. The advantage of this method is that it applies to all the UI events fired from all the Silverlight components. &lt;/li&gt;
&lt;li&gt;The method introduced here is largely from the book &quot;Silverlight 4 in Action&quot; by &lt;a href=&quot;http://www.amazon.com/Silverlight-4-Action-Pete-Brown/dp/1935182374&quot;&gt;Pete Brown&lt;/a&gt;. If you are interested in Silverlight development, this book should be a good reference for you. &lt;/li&gt;
&lt;li&gt;Once again, MVVM is a good pattern in developing Silverlight 
applications. But you still need to make your own judgment on a case by 
case basis. The best design pattern is the pattern that best fits your 
application&#39;s need, regardless if it is MVVM or not. &lt;/li&gt;
&lt;li&gt;I hope you like my postings and I hope this article can help you in one way or the other. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
History&lt;/h2&gt;
This is the first revision of this article. &lt;br /&gt;







&lt;/form&gt;
</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/7198619314738672392/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/binding-events-to-methods-in.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/7198619314738672392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/7198619314738672392'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/binding-events-to-methods-in.html' title='Binding Events to Methods in the Silverlight MVVM View Models'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-1441390932681206036</id><published>2011-09-12T22:30:00.000-07:00</published><updated>2011-09-12T22:31:09.884-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Phone"/><title type='text'>Creación de Prototipos de Proyectos para Windows Phone.</title><content type='html'>Este post lo escribi originalmente en mi blog personal el dia 08/08/2011&lt;br /&gt;
&lt;br /&gt;
Cada vez que nos sentamos delante de nuestro ordenador, cada vez que hablamos con nuestro grupo de trabajo o con nuestros compañeros, o porque no cuando queremos mostrar ese proyecto tan molón a nuestro gerente, deberíamos de apoyarnos en un prototipo del mismo. Para ello estos recursos son de lo mejor que podemos usar. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;&lt;/h2&gt;&lt;br /&gt;
&lt;h2&gt;Lápiz y Papel.&lt;/h2&gt;&lt;br /&gt;
Como muy bien dice mi amigo &lt;a href=&quot;http://www.twitter.com/josueyeray&quot;&gt;Yeray&lt;/a&gt;, a nosotros los programadores esto del “Pinta y Colorea”, se nos da fatal pero no se porque razón buscamos rápidamente un lápiz y un papel para expresar nuestros esquemas o nuestras pantallas, en vez de ir al ordenador y garabatear algo con el Paint, por ejemplo. En fin para todo aquel que se sienta mas cómodo con un bolígrafo en la mano puede descargarse estas plantillas:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tecnologia.rafaserna.es/files/2011/08/Windows_Stencil-2.jpg&quot;&gt;&lt;img alt=&quot;Windows_Stencil-2&quot; border=&quot;0&quot; height=&quot;163&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/Windows_Stencil-2_thumb.jpg&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px 15px 10px 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;Windows_Stencil-2&quot; width=&quot;325&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Los utensilios de &lt;a href=&quot;http://www.uistencils.com/&quot;&gt;UI Stencils&lt;/a&gt; aun siendo de pago, la verdad es que merece y mucho la pena disponer de estas &lt;a href=&quot;http://www.uistencils.com/products/windows-phone-stencil-kit&quot;&gt;plantillas en acero inoxidable&lt;/a&gt; para poder dibujar sobre &lt;a href=&quot;http://www.uistencils.com/products/windows-phone-sketch-pad&quot;&gt;sus blocs&lt;/a&gt; o sobre sus &lt;a href=&quot;http://www.uistencils.com/products/windows-phone-sticky-pad&quot;&gt;pantallas adhesivas&lt;/a&gt;, muy pero que muy recomendable para hacer cosas profesionales. &lt;br /&gt;
&lt;br /&gt;
En la web de &lt;a href=&quot;http://jakubflorczyk.pl/&quot;&gt;Jakub Florczyk&lt;/a&gt;, podemos encontrar un Pdf con &lt;a href=&quot;http://jakubflorczyk.pl/index.php/2010/05/08/windows-phone-7-idea-sheet/&quot;&gt;la plantilla de 4 Windows Phone&lt;/a&gt; a tamaño natural, al menos tienen el tamaño de mi HTC 7 Trophy, para realizar nuestros prototipos. Descárgalo desde &lt;a href=&quot;http://jakubflorczyk.pl/wp-content/uploads/2010/05/windows-phone-7-idea-sheet.pdf&quot;&gt;aquí&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Algo parecido podemos encontrar en la web de &lt;a href=&quot;http://www.michaeldorian.com/&quot;&gt;Michael Dorian&lt;/a&gt;, en donde en &lt;a href=&quot;http://www.michaeldorian.com/journal/entry/windows_phone_7_wireframe_paper_sketch_template&quot;&gt;esta ocasión&lt;/a&gt; disponemos de una plantilla de 3 pantallas y el espacio necesario para catalogar nuestros prototipos, como lugar donde escribir el proyecto, la pagina, etc.. Se puede descargar directamente desde &lt;a href=&quot;http://dl.dropbox.com/u/30813/wp7-sketch-paper-template.pdf&quot;&gt;aquí&lt;/a&gt;. &lt;img alt=&quot;Dorian&quot; border=&quot;0&quot; height=&quot;345&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/Dorian_thumb.png&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin: 0px auto 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;Dorian&quot; width=&quot;464&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;&lt;/h2&gt;&lt;br /&gt;
&lt;h2&gt;Fuente original para Windows.&lt;/h2&gt;&lt;br /&gt;
Mas adelante hablaremos de recursos ya para aplicaciones de software, pero lo mas importante es disponer en nuestro sistema de la fuente utilizada en la UI de Windows Phone, en este caso la fuente &lt;a href=&quot;http://es.wikipedia.org/wiki/Segoe&quot;&gt;Segoe&lt;/a&gt;. Se dispone de dos ramas, por un lado la fuente &lt;a href=&quot;http://www.microsoft.com/typography/fonts/family.aspx?FID=331&quot;&gt;Segoe UI&lt;/a&gt;, que viene preinstalada con Windows y por otro lado la fuente &lt;em&gt;Segoe WP&lt;/em&gt;, que es una variante de la anterior y es realmente la que el interface Metro utiliza. Viene incluida en las Tools de Windows Phone para Visual Studio, pero se puede descargar desde &lt;a href=&quot;http://go.microsoft.com/fwlink/?LinkId=196225&quot;&gt;aquí&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;&lt;/h2&gt;&lt;br /&gt;
&lt;h2&gt;Plantillas para aplicaciones genéricas.&lt;/h2&gt;&lt;br /&gt;
Es fácil encontrar por la red innumerables plantillas para diferentes aplicaciones, pero yo estas para Visio, Powerpoint y Photoshop. &lt;br /&gt;
&lt;br /&gt;
Por un lado las plantillas para Microsoft Visio de &lt;a href=&quot;http://www.griffininteractive.net/&quot;&gt;Griffin Interactive&lt;/a&gt;, en donde se incluyen plantillas para proyectos tanto con Pivot como con Panorama Template, las cuales se pueden descargar desde &lt;a href=&quot;http://www.griffininteractive.net/store/WP7-Template.vsd&quot;&gt;aquí&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
Para PowerPoint disponemos de las plantillas de &lt;a href=&quot;http://thinkfirstcodelater.com/&quot;&gt;Think first code later&lt;/a&gt;, las cuales podemos descargar para realizar nuestras presentaciones con un fondo como si de una pantalla de Windows Phone se tratara, disponibles &lt;a href=&quot;http://thinkfirstcodelater.com/presentations/wp7.potx&quot;&gt;aquí&lt;/a&gt;. O el tema de &lt;a href=&quot;http://www.studentguru.gr/blogs/vangos/default.aspx&quot;&gt;Vangos Pterneas&lt;/a&gt;, el cual nos permite utilizar en nuestras propias presentaciones y apoyarnos en cualquiera de sus slides, &lt;a href=&quot;http://www.studentguru.gr/blogs/vangos/archive/2010/12/05/windows-phone-7-metro-ui-theme-for-powerpoint.aspx&quot;&gt;esta presentación&lt;/a&gt; esta disponible a través de SlideShare desde &lt;a href=&quot;http://www.slideshare.net/Pterneas/windows-phone-7-5998534/download&quot;&gt;aquí.&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Y finalmente para Photoshop, existen múltiples recursos, pero uno de los principales y a mi modo de ver el mejor, es el compendio de PSDs del propio equipo de desarrollo de Windows Phone, el cual se puede descargar desde &lt;a href=&quot;http://go.microsoft.com/fwlink/?LinkId=196225&quot;&gt;aquí&lt;/a&gt;. De nuevo, el amigo &lt;a href=&quot;http://www.studentguru.gr/blogs/vangos/archive/2010/12/09/photoshop-templates-for-windows-phone-7.aspx&quot;&gt;Vangos Pterneas&lt;/a&gt;, nos regala un par de templates tambien muy interesantes para photoshop, la primera de ellas para pantallas simples tanto en orientación portrait como landscape, descargable desde &lt;a href=&quot;http://www.studentguru.gr/blogs/vangos/photoshop-templates-for-windows-phone-7/windows-phone-7-photoshop-templates-1.zip&quot;&gt;aquí&lt;/a&gt; y otra para pantallas Pivot y Panorama, descargable desde &lt;a href=&quot;http://www.studentguru.gr/blogs/vangos/photoshop-templates-for-windows-phone-7/windows-phone-7-photoshop-templates-2.zip&quot;&gt;aquí&lt;/a&gt; &lt;a href=&quot;http://tecnologia.rafaserna.es/files/2011/08/windows-phone-7-panorama.png&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;img alt=&quot;windows-phone-7-panorama&quot; border=&quot;0&quot; height=&quot;330&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/windows-phone-7-panorama_thumb.png&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin: 0px auto 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;windows-phone-7-panorama&quot; width=&quot;526&quot; /&gt;&lt;/a&gt; Muchas cosas como digo repartidas por la web, pero cabe destacar también &lt;a href=&quot;http://blogs.claritycon.com/windowsphone7/2011/01/12/wicked-wireframes-wp7-vector-ux-kit-3/&quot;&gt;estas plantillas&lt;/a&gt; para Adobe Illustrator de &lt;a href=&quot;http://blogs.claritycon.com/index.php&quot;&gt;Clarity Consulting&lt;/a&gt;, las cuales se puede descargar desde &lt;a href=&quot;http://employees.claritycon.com/eklimczak/Blogs/UX%20Kit/WP7_Prototype_Kit.zip&quot;&gt;aquí&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;&lt;/h2&gt;&lt;br /&gt;
&lt;h2&gt;Plantillas para aplicaciones de prototipado.&lt;/h2&gt;&lt;br /&gt;
A parte de poder usar aplicaciones de carácter general, para prototipar, podemos usar, obviamente aplicaciones propias para este tema, Aplicaciones de prototipado, existen como todo innumerables pero yo destaco 3, junto con sus correspondientes templates.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.microsoft.com/expression/products/SketchFlow_WhatIsSketchFlow.aspx&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Microsoft SketchFlow&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;br /&gt;
&lt;br /&gt;
Aplicación de prototipado de Microsoft que viene con la suite Expression, formando parte, como un complemente diría yo de Microsoft Expression Blend, solo disponible con la versión ultimate de Expression Studio (creo). Herramienta bastante buena, sobre todo si manejamos constantemente &lt;a href=&quot;http://www.microsoft.com/expression/products/Blend_Overview.aspx&quot;&gt;Expression Blend&lt;/a&gt;, muy integrada y bastante completa. Podemos descargarnos los templates para prototipos de aplicaciones en Windows Phone, desde &lt;a href=&quot;http://wp7sketchflow.codeplex.com/&quot;&gt;este espacio en Codeplex.&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://tecnologia.rafaserna.es/files/2011/08/skechflow1.png&quot;&gt;&lt;img alt=&quot;skechflow1&quot; border=&quot;0&quot; height=&quot;377&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/skechflow1_thumb.png&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px 15px 10px 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;skechflow1&quot; width=&quot;214&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.axure.com/&quot;&gt;&lt;img alt=&quot;skechflow2&quot; border=&quot;0&quot; height=&quot;376&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/skechflow2.png&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px 0px 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;skechflow2&quot; width=&quot;213&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.axure.com/&quot;&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Axure RP&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;: &lt;br /&gt;
&lt;br /&gt;
He dicho bien, axure que no azure, es una herramienta de prototipado de todo tipo de aplicaciones, entre ellas como no Windows Phone, para ello podemos descargarnos una serie de templates para tal efecto, creadas por Andrej Skaza, las cuales podemos descargar tanto desde Axureland, &lt;a href=&quot;http://axureland.com/entry/windows_phone_7_library&quot;&gt;aquí&lt;/a&gt;, como desde &lt;a href=&quot;http://lab.studiopesec.com/&quot;&gt;Studio Pesec&lt;/a&gt; desde &lt;a href=&quot;http://dl.dropbox.com/u/33955306/win7phone.zip&quot;&gt;aquí&lt;/a&gt;, el cual nos muestra también como podemos montar un ejemplo de web con nuestros prototipos exponerlo al exterior para que nuestro cliente por ejemplo lo pueda ver. Podemos verlo &lt;a href=&quot;http://razvoj.studiopesec.com:81/mockup/mobile/wp7/&quot;&gt;aquí.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;Axure&quot; border=&quot;0&quot; height=&quot;404&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/Axure_thumb.jpg&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin: 0px auto 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;Axure&quot; width=&quot;463&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.omnigroup.com/products/omnigraffle/&quot;&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Omnigraffle&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
Otra aplicación de prototipado general, en este caso para MAC, muy utilizada por el mundo iOS pero que gracias a Adrian Mendoza y a su &lt;a href=&quot;http://www.marlinmobile.com/blog&quot;&gt;Blog Marlin Mobile&lt;/a&gt;, podemos descargarnos desde &lt;a href=&quot;http://www.marlinmobile.com/tools/Windows_Phone_7_UX_stencil.zip&quot;&gt;aquí&lt;/a&gt; unos templates para desarrollar prototipos de aplicaciones Windows Phone. &lt;a href=&quot;http://tecnologia.rafaserna.es/files/2011/08/Omni.png&quot;&gt;&lt;img alt=&quot;Omni&quot; border=&quot;0&quot; height=&quot;404&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/Omni_thumb.png&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin: 0px auto 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;Omni&quot; width=&quot;427&quot; /&gt;&lt;/a&gt; A parte de todo esto, existen como no templates directos para desarrollar aplicaciones desde Visual Studio, una de las mas completas es el proyecto “Windows Phone 7 Design Templates” alojado &lt;a href=&quot;http://wp7designtemplates.codeplex.com/&quot;&gt;aquí&lt;/a&gt; en Codeplex. &lt;a href=&quot;http://tecnologia.rafaserna.es/files/2011/08/WP7DesignTempltes.png&quot;&gt;&lt;img alt=&quot;WP7DesignTempltes&quot; border=&quot;0&quot; height=&quot;284&quot; src=&quot;http://tecnologia.rafaserna.es/files/2011/08/WP7DesignTempltes_thumb.png&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin: 0px auto 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;WP7DesignTempltes&quot; width=&quot;443&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;&lt;img height=&quot;1&quot; src=&quot;http://geeks.ms/aggbug.aspx?PostID=199938&quot; width=&quot;1&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/1441390932681206036/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/creacion-de-prototipos-de-proyectos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/1441390932681206036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/1441390932681206036'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/creacion-de-prototipos-de-proyectos.html' title='Creación de Prototipos de Proyectos para Windows Phone.'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-4560937844058054109</id><published>2011-09-12T08:43:00.001-07:00</published><updated>2011-09-12T08:43:19.169-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVVM"/><title type='text'>Using the MVVM Pattern in Silverlight Applications</title><content type='html'>&lt;div class=&quot;article-title keyline&quot;&gt;
&lt;h1&gt;
Using the MVVM Pattern in Silverlight Applications&lt;/h1&gt;
&lt;div class=&quot;details&quot;&gt;
By&amp;nbsp;Microsoft Silverlight Team&lt;span class=&quot;separator&quot;&gt;|&lt;/span&gt;December 1, 2010&lt;span class=&quot;separator&quot;&gt;|&lt;/span&gt;Level 300 : Intermediate&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;
Contents&lt;/h2&gt;
&lt;div class=&quot;important&quot;&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.silverlight.net/learn/advanced-techniques/the-mvvm-pattern/using-the-mvvm-pattern-in-silverlight-applications#Overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.silverlight.net/learn/advanced-techniques/the-mvvm-pattern/using-the-mvvm-pattern-in-silverlight-applications#Exercise1&quot;&gt;Exercise 1: Creating a Service Agent Class&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.silverlight.net/learn/advanced-techniques/the-mvvm-pattern/using-the-mvvm-pattern-in-silverlight-applications#Exercise2&quot;&gt;Exercise 2: Creating a ViewModel Class&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.silverlight.net/learn/advanced-techniques/the-mvvm-pattern/using-the-mvvm-pattern-in-silverlight-applications#Exercise3&quot;&gt;Exercise 3: Handling Commands and Binding to a ViewModel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.silverlight.net/learn/advanced-techniques/the-mvvm-pattern/using-the-mvvm-pattern-in-silverlight-applications#Summary&quot;&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;featured_vid_options&quot;&gt;

&lt;a class=&quot;common-btn&quot; href=&quot;http://i1.silverlight.net/content/tutorials/firestarter/downloads/Firestarter.Setup.exe&quot;&gt;&lt;span&gt;Download Offline Kit&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;spacer&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;clear&quot;&gt;&lt;/span&gt;

&lt;a href=&quot;&quot; name=&quot;Overview&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Overview&lt;/h2&gt;
Estimated Time: 45 minutes&lt;br /&gt;

The Model-View-ViewModel (MVVM) pattern provides a flexible way to 
build Silverlight applications that promotes code re-use, simplifies 
maintenance and supports testing. The pattern consists of three 
different components including the Model (entities and code on the 
server), the View (the Silverlight screens) and the ViewModel (the glue 
between the Model and the View).  An example of the how the Model, View 
and ViewModel components relate to each other is shown next:&lt;br /&gt;


&lt;img alt=&quot;&quot; src=&quot;http://i2.silverlight.net/content/tutorials/firestarter/lab10/figure1.png&quot; /&gt;
&lt;br /&gt;

In this lab exercise you&#39;ll learn how to migrate an existing 
Silverlight application that uses &lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;code-behind files for all of the C# or
 VB code into a more structured architecture that follows the MVVM 
pattern.  Topics covered include creating a service agent class to 
handle calls to a WCF service, creating a ViewModelBase class, creating a
 custom ViewModel class and binding a ViewModel to a View declaratively 
in XAML. You&#39;ll also see how commanding can be used to wire-up events in
 a View to methods in a ViewModel.  The application that you&#39;ll work 
with in the lab exercises is shown next:&lt;br /&gt;


&lt;img alt=&quot;&quot; src=&quot;http://i2.silverlight.net/content/tutorials/firestarter/lab10/figure2.png&quot; /&gt;
&lt;br /&gt;

&lt;div class=&quot;note&quot;&gt;
It&#39;s recommended that you complete the data binding and 
WCF labs before starting this lab. Some of the steps in the lab will 
provide the code to use while others will explain the task to perform 
and let you figure out the code that should be added. If you need help 
with any of the steps refer to the lab&#39;s Completed folder which contains
 the finished code.&lt;/div&gt;
&lt;h3&gt;
You Will Benefit from this Lab if:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;You&#39;re interested in building Silverlight applications that take 
advantage of code re-use, promote testability and reduce maintenance 
costs&lt;/li&gt;
&lt;li&gt;You&#39;d like to separate your Silverlight application into distinct 
modules and provide a pattern that can be followed by a team of 
developers&lt;/li&gt;
&lt;li&gt;You&#39;re interested in learning the MVVM pattern and the benefits it offers&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
You Will Learn:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;How to convert an existing Silverlight application to use the MVVM pattern&lt;/li&gt;
&lt;li&gt;The role of the Model, ViewModel and View in the MVVM pattern&lt;/li&gt;
&lt;li&gt;How to create a service agent class and the role it can play in an application to promote code re-use&lt;/li&gt;
&lt;li&gt;How to create a ViewModel class and handle property change notifications&lt;/li&gt;
&lt;li&gt;How to bind a ViewModel class to a View &lt;/li&gt;
&lt;li&gt;How to communicate between a View and ViewModel using commanding&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Business Requirements for the Silverlight application include:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Remove existing code from a Silverlight code-beside file&lt;/li&gt;
&lt;li&gt;Create a service agent interface and class to handle calls to a WCF service&lt;/li&gt;
&lt;li&gt;Create a ViewModelBase class to handle INotifyPropertyChanged notifications&lt;/li&gt;
&lt;li&gt;Create a ViewModel class that derives from ViewModelBase and handles data interactions&lt;/li&gt;
&lt;li&gt;Add support for commanding into a ViewModel class&lt;/li&gt;
&lt;li&gt;Bind a ViewModel class to a View in XAML&lt;/li&gt;
&lt;li&gt;Bind Silverlight controls to ViewModel properties&lt;/li&gt;
&lt;/ul&gt;
&lt;a href=&quot;&quot; name=&quot;Exercise1&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Exercise 1: Creating a Service Agent Class&lt;/h2&gt;
&lt;div class=&quot;video_and_thumbnail&quot; id=&quot;video1&quot;&gt;

&lt;div class=&quot;thumb_img&quot;&gt;
&lt;a href=&quot;http://www.silverlight.net/learn/advanced-techniques/the-mvvm-pattern/using-the-mvvm-pattern-in-silverlight-applications#Exercise1&quot;&gt;&lt;img src=&quot;http://i2.silverlight.net/content/tutorials/firestarter/thumbs/videos/lab10-ex1.jpg&quot; /&gt;&lt;span class=&quot;common-btn&quot;&gt;Watch Video&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
In this exercise you&#39;ll remove existing code in a code-beside file 
and create a service agent class. The service agent class will be used 
to make calls to a WCF service from within a ViewModel class created 
later in the lab. &lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;Open the following Visual Studio 2010 solution file based upon your chosen language.
&lt;table&gt;
  &lt;tbody&gt;
&lt;tr&gt;
 &lt;th class=&quot;col1&quot;&gt;Language&lt;/th&gt;
 &lt;th class=&quot;col2&quot;&gt;Lab Files Location&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
 &lt;td class=&quot;col1&quot;&gt;C#&lt;/td&gt;
 &lt;td class=&quot;col2&quot;&gt;/MVVMPattern/Starting Point/C#/CustomerViewer.sln&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
 &lt;td class=&quot;col1&quot;&gt;Visual Basic&lt;/td&gt;
 &lt;td class=&quot;col2&quot;&gt;/MVVMPattern/Starting Point/VB/CustomerViewer.sln&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;li&gt;The following projects are available in the solution:
&lt;ul&gt;
&lt;li&gt;CustomerService.Model – Contains entities and data repository classes used to access an AdventureWorks LT database.&lt;/li&gt;
&lt;li&gt;CustomersService – A WCF service application that exposes entities to various applications.&lt;/li&gt;
&lt;li&gt;SilverlightCustomerViewer – A Silverlight project that consumes data from a WCF service.&lt;/li&gt;
&lt;li&gt;SilverlightCustomerViewer.Web – A website project used to host the SilverlightCustomerViewer application.&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt=&quot;&quot; src=&quot;http://i2.silverlight.net/content/tutorials/firestarter/lab10/figure3.png&quot; /&gt;
&lt;/li&gt;
&lt;li&gt;Right-click CustomerService.svc in the CustomersService project and 
select View in Browser from the menu. This will start a local WCF server
 and show details about the service.&lt;/li&gt;
&lt;li&gt;Back in Visual Studio, right-click 
SilverlightCustomerViewerTestPage.html in the 
SilverlightCustomerViewer.Web project and select View in Browser from 
the menu.  Select customers from the ComboBox control (note that you may
 have to wait a moment for the customers to load the first time the 
application is run) and notice that the data for each customer displays 
in the details area.&lt;/li&gt;
&lt;li&gt;Back in Visual Studio, open MainPage.xaml.cs located in the 
SilverlightCustomerViewer project in the code editor and remove all of 
the existing code within the MainPage class except the constructor and 
the call to InitializeComponent.

&lt;div class=&quot;note&quot;&gt;
All of the functionality in the code-beside file will be moved into a ViewModel class that you&#39;ll create later in this lab.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Open MainPage.xaml and remove the Click event handlers defined on the two Button controls.&lt;/li&gt;
&lt;li&gt;Right-click on the SilverlightCustomerViewer project and select Add ? New Folder. Give the folder a name of ServiceAgents.&lt;/li&gt;
&lt;li&gt;Add a new class into the ServiceAgents folder named CustomersServiceAgent.&lt;/li&gt;
&lt;li&gt;Add the following interface immediately above the class and resolve any missing namespaces:

&lt;div class=&quot;note&quot;&gt;
Resolve any missing namespaces by right-clicking on an unknown type and then selecting Resolve in the menu.&lt;/div&gt;
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;interface&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ICustomersServiceAgent&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;EventHandler&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;GetCustomersCompletedEventArgs&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Customer&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cust&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;EventHandler&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomerCompletedEventArgs&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;Public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Interface&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ICustomersServiceAgent
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;ByVal&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _
&amp;nbsp; &amp;nbsp; &amp;nbsp; EventHandler&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Of GetCustomersCompletedEventArgs&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;ByVal&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cust &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; Customer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;ByVal&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; EventHandler&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Of SaveCustomerCompletedEventArgs&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Interface&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Implement the ICustomerService interface on the CustomersServiceAgent class.&lt;/li&gt;
&lt;li&gt;Add the following field into the CustomersServiceAgent class:
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;typ&quot;&gt;CustomerServiceClient&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _Proxy &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;CustomerServiceClient&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;();&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;Dim&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _Proxy &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; CustomerServiceClient&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;note&quot;&gt;
The CustomerServiceClient class is a WCF service proxy 
class that will be used to communicate with the remote service to 
retrieve customer data and perform update and delete operations.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Add the following code in the GetCustomers method to handle calling the WCF service operation:
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;pln&quot;&gt;_Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;GetCustomersCompleted&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
_Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;GetCustomersAsync&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;();&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;AddHandler&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;GetCustomersCompleted&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback
_Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;GetCustomersAsync&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Add the following code in the SaveCustomer method to handle communicating delete and update data operations to the WCF service:
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;pln&quot;&gt;_Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomerCompleted&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
_Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomerAsync&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cust&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;AddHandler&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;SaveCustomerCompleted&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callback
_Proxy&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;SaveCustomerAsync&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cust&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;a href=&quot;&quot; name=&quot;Exercise2&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Exercise 2: Creating a ViewModel Class&lt;/h2&gt;
In this exercise you&#39;ll create a ViewModelBase class that provides 
core functionality that can be used by one or more ViewModel classes. 
You&#39;ll then derive from ViewModelBase and create a ViewModel class that 
will be used to retrieve and manipulate customer data used in the 
MainPage.xaml View.&lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;Locate the file named mvvmInpcPropertyCS.snippet (for C#) or 
mvvmInpcPropertyVB.snippet (for VB) in the 
SilverlightCustomerViewer/CodeSnippets folder. &lt;/li&gt;
&lt;li&gt;Copy the file for your chosen language to the following location (or
 use Tools ? Code Snippets Manager in Visual Studio to import it):
&lt;table&gt;
  &lt;tbody&gt;
&lt;tr&gt;
 &lt;th class=&quot;col1&quot;&gt;Language&lt;/th&gt;
 &lt;th class=&quot;col2&quot;&gt;Lab Files Location&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
 &lt;td class=&quot;col1&quot;&gt;C#&lt;/td&gt;
 &lt;td class=&quot;col2&quot;&gt;Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
 &lt;td class=&quot;col1&quot;&gt;Visual Basic&lt;/td&gt;
 &lt;td class=&quot;col2&quot;&gt;Documents\Visual Studio 2010\Code Snippets\Visual Basic\My Code Snippets&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;note&quot;&gt;
The mvvmInpc snippet will be used to create properties 
within a ViewModel class later in this lab.  It&#39;s one of several 
snippets available in MVVM Light (http://mvvmlight.codeplex.com) and has
 been modified for use in this lab exercise.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Right-click on the SilverlightCustomerViewer project and select Add ? New Folder. Give the folder a name of ViewModels.&lt;/li&gt;
&lt;li&gt;Add a new class into the ViewModels folder named ViewModelBase and mark it as abstract (C#) or MustInherit (VB).&lt;/li&gt;
&lt;li&gt;Implement the INotifyPropertyChanged interface on the class and resolve the namespace.

&lt;div class=&quot;note&quot;&gt;
INotifyPropertyChanged is an important interface in 
Silverlight used by the data binding engine to notify controls and other
 objects when a bound property value changes. By implementing 
INotifyPropertyChanged on the ViewModelBase class you can write the code
 once and re-use it across multiple ViewModel classes. The interface is 
located in the System.ComponentModel namespace. &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Once the interface has been implemented on the ViewModelBase class, 
add a method named OnPropertyChanged into ViewModelBase to handle 
raising the PropertyChanged event from the INotifyPropertyChanged 
interface.

&lt;div class=&quot;note&quot;&gt;
If you need help with this step please refer to the 
ViewModelBase class in the lab&#39;s Completed folder. Creating an 
OnPropertyChanged method was covered in the data binding lab.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Add a new public Boolean property into the ViewModelBase class named IsDesignTime. &lt;/li&gt;
&lt;li&gt;Add a get block (but no set block) into the property that returns 
DesignerProperties.IsInDesignTool as the value. Resolve any namespaces 
as needed.

&lt;div class=&quot;note&quot;&gt;
When using the MVVM pattern and ViewModel classes it&#39;s 
important to know when code is executing in a design-time tool such as 
Visual Studio or Expression Blend and when it&#39;s executing at runtime. 
When code runs in a design tool network calls will not execute properly 
and can error out the designer. The IsDesignTime property will be used 
to detect where code is running to ensure that ViewModel classes execute
 properly at design-time.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Add a new class into the ViewModels folder named MainPageViewModel that derives from ViewModelBase .&lt;/li&gt;
&lt;li&gt;Add the following properties into MainPageViewModel using the 
mvvmInpc code snippet  and resolve any missing namespaces as necessary 
(type mvvmInpc + tab + tab to use the snippet in C# or mvvminpc + tab to
 use the snippet in VB):
&lt;table&gt;
  &lt;tbody&gt;
&lt;tr&gt;
 &lt;th class=&quot;col1&quot;&gt;Property Name&lt;/th&gt;
 &lt;th class=&quot;col2&quot;&gt;Property Type&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
 &lt;td class=&quot;col1&quot;&gt;Customers&lt;/td&gt;
 &lt;td class=&quot;col2&quot;&gt;ObservableCollection of Customer&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
 &lt;td class=&quot;col1&quot;&gt;CurrentCustomer&lt;/td&gt;
 &lt;td class=&quot;col2&quot;&gt;Customer&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
 &lt;td class=&quot;col1&quot;&gt;StatusMessage&lt;/td&gt;
 &lt;td class=&quot;col2&quot;&gt;string&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;note&quot;&gt;
If you need help with creating the properties in this step refer to the MainPageViewModel class in the lab&#39;s Completed folder.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Within the CurrentCustomer property&#39;s set block add code to set the 
StatusMessage property to empty strings (add the code within the 
existing &quot;if&quot; statement).&lt;/li&gt;
&lt;li&gt;Add another property named ServiceAgent of type 
ICustomersServiceAgent and resolve the namespace (create it as a 
standard .NET property).&lt;/li&gt;
&lt;li&gt;Add the following methods into MainPageViewModel to handle retrieving, updating and deleting customer objects: 

&lt;div class=&quot;note&quot;&gt;
The ObjectState parameter used in the following code is 
automatically created by the WCF proxy generator when using 
self-tracking entities in Entity Framework 4. By changing the object 
state we can easily track whether delete or update operations should 
occur for a given Customer object.&lt;/div&gt;
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ServiceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Customers&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;UpdateCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ObjectState&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Modified&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;DeleteCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ObjectState&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Deleted&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; 
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Customers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Remove&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;CurrentCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;CurrentCustomer&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ObjectState&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; state&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;CurrentCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ChangeTracker&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;State&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; state&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ServiceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;CurrentCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;StatusMessage&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Status&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;Success!&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; 
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;Unable to complete operation&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;Private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; ServiceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; Customers &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; UpdateCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ObjectState&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Modified&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; DeleteCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ObjectState&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Deleted&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; Customers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;Remove(CurrentCustomer)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; CurrentCustomer &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;Nothing&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;ByVal&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; state &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ObjectState&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; CurrentCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ChangeTracker&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;State &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; state
&amp;nbsp; &amp;nbsp; ServiceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;SaveCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;CurrentCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; StatusMessage &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;If&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Status&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;Success!&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;Unable to complete operation&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Add the following constructors into MainPageViewModel:
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;MainPageViewModel&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;CustomersServiceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;())&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;MainPageViewModel&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ICustomersServiceAgent&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; serviceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;IsDesignTime&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;serviceAgent &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;ServiceAgent&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; serviceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;Public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Me&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; CustomersServiceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;())&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;ByVal&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; serviceAgent &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ICustomersServiceAgent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;If&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Not&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; IsDesignTime &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Then&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;If&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; serviceAgent IsNot &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;Nothing&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Then&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Me&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ServiceAgent &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; serviceAgent
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;If&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GetCustomers&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;If&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;note&quot;&gt;
The first constructor will be called if the ViewModel is
 instantiated without any parameters.  It passes a new instance of the 
CustomersServiceAgent object to the second constructor which assigns it 
to the ServiceAgent property when not in design mode (note that instead 
of hard coding the service agent type it could be injected using a 
dependency injection framework). The second constructor accepts any 
object that implements the ICustomersServiceAgent interface allowing 
mock objects to be passed in for the service agent when testing the 
ViewModel class. Following this pattern provides a flexible way to work 
with different types of service agent objects when the application is 
running as well as when tests need to be executed.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Ensure that the SilverlightCustomerViewer project compiles before proceeding to the next exercise.&lt;/li&gt;
&lt;/ol&gt;
&lt;a href=&quot;&quot; name=&quot;Exercise3&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Exercise 3: Handling Commands and Binding to a ViewModel&lt;/h2&gt;
In this exercise you&#39;ll add commanding support into the 
SilverlightCustomerViewer project. Commanding allows events triggered in
 a View such as a Button&#39;s Click event to be routed directly to a 
ViewModel instance without having to add code in a code-beside file. 
You&#39;ll be introduced to the ICommand interface as well as a RelayCommand
 class that will be used within MainPageViewModel to handle commands. 
Finally, you&#39;ll bind MainPageViewModel to a View using a declarative 
binding syntax.&lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;Open the Commanding/RelayCommand.cs class in the 
SilverlightCustomerViewer project and note that it implements ICommand. 
This interface is required in order for a Silverlight application to 
support commanding.

&lt;div class=&quot;note&quot;&gt;
Commanding is the process of forwarding events that 
occur in the user interface to a ViewModel object for processing at 
runtime.  The RelayCommand class will be used to wire properties in a 
ViewModel to methods that are invoked when any control derived from 
ButtonBase is clicked in a View. It satisfies the ICommand interface 
allowing commanding to be used in Silverlight MVVM applications.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Add the following code into MainPageViewModel to create properties 
capable of binding to controls that expose a Command property. Resolve 
the required namespace.
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;RelayCommand&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;UpdateCustomerCommand&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; get&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; set&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;RelayCommand&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;DeleteCustomerCommand&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; get&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; set&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;Private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _UpdateCustomerCommand &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Property&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; UpdateCustomerCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _UpdateCustomerCommand
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;ByVal&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; value &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _UpdateCustomerCommand &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; value
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Property&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _DeleteCustomerCommand &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Public&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Property&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; DeleteCustomerCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; _DeleteCustomerCommand
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;ByVal&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; value &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;As&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _DeleteCustomerCommand &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; value
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Property&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Add the following code into MainPageViewModel to handle wiring up 
the properties defined in the previous step to methods that will be 
invoked once a command is executed:
&lt;h4 class=&quot;label&quot;&gt;
C#&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-cs&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;WireCommands&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;UpdateCustomerCommand&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;RelayCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;UpdateCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;DeleteCustomerCommand&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;RelayCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;DeleteCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h4 class=&quot;label&quot;&gt;
Visual Basic&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-vb&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;Private&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; WireCommands&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; UpdateCustomerCommand &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;AddressOf&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; UpdateCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &amp;nbsp;
&amp;nbsp; &amp;nbsp; DeleteCustomerCommand &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; RelayCommand&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;AddressOf&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; DeleteCustomer&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;End&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;note&quot;&gt;
WireCommands handles associating two RelayCommand 
properties with methods that will be invoked as a command is executed in
 a View.  For example, any Button with a Command property bound to 
UpdateCustomerCommand will cause the UpdateCustomer method to be 
invoked.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Add a call to the WireCommands method within MainPageViewModel&#39;s 
second constructor (add the code immediately under the GetCustomers 
method call within the constructor).&lt;/li&gt;
&lt;li&gt;Add code within the CurrentCustomer property&#39;s set block to assign 
the IsEnabled property of UpdateCustomerCommand and 
DeleteCustomerCommand to a value of true (add the code within the 
existing &quot;if&quot; statement). &lt;/li&gt;
&lt;li&gt;Open MainPage.xaml and add the following xml namespace definition on
 the UserControl element to reference the ViewModels namespace:
&lt;h4 class=&quot;label&quot;&gt;
XAML&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&lt;span class=&quot;pln&quot;&gt;xmlns:viewModels=&quot;clr-namespace:SilverlightCustomerViewer.ViewModels&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Create a UserControl.Resources element within the XAML immediately 
below the beginning UserControl element and add the following code into 
it:
&lt;h4 class=&quot;label&quot;&gt;
XAML&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;viewModels:MainPageViewModel&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;x:Key&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&quot;ViewModel&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Bind the ViewModel key created in the previous step to the 
LayoutRoot element&#39;s DataContext property using a StaticResource 
binding. This will bind a MainPageViewModel object instance to the 
DataContext.
&lt;h4 class=&quot;label&quot;&gt;
XAML&lt;/h4&gt;
&lt;pre class=&quot;prettyprint lang-xml&quot;&gt;&lt;span class=&quot;pln&quot;&gt;DataContext=&quot;{Binding Source={StaticResource ViewModel}}&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Build the solution. If you encounter any compilation errors resolve them before continuing.&lt;/li&gt;
&lt;li&gt;Right-click on the ComboBox control in the designer and select Properties from the menu.&lt;/li&gt;
&lt;li&gt;Locate the ItemsSource property and click on its Binding value to 
view the data binding window. Select Customers from the available Path 
values as shown next:

&lt;img alt=&quot;&quot; src=&quot;http://i2.silverlight.net/content/tutorials/firestarter/lab10/figure4.png&quot; /&gt;
&lt;/li&gt;
&lt;li&gt;Follow the same procedure shown in the previous step to bind the ComboBox control&#39;s SelectedItem property to CurrentCustomer.

&lt;div class=&quot;note&quot;&gt;
You&#39;ll need to click on the icon to the right of 
SelectedItem and then select Apply Data Binding to access the data 
binding window.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Bind the Text property of each TextBox control to the associated property in CurrentCustomer.

&lt;div class=&quot;note&quot;&gt;
To do this, first clear any existing bindings by 
selecting the data icon to the right of the Text property and select 
Reset Value. You&#39;ll need to bind the Text property of each TextBox to 
CurrentCustomer and then select the appropriate property from 
CurrentCustomer (FirstName, LastName, etc.) in the data binding window.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Bind the Command property of each Button control to the appropriate 
command property in the ViewModel (UpdateCustomerCommand or 
DeleteCustomerCommand) using the same technique shown in the previous 
steps.&lt;/li&gt;
&lt;li&gt;Drag a TextBlock control from the Toolbox and drop it directly to 
the right of the existing Delete button. Change the Width of the 
TextBlock to 200.&lt;/li&gt;
&lt;li&gt;Bind the newly added TextBlock control&#39;s Text property to the 
StatusMessage property of the ViewModel using the data binding window.&lt;/li&gt;
&lt;li&gt;Run the application and test the functionality. As you update or 
delete a Customer object a success message should appear to the right of
 the Button controls. Select a different customer and the success 
message should disappear.&lt;/li&gt;
&lt;/ol&gt;
&lt;a href=&quot;&quot; name=&quot;Summary&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Summary&lt;/h2&gt;
In this exercise you converted the SilverlightCustomerViewer 
application to use the Model-View-ViewModel pattern.  Tasks completed 
include creating a service agent class for communication with a WCF 
service as well as a ViewModel class that is responsible for retrieving 
data and storing it in properties. You also added support for commanding
 and bound a ViewModel class to a XAML view.  Requirements satisfied in 
this lab include:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;Remove code located in a Silverlight code-beside file&lt;/li&gt;
&lt;li&gt;Create a service agent interface and class to handle calls to a WCF service&lt;/li&gt;
&lt;li&gt;Create a ViewModelBase class to handle INotifyPropertyChanged notifications&lt;/li&gt;
&lt;li&gt;Create a ViewModel class that derives from ViewModelBase and handles data interactions&lt;/li&gt;
&lt;li&gt;Add support for commanding into a ViewModel class&lt;/li&gt;
&lt;li&gt;Bind a ViewModel class to a View in XAML&lt;/li&gt;
&lt;li&gt;Bind Silverlight controls to ViewModel properties&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/4560937844058054109/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/using-mvvm-pattern-in-silverlight.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/4560937844058054109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/4560937844058054109'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/using-mvvm-pattern-in-silverlight.html' title='Using the MVVM Pattern in Silverlight Applications'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-7810556756839694233</id><published>2011-09-11T22:54:00.000-07:00</published><updated>2011-09-11T22:55:06.600-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Expression Blend"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Phone"/><title type='text'>Creating WP7 prototypes with Sketchflow</title><content type='html'>With the upcoming release of Windows Phone Mango, you can create prototypes for Phone apps with Sketchflow. For people not knowing Sketchflow : it allows you to create prototypes that look like they have been drawn. When you present a “normal” prototype to a customer you get conversations like this :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Nice protoype, how long before you can deliver us the final product ?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #9b00d3;&quot;&gt;I estimate we can deliver within 4 months.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;What ? You created this prototype in just 3 days, it looks like it’s almost finished. How can it possibly take 4 months for completing ?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;A sketchflow prototype looks more “unfinished”. It’s not new, it has been around for WPF and silverlight, but you can now also get the projecttemplate for WP7 for using in Blend. Just go to &lt;a href=&quot;http://wp7sketchflow.codeplex.com/&quot; title=&quot;http://wp7sketchflow.codeplex.com/&quot;&gt;http://wp7sketchflow.codeplex.com/&lt;/a&gt;, download and install. Beware : you can only use this thing if you have the full paid version of Blend. The one you get for free with the phone developers tool will not do. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;OK. Let’s open up Blend and create a Windows Phone SketchFlow application :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_6.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;385&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_6.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;421&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This project directly creates some an empty screen for my app  and a fake start-up screen:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_7.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;383&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_7.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;241&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I also get an overview how I can move (“Flow”) between the different screens:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_8.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;141&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_8.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;336&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I created a little prototype for an application I sometimes create during WP7-courses : a complaints-application for my city (the well-know megacity Serskamp in Belgium). This application allows me to signal stuff like defective traffic lights a.o. I also need to be able to add a location (GPS) and a picture, and to track my filed complaints. I’m not going to create the app itself now, but just the screens.&lt;br /&gt;
&lt;br /&gt;
I start by adding a Panorama on my start screen. This thing automatically gets 2 Panorama-items. The design of my item looks like this :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot; style=&quot;width: 400px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign=&quot;top&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_9.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;451&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_9.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;261&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_10.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;455&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_10.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;258&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
For the data I created a demo-datasource in the data-tab:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_11.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;375&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_11.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;261&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
got some trouble for designing the second Panorama-item. Unlike Visual Studio, in which you simply have to select a Panorama-item for making it the active one, there’s no such thing in Blend. Or at least I didn’t find it. The only thing I could do was temporary setting the visibility of the other items to collapsed.&lt;br /&gt;
&lt;br /&gt;
Inside the Flow-panel I can select to add a new Connected screen. This way I create a screen for the follow-up of my complaints, and one for setting the location. I also create connections for returning to Screen 1, and remove the connection from my new screens to Search and AppList.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_12.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;178&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_12.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;440&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The Follow-up screen looks like this :&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_13.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;397&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_13.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;230&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
For finishing I also change the start-screen, and I’m done.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_14.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;346&quot; src=&quot;http://blogs.u2u.be/michael/image.axd?picture=image_thumb_14.png&quot; style=&quot;border: 0px; display: inline; margin: 0px 0px 0px 5px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;198&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Now I’ve finished my SketchFlow-prototype, there’s 2 thing I can do : print it, or run it. In the File-menu you have an option for exporting to Word. This will export all your designs and add a table of contents :&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://blogs.u2u.be/michael/file.axd?file=2011%2f8%2fWindowsPhonePrototype2.doc&quot;&gt;WindowsPhonePrototype2.doc (1,28 mb)&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Creating a SketchFlow-prototype is essentially creating a Silverlight-application. This gives you a way of “running” the app, so you can demonstrate it to your customer (see video) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder=&quot;0&quot; height=&quot;349&quot; src=&quot;http://www.youtube.com/embed/Un4YMn6kDU8?hl=nl&amp;amp;fs=1&quot; width=&quot;425&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
Is that cool, or what ?</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/7810556756839694233/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/creating-wp7-prototypes-with-sketchflow.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/7810556756839694233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/7810556756839694233'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/creating-wp7-prototypes-with-sketchflow.html' title='Creating WP7 prototypes with Sketchflow'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/Un4YMn6kDU8/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-3907351419644656240</id><published>2011-09-02T03:39:00.000-07:00</published><updated>2011-09-02T03:39:17.397-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Custom Control"/><category scheme="http://www.blogger.com/atom/ns#" term="Lookless"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Creating a Silverlight Custom Control</title><content type='html'>&lt;div&gt;
&lt;i&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: calibri,sans-serif; font-size: 11pt; line-height: 17px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;h3&gt;

Introduction&lt;/h3&gt;
This articles focuses on the process of creating a Custom Control in 
Silverlight 2. It describes the basics of what you need to build a 
styleable control with custom logic that can be used in Silverlight 
applications. The article shows a sample(part) of implementing a 
LinkLabel control that recognizes URIs in a given text and displays them
 as links instead of as plain text.&lt;br /&gt;
&lt;h3&gt;

Overview&lt;/h3&gt;
&lt;br /&gt;
&lt;br /&gt;
The control model in Silverlight 2 offers creating UserControls and 
Custom Controls. UserControls enable encapsulation of a specific logic. 
They are used in scenarios where you want to reuse XAML and/or logic in 
multiple places or build a sophisticated page with smaller chunks(the 
UserControls). However, in other scenarios you may need a custom logic 
to be built in the control and this control to allow designers customize
 easily its look. You need a way to modify the control visuals without 
having to modify the control logic. This is where the Custom Controls 
comes in handy. In Silverlight they derive from the Control class and 
specify a default style for the way they will look like.&lt;br /&gt;
To get started create a Silverlight Class Library project in Visual 
Studio. This will generate just a single .cs file. Lets take a sample 
implementation of a LinkLabel control.&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;pre style=&quot;background-color: white; border-style: none; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; LinkLabel : Control&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;{&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;...&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
Ok, the first step is to define a default look for this control. A 
file called generic.xaml contains the UI of your custom controls. It 
should be placed in a &quot;themes&quot; directory inside your project. Add a new 
item of type XML File in your project in the &quot;themes&quot; directory and&amp;nbsp;name
 it generic.xaml. By default when you add a new file the Build Action is
 set to Silverlight page. But the platform look for the generic.xaml as a
 Resource file. Therefore you need to change the default behavior:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Open the Properties window of the file. &lt;/li&gt;
&lt;li&gt;Change the Build Action to Resource. &lt;/li&gt;
&lt;li&gt;Clear the Custom Tool value. &lt;/li&gt;
&lt;/ol&gt;
&lt;img alt=&quot;generic.xaml.build.action&quot; height=&quot;229&quot; src=&quot;http://www.silverlightshow.net/storage/userfiles/generic.xaml.build.action.png&quot; style=&quot;border: 0px solid;&quot; width=&quot;256&quot; /&gt;&lt;br /&gt;
In the generic.xaml add a ResourceDictionary element where you will put all the resources.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&amp;lt;ResourceDictionary xmlns=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;xmlns:x=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;...&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&amp;lt;/ResourceDictionary&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
The next step is to add the default style for the control. Start by including the XML namespace of the assembly.&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&amp;lt;ResourceDictionary xmlns=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;xmlns:x=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;xmlns:local=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;clr-namespace:CompletIT.Windows.Controls;assembly=LinkLabel&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    &amp;lt;!-- Default style &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; CompletIT.Windows.Controls.LinkLabel --&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    &amp;lt;Style TargetType=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;local:LinkLabel&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;        &amp;lt;Setter Property=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;Template&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;            &amp;lt;Setter.Value&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;                &amp;lt;ControlTemplate TargetType=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;local:LinkLabel&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;                     &amp;lt;StackPanel x:Name=&lt;span style=&quot;color: #006080;&quot;&gt;&quot;LayoutRoot&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;                         &amp;lt;ContentPresenter   /&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;                     &amp;lt;/StackPanel&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;                 &amp;lt;/ControlTemplate&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;             &amp;lt;/Setter.Value&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;         &amp;lt;/Setter&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;     &amp;lt;/Style&amp;gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&amp;lt;/ResourceDictionary&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
In this code snippet you see a Style element just like the one you 
might have already used in your Silverlight applications. You may also 
notice that there is no x:Key attribute - you don&#39;t need it because when
 the platform looks for the default style of the control it just 
examines the TargetType. To specify the control&#39;s look set the Template 
property and add a ControlTemplate. This is where you can define the 
full appearance of the control.&lt;br /&gt;
With the release of the VisualStateManager in Beta 2 it is important 
to point that this style is also the place where you can define the &lt;i&gt;state parts&lt;/i&gt;
 of your control. This is not the main focus of this article so I won&#39;t 
get deep in it. For more information on this topic you can read &lt;a href=&quot;http://scorbs.com/2008/06/11/parts-states-model-with-visualstatemanager-part-1-of/&quot; target=&quot;_blank&quot;&gt;Parts &amp;amp; States Model with VisualStateManager&lt;/a&gt; and watch &lt;a href=&quot;http://scorbs.com/2008/03/09/mix08-creating-rich-dynamic-user-interfaces-with-silverlight-2-controls/&quot; target=&quot;_blank&quot;&gt;Creating Rich, Dynamic User Interfaces with Silverlight 2&lt;/a&gt; by Karen Corby.&lt;br /&gt;
Ok, enough of XAML. Lets see what&#39;s needed in the code.&lt;br /&gt;
Start with creating a constructor and set the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.defaultstylekey.aspx&quot; target=&quot;_blank&quot;&gt;FrameworkElement.DefaultStyleKey&lt;/a&gt; - type that should be used to look up the built-in style - to the Type of the control.&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; LinkLabel()&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    : &lt;span style=&quot;color: blue;&quot;&gt;base&lt;/span&gt;()&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;{&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    DefaultStyleKey = &lt;span style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;( LinkLabel );&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
Then, define all the custom properties of the control. Most of the 
properties in the framework are of DependencyProperty type. If you want a
 particular property of your control to be template-bindable, 
data-bindable or styleable,&amp;nbsp; you need to define it as a 
DependencyProperty. For the LinkLabel control lets just add a Text 
property.&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;readonly&lt;/span&gt; DependencyProperty TextProperty = DependencyProperty.Register(&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;            &lt;span style=&quot;color: #006080;&quot;&gt;&quot;Text&quot;&lt;/span&gt;,&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;            &lt;span style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;( &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; ),&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;            &lt;span style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;( LinkLabel ),&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;            &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; PropertyMetadata( &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; PropertyChangedCallback( OnTextChanged ) ) );&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; Text&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;{&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    get&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;     {&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;         &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; ( &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; )&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.GetValue( TextProperty );&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;     }&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;     set&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;     {&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;         &lt;span style=&quot;color: blue;&quot;&gt;base&lt;/span&gt;.SetValue( TextProperty, &lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt; );&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;     }&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
As you can see on line 5 a new PropertyChangedCallback is added that 
will be called when the text is changed. This is not needed for all 
controls. We will walk through the implementation of the OnTextChanged 
method in a second. Do the same for all properties your control needs.&lt;br /&gt;
One last step before proceeding to the control logic code. The 
StackPanel we use for a &quot;built-in&quot; style in the generic.xaml is still 
not accessible from the code file. To assign it to a member variable 
create a private field of type StackPanel and override the 
OnApplyTemplate method like this:&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; OnApplyTemplate()&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;{&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.layoutRoot = &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.GetTemplateChild( &lt;span style=&quot;color: #006080;&quot;&gt;&quot;LayoutRoot&quot;&lt;/span&gt; ) &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; StackPanel;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    Debug.Assert( &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.layoutRoot != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #006080;&quot;&gt;&quot;LayoutRoot is null&quot;&lt;/span&gt; );&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    &lt;span style=&quot;color: blue;&quot;&gt;base&lt;/span&gt;.OnApplyTemplate();&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
As you see in the above code we call this.GetTemplateChild(childName) to retrieve the element from the visual tree.&lt;br /&gt;
That&#39;s it. From there on you should write the custom logic needed by 
your control to act as you want. For our LinkLabel sample we need to 
process the entered text by replacing all URIs with links. To achieve 
this we need to define a new method (ProcessText()) that should be 
called (1) from the OnApplyTemplate event and (2) from the OnTextChanged
 event. I&#39;ll skip the implementation of the ProcessText method here as 
I&#39;ll blog about the full implementation of the LinkLabel control later 
this week and will provide the source code and a sample usage.&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; OnTextChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;{&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    LinkLabel linkLabel = d &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; LinkLabel;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    Debug.Assert( linkLabel != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;color: #006080;&quot;&gt;&quot;LaytouRoot is null&quot;&lt;/span&gt; );&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4f4f4; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;    linkLabel.ProcessText();&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; border-style: none; color: black; font-family: consolas, &#39;courier new&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow-x: visible; overflow-y: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 100%;&quot;&gt;&lt;span style=&quot;color: #606060;&quot;&gt; &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;

Conclusion&lt;/h3&gt;
Building a Custom Control in Silverlight can be tricky sometimes, but
 that really depends on the complexity the control requires. Silverlight
 really gives the freedom to create whatever your imagination can born 
and push it to the highest level. You are able to build beautiful 
controls that can be easily customized by designers on their own. You 
are sure that the designer won&#39;t brake your logic while making the 
fascinate look of the control. With the new VisualStateManager and the 
&quot;Parts and States Model&quot; you can easily define complex UI while keeping 
the designer&#39;s ability to style it. This is another quite a big and 
interesting topic that I&#39;ll try to cover in future posts.&lt;br /&gt;
Stay tuned to see the LinkLabel control. I&#39;ll provide a link in this article too.&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;Update&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;Check out the LinkLabel control &lt;a href=&quot;http://www.silverlightshow.net/items/Silverlight-LinkLabel-control.aspx&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;h3&gt;

References&lt;/h3&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc189093%28VS.95%29.aspx&quot; target=&quot;_blank&quot;&gt;Styling and Templating Overview&lt;/a&gt; on MSDN &lt;br /&gt;
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc278064%28VS.95%29.aspx&quot; target=&quot;_blank&quot;&gt;Creating a Templatable Control&lt;/a&gt; on MSDN &lt;br /&gt;
&lt;a href=&quot;http://scorbs.com/2008/03/09/mix08-creating-rich-dynamic-user-interfaces-with-silverlight-2-controls/&quot; target=&quot;_blank&quot;&gt;Creating Rich, Dynamic User Interfaces with Silverlight 2&lt;/a&gt; by Karen Corby &lt;br /&gt;
&lt;a href=&quot;http://scorbs.com/2008/06/11/parts-states-model-with-visualstatemanager-part-1-of/&quot; target=&quot;_blank&quot;&gt;Parts &amp;amp; States Model with VisualStateManager&lt;/a&gt; by Karen Corby</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/3907351419644656240/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/creating-silverlight-custom-control.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/3907351419644656240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/3907351419644656240'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/09/creating-silverlight-custom-control.html' title='Creating a Silverlight Custom Control'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-5752983877696511019</id><published>2011-08-28T12:35:00.000-07:00</published><updated>2011-08-28T12:35:07.803-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Lookless"/><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Creating Lookless Controls for WPF and Silverlight</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;This screencast is a continuation of a previous screencast entitled “&lt;a href=&quot;http://channel9.msdn.com/posts/jbienz/Skins-for-WPF-and-Silverlight/&quot; shape=&quot;rect&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #d2730d; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;Skins for WPF and Silverlight&lt;/a&gt;”. In this session we go beyond skinning built-in controls and learn what’s required to create our own skinnable (or ‘lookless’) controls.&lt;br /&gt;
&lt;br /&gt;
This screencast assumes existing knowledge about styles and templates, so if you aren’t up to speed on those topics please consider watching the&amp;nbsp;&lt;a href=&quot;http://channel9.msdn.com/posts/jbienz/Skins-for-WPF-and-Silverlight/&quot; shape=&quot;rect&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #d2730d; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;skinning&lt;/a&gt;&amp;nbsp;screencast first.&lt;br /&gt;
&lt;br /&gt;
The sample demonstrated in this screencast can be downloaded&amp;nbsp;&lt;a href=&quot;http://channel9.msdn.com/playground/Sandbox/475017-Files-for-Creating-Lookless-Controls-Screencast/&quot; shape=&quot;rect&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #d2730d; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;iframe frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://channel9.msdn.com/Blogs/jbienz/Creating-Lookless-Controls-for-WPF-and-Silverlight/player?w=512&amp;amp;h=288&quot; style=&quot;height: 288px; width: 512px;&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/5752983877696511019/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/08/creating-lookless-controls-for-wpf-and.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/5752983877696511019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/5752983877696511019'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/08/creating-lookless-controls-for-wpf-and.html' title='Creating Lookless Controls for WPF and Silverlight'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-1898769131095034209</id><published>2011-06-15T01:39:00.000-07:00</published><updated>2011-06-15T01:39:04.033-07:00</updated><title type='text'>Project Silk Drop 11</title><content type='html'>&lt;a href=&quot;http://karlshifflett.wordpress.com/2011/06/14/project-silk-drop-11/&quot;&gt;Project Silk Drop 11&lt;/a&gt;: &quot;&lt;p&gt;The patterns &amp;amp; practices Web Guidance team released &lt;a href=&quot;http://silk.codeplex.com/releases/view/68326&quot;&gt;Drop 11 of Project Silk (6-14-2011)&lt;/a&gt;. This drop includes work recommended by the advisory board and 3rd party code review of the JavaScript.&lt;/p&gt;&lt;br /&gt;&lt;h4&gt;Code Updates&lt;/h4&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Significantly reduced the coupling to the mstats global object. Widgets are no longer stored as members on mstats. Instead, widgets are either created in the bootstrapping mileagestats.js or in another managing widget.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Added a utility function for mixing in helper methods that simplify the syntax for invoking public method on widgets (when used inside of another widget).&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Significantly reduced the number of hard-coded URLs. URLs are generally pulled from data- attributes.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Corrected an issue with the way that the chart vehicle selection UI was constructed. Changes in jQuery 1.6.1 caused this to surface.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now correctly redirects to the Login page when a session timeouts and JSON request is made while using the Single Page Interface. &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h4&gt;Chapters&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;We are providing the guidance chapters in Word document, .pdf, and .chm format. Providing the chapters in Word format makes it easier for the community to provide feedback by using the Word Track Changes feature. If you provide feedback on a chapter, you can upload your feedback to: &lt;a href=&quot;http://silk.codeplex.com/workitem/list/basic&quot;&gt;Project Silk Issue Tracker&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The following chapters are ready for review:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Client Data Management and Caching (new)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Architecture (updated)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;jQuery UI Widgets (updated)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Application Notifications (updated)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Server-Side Implementation &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Security &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Unit Testing Web Applications &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Widget QuickStart (updated)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;How to: Check UIElement Properties with Coded UI Test &lt;/li&gt;&lt;br /&gt;&lt;li&gt;How to: Create Automation Negative case with Coded UI Test &lt;/li&gt;&lt;br /&gt;&lt;li&gt;How to: Create Web Client UI Test using Coded UI Test &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;The following chapters are currently being written or will be started soon:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Introduction (in progress)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Modularity (in progress)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Navigation&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Communication&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h4&gt;Video&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;We have also made a new video for Project Silk that includes a short tour through the countryside with stops for gas and parts. During parts of the video, the Mileage Stats UI displays as a HUD (heads up display). After this short but entertaining introduction a new tutorial video beings.  This video is currently in production and will be released on Channel9 soon.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://karlshifflett.files.wordpress.com/2011/06/hud.png&quot;&gt;&lt;img style=&quot;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0 5px&quot; title=&quot;HUD&quot; border=&quot;0&quot; alt=&quot;HUD&quot; src=&quot;http://karlshifflett.files.wordpress.com/2011/06/hud_thumb.png?w=684&amp;amp;h=386&quot; width=&quot;684&quot; height=&quot;386&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;h4&gt;Close&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;We welcome and appreciate your feedback on the application and book content.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Have a great day,&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color:rgb(192,148,63)&quot;&gt;Just a grain of sand on the worlds beaches.&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/1898769131095034209/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/06/project-silk-drop-11.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/1898769131095034209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/1898769131095034209'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/06/project-silk-drop-11.html' title='Project Silk Drop 11'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7376718508560925815.post-1597204945276962598</id><published>2011-06-14T00:31:00.000-07:00</published><updated>2011-06-14T00:31:47.830-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Demos"/><title type='text'>10 Silverlight 5 Demos</title><content type='html'>Last week in Germany at DevConnections, I presented a session on 10 cool features in Silverlight 5. This presentation was a combination of demos that both I and Pete Brown had put together over the past few weeks. You can &lt;a href=&quot;http://johnpapa.net/files/downloads/DevConGermany2011.SL5Slides.zip&quot;&gt;download the slide deck&lt;/a&gt; and the &lt;a href=&quot;http://johnpapa.net/files/downloads/DevConGermany2011.SL5Demos.zip&quot;&gt;sample code right here&lt;/a&gt;. &lt;br /&gt;
The 10 topics I chose to demonstrate are:&lt;br /&gt;
&lt;a href=&quot;http://johnpapa.net/Media/Default/Windows-Live-Writer/10-Silverlight-5-Demos_142FD/image_4.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;259&quot; src=&quot;http://johnpapa.net/Media/Default/Windows-Live-Writer/10-Silverlight-5-Demos_142FD/image_thumb_1.png&quot; style=&quot;border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;504&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
I also presented a talk on MVVM, which uses the same BookShelf app demo I used at the Silverlight Firestarter. You can &lt;a href=&quot;http://cid-db8de07d70b6e4b7.office.live.com/browse.aspx/.Public?sa=297082339&quot;&gt;download the deck and demo for that from this link&lt;/a&gt;.&lt;br /&gt;
Note: I’m working on cleaning up my demos from my joint talk with Dan Wahlin on &lt;a href=&quot;http://jquery.com/&quot;&gt;jQuery&lt;/a&gt; and &lt;a href=&quot;http://knockoutjs.com/&quot;&gt;KnockoutJS&lt;/a&gt;, which covered MVVM concepts. &lt;br /&gt;
&lt;div&gt;n&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://silverlightmicrosoft.blogspot.com/feeds/1597204945276962598/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/06/10-silverlight-5-demos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/1597204945276962598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7376718508560925815/posts/default/1597204945276962598'/><link rel='alternate' type='text/html' href='http://silverlightmicrosoft.blogspot.com/2011/06/10-silverlight-5-demos.html' title='10 Silverlight 5 Demos'/><author><name>Jesús Estévez @jecaestevez</name><uri>http://www.blogger.com/profile/11408634435235193152</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>