<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0"><channel><title>Dan Wahlin&amp;#39;s WebLog</title><link>http://weblogs.asp.net/dwahlin/default.aspx</link><description>ASP.NET, AJAX, Silverlight and Web Services Exploration</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/dwahlin" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>DevConnections Conference Code and Slides</title><link>http://weblogs.asp.net/dwahlin/archive/2009/11/10/devconnections-conference-code-and-slides.aspx</link><pubDate>Tue, 10 Nov 2009 08:48:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7250383</guid><dc:creator>dwahlin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7250383</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/11/10/devconnections-conference-code-and-slides.aspx#comments</comments><description>&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_69858111.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_69858111.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 0px 0px 0px 5px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image align=right src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_2C814F7F.png" width=190 height=176 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_2C814F7F.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I’m in Las Vegas this week for the DevConnections conference and wanted to get the slides and code posted for the talks as I give them.&amp;nbsp; This time around I’m talking about Silverlight (including a full-day workshop), the new Microsoft Ajax Library script loader and template features and RIA Services.&amp;nbsp; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/SL3Workshop.zip" mce_href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/SL3Workshop.zip"&gt;Silverlight 3 Workshop&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/Getting%20Started%20with%20Silverlight%203.zip" mce_href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/Getting Started with Silverlight 3.zip"&gt;Getting Started with Silverlight 3&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/RIAServices.zip" mce_href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/RIAServices.zip"&gt;Using RIA Services&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/AjaxTemplates.zip" mce_href="http://www.xmlforasp.net/CodeBank/Download/Blog/Connections/LasVegas2009/AjaxTemplates.zip"&gt;Using the Microsoft Ajax Library Script Loader and Template Features&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7250383" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+AJAX/default.aspx">ASP.NET AJAX</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WCF/default.aspx">WCF</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Architecture/default.aspx">Architecture</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/RIA+Services/default.aspx">RIA Services</category></item><item><title>Passing Multiple Records to a Stored Procedure in SQL Server</title><link>http://weblogs.asp.net/dwahlin/archive/2009/09/30/passing-multiple-records-to-a-stored-procedure-in-sql-server.aspx</link><pubDate>Wed, 30 Sep 2009 18:51:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7220575</guid><dc:creator>dwahlin</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7220575</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/09/30/passing-multiple-records-to-a-stored-procedure-in-sql-server.aspx#comments</comments><description>&lt;p&gt;There are so many different ways to work with data that it can make your head spin.&amp;#160; Regardless of the technology, one thing I always try to do when working with databases is minimize the number of calls that are made.&amp;#160; I use ORM frameworks a lot so I have to make sure that my code doesn’t end up calling the database a ton and being overly “chatty”.&amp;#160; &lt;/p&gt;  &lt;p&gt;My company is currently working on a large Silverlight 3 application for a customer and have a requirement to allow CSV file uploads through the application.&amp;#160; That’s pretty straightforward to do with Silverlight but in looking through the CSV file there can be 1000s of records and there is a lot of custom functionality around each record.&amp;#160; Initially I was going to handle the business rules and insertion for each row individually.&amp;#160; However, once I saw how many rows were involved I backed off my initial approach since that would mean a single file upload could trigger thousands and thousands of calls to the database which certainly isn’t efficient.&amp;#160; Instead of going that route I decided it would be better to pass all of the rows into a stored procedure and let it handle everything.&amp;#160; That way I can make a single database connection yet handle inserting (and updating and deleting based upon the business rules) many records.&amp;#160; &lt;/p&gt;  &lt;p&gt;So how can you pass multiple records into a stored procedure?&amp;#160; Back in “the day” I’d pass in delimited strings and then parse them.&amp;#160; Although that technique probably wasn’t the most efficient, it got the job done.&amp;#160; With SQL Server 2005 and higher we have access to a much more efficient technique due to the availability of XQuery.&amp;#160; The current project I’m working on relies on SQL Server 2005 behind the scenes so that’s what I’ll focus on here.&amp;#160; Note that SQL Server 2008 allows .NET DataTable objects to be passed when using table value parameters as well in a stored procedure.&amp;#160; See &lt;a title="http://www.codeproject.com/KB/database/sqlserver2008.aspx" href="http://www.codeproject.com/KB/database/sqlserver2008.aspx"&gt;http://www.codeproject.com/KB/database/sqlserver2008.aspx&lt;/a&gt; for an overview of the table value parameter functionality.&lt;/p&gt;  &lt;p&gt;For the import I can serialize the list of records to XML and then pass them into a stored procedure.&amp;#160; It appears that you can pass an XmlDocument object from .NET if the stored procedure takes an XML input parameter type.&amp;#160; However, I never got it to work properly doing that so I pass a string containing serialized XML data and then load it into the XML data type.&amp;#160; The stored procedure can then use XQuery to convert the XML into actual rows.&amp;#160; Here’s some code that handles parsing a flat file, converting the data into a List&amp;lt;JobMaterialImport&amp;gt;, serializing the list into XML and then passing the serialized XML data to a stored procedure named ImportJobMaterials.   &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ImportJobMaterialsResult&lt;/span&gt;&amp;gt; ImportJobMaterials(&lt;span style="color: blue"&gt;int &lt;/span&gt;jobID, &lt;span style="color: #2b91af"&gt;Stream &lt;/span&gt;stream, &lt;span style="color: blue"&gt;string &lt;/span&gt;coNumber, &lt;span style="color: blue"&gt;string &lt;/span&gt;coDesc, &lt;span style="color: blue"&gt;string &lt;/span&gt;xmlMapFile)
{
    &lt;span style="color: green"&gt;//Convert flat file to List&amp;lt;JobMaterialImport&amp;gt; using converter and XML mapping file
    //Mapping file passed from FlatFileHandler.ashx in web project
    &lt;/span&gt;&lt;span style="color: #2b91af"&gt;FlatFileToObjectConverter&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;JobMaterialImport&lt;/span&gt;&amp;gt; converter = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;FlatFileToObjectConverter&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;JobMaterialImport&lt;/span&gt;&amp;gt;(stream, xmlMapFile);
    &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;JobMaterialImport&lt;/span&gt;&amp;gt; imports = converter.ConvertToList();
    imports = imports.Take(imports.Count - 2).ToList(); &lt;span style="color: green"&gt;//last rows are bogus in flat-file

    //Generate XML and pass to sproc
    &lt;/span&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;StringWriter &lt;/span&gt;sw = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StringWriter&lt;/span&gt;())
    {
        &lt;span style="color: #2b91af"&gt;XmlSerializer &lt;/span&gt;xs = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlSerializer&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;JobMaterialImport&lt;/span&gt;&amp;gt;));
        xs.Serialize(sw, imports);
        &lt;span style="color: blue"&gt;try
        &lt;/span&gt;{
            &lt;span style="color: green"&gt;//Pass materials into sproc
            &lt;/span&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;xml = sw.ToString().Replace(&lt;span style="color: #a31515"&gt;&amp;quot;utf-16&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;);
            &lt;span style="color: blue"&gt;return this&lt;/span&gt;.DataContext.ImportJobMaterials(xml, jobID, coNumber, coDesc).ToList();            
        }
        &lt;span style="color: blue"&gt;catch &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Exception &lt;/span&gt;exp)
        {
            &lt;span style="color: #2b91af"&gt;Logger&lt;/span&gt;.Log(&lt;span style="color: #a31515"&gt;&amp;quot;Error in JobManagementRepository.ImportJobMaterials&amp;quot;&lt;/span&gt;, exp);
        }
    }
    &lt;span style="color: blue"&gt;return null&lt;/span&gt;;
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The XML that’s generated from the code above looks like the following.&amp;#160; Security Note: We’ll assume that appropriate measures have been taken to clean the data and ensure it doesn’t contain any bad stuff related to injection attacks. That’s especially important if you’ll be running any dynamic SQL in your stored procedure.&amp;#160; I’m not, but I thought I’d be a good citizen and point it out…always sanitize your data with some Clorox before using it. :-)
  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ArrayOfJobMaterialImport &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:xsi&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;xmlns:xsd&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;JobMaterialImport&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Area&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;BUILDING A&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Area&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phase&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;LIGHTING&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phase&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCode&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;0&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCode&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCodeTitle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;Manually Assigned&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCodeTitle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;4x1 1/2in. SQ BOX COMB KO&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Quantity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;2&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Quantity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TotalHours&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;10.46&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TotalHours&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;/&lt;span style="color: #a31515"&gt;Job&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaterialImport&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;span style="color: #a31515"&gt;Job&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaterialImport&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Area&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;BUILDING A&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Area&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phase&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;LIGHTING&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phase&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCode&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;0&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCode&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCodeTitle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;Manually Assigned&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCodeTitle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;#8x   3/4 P/H SELF-TAP SCREW&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Quantity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;4&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Quantity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TotalHours&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;0.28&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TotalHours&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;/&lt;span style="color: #a31515"&gt;Job&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaterialImport&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;span style="color: #a31515"&gt;Job&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaterialImport&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Area&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;BUILDING A&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Area&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phase&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;LIGHTING&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Phase&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCode&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;605&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCode&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCodeTitle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;Wiring and System Devices&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WorkCodeTitle&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;1G TGL SWITCH PLATE - PLASTIC IVY&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Quantity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;2&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Quantity&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TotalHours&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;0.89&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TotalHours&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;/&lt;span style="color: #a31515"&gt;Job&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaterialImport&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ArrayOfJobMaterialImport&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Here’s what the stored procedure looks like:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;CREATE PROCEDURE &lt;/span&gt;[ImportJobMaterials]
    @JobMaterialsXml &lt;span style="color: blue"&gt;AS VARCHAR&lt;/span&gt;(&lt;span style="color: blue"&gt;MAX&lt;/span&gt;),
    @JobID &lt;span style="color: blue"&gt;AS INT&lt;/span&gt;,
    @ChangeOrderNumber &lt;span style="color: blue"&gt;AS VARCHAR&lt;/span&gt;(10) = &lt;span style="color: blue"&gt;NULL&lt;/span&gt;,
    @ChangeOrderDescription &lt;span style="color: blue"&gt;AS VARCHAR&lt;/span&gt;(100) = &lt;span style="color: blue"&gt;NULL
AS
    BEGIN
        DECLARE &lt;/span&gt;@XML &lt;span style="color: blue"&gt;AS XML
&lt;/span&gt;        
&lt;span style="color: blue"&gt;        DECLARE &lt;/span&gt;@MaterialsTable &lt;span style="color: blue"&gt;TABLE
        &lt;/span&gt;(
            ID &lt;span style="color: blue"&gt;INT IDENTITY&lt;/span&gt;(1,1),
            Area &lt;span style="color: blue"&gt;VARCHAR&lt;/span&gt;(250),
            Phase &lt;span style="color: blue"&gt;VARCHAR&lt;/span&gt;(250),
            WorkCodeID &lt;span style="color: blue"&gt;INT&lt;/span&gt;,
            WorkCodeTitle &lt;span style="color: blue"&gt;VARCHAR&lt;/span&gt;(250),
            MaterialTitle &lt;span style="color: blue"&gt;VARCHAR&lt;/span&gt;(250),
            Quantity &lt;span style="color: blue"&gt;DECIMAL&lt;/span&gt;(18,2),
            TotalHours &lt;span style="color: blue"&gt;DECIMAL&lt;/span&gt;(18,2)
        )
        
        &lt;span style="color: blue"&gt;SELECT &lt;/span&gt;@XML = @JobMaterialsXml
        
        &lt;span style="color: blue"&gt;INSERT INTO &lt;/span&gt;@MaterialsTable (Area, Phase, WorkCodeID, WorkCodeTitle, MaterialTitle, Quantity, TotalHours)
        &lt;span style="color: blue"&gt;SELECT &lt;/span&gt;M.Item.query(&lt;span style="color: #a31515"&gt;'./Area'&lt;/span&gt;).value(&lt;span style="color: #a31515"&gt;'.'&lt;/span&gt;,&lt;span style="color: #a31515"&gt;'VARCHAR(250)'&lt;/span&gt;) Area,
               M.Item.query(&lt;span style="color: #a31515"&gt;'./Phase'&lt;/span&gt;).value(&lt;span style="color: #a31515"&gt;'.'&lt;/span&gt;,&lt;span style="color: #a31515"&gt;'VARCHAR(250)'&lt;/span&gt;) WorkCode,
               M.Item.query(&lt;span style="color: #a31515"&gt;'./WorkCodeID'&lt;/span&gt;).value(&lt;span style="color: #a31515"&gt;'.'&lt;/span&gt;,&lt;span style="color: #a31515"&gt;'INT'&lt;/span&gt;) WorkCodeID,
               M.Item.query(&lt;span style="color: #a31515"&gt;'./WorkCodeTitle'&lt;/span&gt;).value(&lt;span style="color: #a31515"&gt;'.'&lt;/span&gt;,&lt;span style="color: #a31515"&gt;'VARCHAR(250)'&lt;/span&gt;) WorkCodeTitle,
               M.Item.query(&lt;span style="color: #a31515"&gt;'./MaterialTitle'&lt;/span&gt;).value(&lt;span style="color: #a31515"&gt;'.'&lt;/span&gt;,&lt;span style="color: #a31515"&gt;'VARCHAR(250)'&lt;/span&gt;) MaterialTitle,    
               M.Item.query(&lt;span style="color: #a31515"&gt;'./Quantity'&lt;/span&gt;).value(&lt;span style="color: #a31515"&gt;'.'&lt;/span&gt;,&lt;span style="color: #a31515"&gt;'DECIMAL(18,2)'&lt;/span&gt;) Quantity,    
               M.Item.query(&lt;span style="color: #a31515"&gt;'./TotalHours'&lt;/span&gt;).value(&lt;span style="color: #a31515"&gt;'.'&lt;/span&gt;,&lt;span style="color: #a31515"&gt;'DECIMAL(18,2)'&lt;/span&gt;) TotalHours
        &lt;span style="color: blue"&gt;FROM &lt;/span&gt;@XML.nodes(&lt;span style="color: #a31515"&gt;'/ArrayOfJobMaterialImport/JobMaterialImport'&lt;/span&gt;) &lt;span style="color: blue"&gt;AS &lt;/span&gt;M(Item)
        
        &lt;span style="color: green"&gt;--Process the data        &lt;/span&gt;            
    &lt;span style="color: blue"&gt;END
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Once the XML data comes in it’s converted into an XML data type using SELECT @XML = @JobMaterialsXml syntax.&amp;#160; The key part of the T-SQL code is the SELECT statement that grabs each value from the XML data type and looks for specific child nodes.&amp;#160; If the child nodes were attributes instead then you would do something like M.Item.value(‘@attributeName’,’DBType’).&amp;#160; Each JobMaterialImport node in the XML is located by the @XML.nodes(‘/ArrayOfJobMaterialImport/JobMaterialImport’) AS M(Item) code.&amp;#160; What’s nice about this approach is that a single call can be made to the database yet 1000s of records can be processed.&amp;#160; Not optimal for every situation, but exactly what I needed and fairly straightforward to use.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7220575" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Cleaning Up the Disabled State of a Silverlight Control using Expression Blend</title><link>http://weblogs.asp.net/dwahlin/archive/2009/08/27/cleaning-up-the-disabled-state-of-a-silverlight-control-using-expression-blend.aspx</link><pubDate>Thu, 27 Aug 2009 21:58:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7183394</guid><dc:creator>dwahlin</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7183394</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/08/27/cleaning-up-the-disabled-state-of-a-silverlight-control-using-expression-blend.aspx#comments</comments><description>&lt;p&gt;Silverlight provides the ultimate in flexibility when it comes to styling controls.&amp;#160; If you don’t like how something looks you can tweak the template in a tool like Expression Blend quickly and easily and get something completely different.&amp;#160; This post is geared towards those of you who may just be getting into Silverlight.&amp;#160; My goal is to demonstrate how easy it is to change controls using a simple example that I just went through on a client application.&lt;/p&gt;  &lt;p&gt;Being able to change a control’s template comes in handy when you don’t like the built-in style used by the framework.&amp;#160; I’m working on a menu used in a client application and the disabled state of the HyperlinkButton control wasn’t looking too good.&amp;#160; I thought the control looked butt ugly and was unreadable in the disabled state.…just sayin’.&amp;#160; :-)&amp;#160; I wasn’t looking to do anything fancy, but did want to make it obvious that the control was disabled while still making it easy for the end user to read the text.&amp;#160; Here’s what the menu looked like when two HyperLinkButton controls were disabled using the built-in control template:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_5805E7BE.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_377EA80C.png" width="630" height="66" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;I don’t know about you, but “Edit Job” and “Job Plan” look pretty bad in my opinion.&amp;#160; They’re definitely disabled (or possibly just plain dead), but they could both look better.&amp;#160; As mentioned earlier, Silverlight allows any control to be changed by simply modifying the control’s template.&amp;#160; The easiest way to do this is to use Expression Blend although you can do it in Visual Studio 2008 by hand as well.&amp;#160; When the control to tweak is placed on the Blend design surface you can right-click on it and select &lt;strong&gt;Edit Template –&amp;gt; Edit a Copy&lt;/strong&gt;:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_48EF08E4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_3A445CFF.png" width="341" height="437" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;From there you can give the new style a name, specify where it should be stored and then click OK:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_165B85A5.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_55B93935.png" width="415" height="233" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Once the style is created you’ll be able to see it in Blend and locate an element named DisabledOverlay.&amp;#160; In my case this was the culprit of the ugliness.&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_54E0D34B.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_2930094F.png" width="300" height="193" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;I ended up adjusting the Foreground color of the DisabledOverlay to black and set the Opacity to .4 using the properties window.&amp;#160; However, doing that isn’t quite enough.&amp;#160; The HyperlinkButton template places the DisabledOverlay TextBlock over the actual link content when the control is disabled.&amp;#160; That’s why you get the semi blurry effect because two pieces of text are showing.&amp;#160; I decided I wanted to hide the contentPresenter element when the control was disabled and just show the DisabledOverlay instead since it looked a lot cleaner.&amp;#160; Fortunately that’s quite easy to do.&amp;#160; Internally the control template uses the VisualStateManager to show and hide the DisabledOverlay.&amp;#160; I went into the disabled state and changed it to hide the contentPresenter.&amp;#160; That’s done by clicking on the &lt;strong&gt;States&lt;/strong&gt; tab followed by the &lt;strong&gt;Disabled&lt;/strong&gt; state:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_136620F2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_00B1273B.png" width="306" height="321" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Any changes you make to the contentPresenter are now tracked for that state so I clicked on contentPresenter and then set is Visibility property to Collapsed for the Disabled state:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_6D8FFA8E.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_58324526.png" width="308" height="138" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Doing that modifies the disabled state.&amp;#160; Here’s what the XAML looks like (I cleaned it up slightly).&amp;#160; You can see that it causes the contentPresenter’s Visibility to be set to Collapsed:    &lt;br /&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;VisualState &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Disabled&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Storyboard&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ObjectAnimationUsingKeyFrames &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;DisabledOverlay&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Visibility&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Duration&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&amp;quot;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame &lt;/span&gt;&lt;span style="color: red"&gt;KeyTime&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&amp;quot;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Visible&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ObjectAnimationUsingKeyFrames &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;contentPresenter&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetProperty&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Visibility&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Duration&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&amp;quot;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame &lt;/span&gt;&lt;span style="color: red"&gt;KeyTime&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;0&amp;quot;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Collapsed&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Visibility&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;DiscreteObjectKeyFrame&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ObjectAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Storyboard&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;VisualState&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;VisualStateGroup&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;From there I simply applied the style and newly created template to each HyperlinkButton control:
  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;HyperlinkButton &lt;/span&gt;&lt;span style="color: red"&gt;Style&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;StaticResource &lt;/span&gt;&lt;span style="color: red"&gt;MenuHyperlinkButtonStyle&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Content&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Job Plan&amp;quot;&lt;/span&gt;&lt;span style="color: blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;The end result is a menu that looks much better (in my opinion anyway) when the controls are disabled.&amp;#160; Here’s a before and after image:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_25623EB2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_7708B904.png" width="684" height="72" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;
    &lt;br /&gt;After:&lt;/strong&gt;

  &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_4B57EF08.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_4AEBBC13.png" width="686" height="66" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;This is a really simple example of modifying control templates but you can literally tweak any aspect of a control to get things looking just like you want them to look.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.thewahlingroup.com/"&gt;&lt;img title="Logo" border="0" alt="Logo" src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width="240" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information about &lt;strong&gt;onsite, online and video training, mentoring and consulting solutions&lt;/strong&gt; for .NET, SharePoint or Silverlight please visit &lt;a href="http://www.thewahlingroup.com/"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7183394" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Requiring SSL For ASP.NET MVC Controllers</title><link>http://weblogs.asp.net/dwahlin/archive/2009/08/25/requiring-ssl-for-asp-net-mvc-controllers.aspx</link><pubDate>Tue, 25 Aug 2009 17:53:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7181152</guid><dc:creator>dwahlin</dc:creator><slash:comments>13</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7181152</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/08/25/requiring-ssl-for-asp-net-mvc-controllers.aspx#comments</comments><description>&lt;p&gt;There are quite a few posts out there about switching to SSL when a user visits specific areas of a website but I figure the more the merrier so here’s yet another one.&lt;/p&gt;  &lt;p&gt;My company is in the process of rolling out an ASP.NET MVC site for a client and specific actions and controllers need to have SSL running to ensure that no sensitive information gets out such as passwords and credit cards.&amp;#160; If a user visits the site using http:// I need to switch them to https:// in certain parts of the website.&amp;#160; Fortunately, ASP.NET MVC is quite extensible so it only took about 4-5 minutes to get a simple solution in place.&amp;#160; &lt;/p&gt;  &lt;p&gt;The easiest way I know of to switch to SSL for specific controllers or actions is to create an ActionFilterAttribute that handles redirecting them to an https:// address.&amp;#160; Classes that derive from ActionFilterAttribute can be placed immediately above actions or even controllers in cases where the filter needs to apply to all actions in the controller.&amp;#160; For my situation I needed entire controllers to be SSL-enabled so I placed the attribute above the controller class name.&lt;/p&gt;  &lt;p&gt;Here’s an example of the simple RequiresSSL attribute class:    &lt;br /&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.Mvc;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;Helpers
{
    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;RequiresSSL &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ActionFilterAttribute
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;public override void &lt;/span&gt;OnActionExecuting(&lt;span style="color: #2b91af"&gt;ActionExecutingContext &lt;/span&gt;filterContext)
        {
            &lt;span style="color: #2b91af"&gt;HttpRequestBase &lt;/span&gt;req = filterContext.HttpContext.Request;
            &lt;span style="color: #2b91af"&gt;HttpResponseBase &lt;/span&gt;res = filterContext.HttpContext.Response;

            &lt;span style="background: #e2e2e2; color: #008200"&gt;//Check if we're secure or not and if we're on the local box
&lt;/span&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(!req.IsSecureConnection &amp;amp;&amp;amp; !req.IsLocal)
            {
                &lt;span style="color: blue"&gt;string &lt;/span&gt;url = req.Url.ToString().ToLower().Replace(&lt;span style="color: #a31515"&gt;&amp;quot;http:&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;https:&amp;quot;&lt;/span&gt;);
                res.Redirect(url);
            }
            &lt;span style="color: blue"&gt;base&lt;/span&gt;.OnActionExecuting(filterContext);
        }
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;A couple of people (thanks Jon and Phil) commented that the ToLower() call I had above could cause consequences with QueryString data.&amp;#160; I could take ToString() out but some people may type “HTTP” instead of “http” which would mess up the replace call.&amp;#160; For the current application I’m working on I only have integers being passed around on the QueryString so it didn’t affect me at all but it definitely could affect string data being passed.&amp;#160; The suggestion was to use the UriBuilder class and after thinking it through more I agree.&amp;#160; Here’s a different version of the RequiresSSL class that uses the UriBuilder class.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.Mvc;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;Helpers
{
    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;RequiresSSL &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ActionFilterAttribute
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;public override void &lt;/span&gt;OnActionExecuting(&lt;span style="color: #2b91af"&gt;ActionExecutingContext &lt;/span&gt;filterContext)
        {
            &lt;span style="color: #2b91af"&gt;HttpRequestBase &lt;/span&gt;req = filterContext.HttpContext.Request;
            &lt;span style="color: #2b91af"&gt;HttpResponseBase &lt;/span&gt;res = filterContext.HttpContext.Response;

            &lt;span style="background: #e2e2e2; color: #008200"&gt;//Check if we're secure or not and if we're on the local box
&lt;/span&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(!req.IsSecureConnection &amp;amp;&amp;amp; !req.IsLocal)
            {
                &lt;span style="color: blue"&gt;var &lt;/span&gt;builder = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;UriBuilder&lt;/span&gt;(req.Url)
                {
                    Scheme = &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;.UriSchemeHttps,
                    Port = 443
                };
                res.Redirect(builder.Uri.ToString());
            }
            &lt;span style="color: blue"&gt;base&lt;/span&gt;.OnActionExecuting(filterContext);
        }
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;The RequiresSSL attribute can then be placed above the appropriate action or controller: 

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;HandleError&lt;/span&gt;]
[&lt;span style="color: #2b91af"&gt;RequiresSSL&lt;/span&gt;]
&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AccountController &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;Controller
&lt;/span&gt;{
    ...
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;If you’re running IIS7 and want to get a test SSL certificate setup for testing purposes check out my good friend &lt;a href="http://blogs.msdn.com/bags/archive/2009/01/23/self-signed-certificates-on-iis-7-the-easy-way-and-the-most-effective-way.aspx" target="_blank"&gt;Rob Bagby’s excellent post&lt;/a&gt; on the subject. 

  &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7181152" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category></item><item><title>Creating a Silverlight DataContext Proxy to Simplify Data Binding in Nested Controls</title><link>http://weblogs.asp.net/dwahlin/archive/2009/08/20/creating-a-silverlight-datacontext-proxy-to-simplify-data-binding-in-nested-controls.aspx</link><pubDate>Fri, 21 Aug 2009 06:37:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7176078</guid><dc:creator>dwahlin</dc:creator><slash:comments>14</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7176078</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/08/20/creating-a-silverlight-datacontext-proxy-to-simplify-data-binding-in-nested-controls.aspx#comments</comments><description>&lt;p&gt;Data binding is one of my favorite features and something that I use a lot while building Silverlight applications.&amp;#160; Silverlight makes it really easy to bind data to different controls and move data from controls back into the original bound object without having to write any C# or VB code in many cases.&amp;#160; Here’s an example of binding a ComboBox control to an object that defines a property named Branches:    &lt;br /&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ComboBox 
    &lt;/span&gt;&lt;span style="color: red"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: blue"&gt;Branches}&amp;quot; 
&lt;/span&gt;&lt;span style="color: blue"&gt;    &lt;/span&gt;&lt;span style="color: red"&gt;DisplayMemberPath&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Title&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;This code binds the ItemsSource property to the DataContext object’s Branches property and displays the Branch object’s Title property in the ComboBox.&amp;#160; The DataContext could be assigned directly to the ComboBox through code or could be assigned to a parent object.&amp;#160; If it’s defined on a parent then all children have access to the object.&amp;#160; &lt;/p&gt;

&lt;p&gt;This works great as long as the ComboBox has access to the Branches property as shown in Figure 1 below (note that the Page shown in the figure is a Silverlight Page class or User Control not a web page).&amp;#160; However, figure 2 demonstrates a problem that can occur as the ComboBox control’s DataContext is changed to something other than the ViewModel object that defines the Branches property.&amp;#160; In this example a DataGrid binds to the Jobs property of the ViewModel and each row’s DataContext is a Job type.&amp;#160; The Job type doesn’t have a Branches property (the ViewModel object does obviously) so the ComboBox no longer has access to it for data binding.&amp;#160; Or does it? 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;table border="0" cellspacing="5" cellpadding="8" width="934"&gt;&lt;tbody&gt;
    &lt;tr bgcolor="#efefef"&gt;
      &lt;td valign="top" width="242" align="center"&gt;&lt;strong&gt;
          &lt;h3&gt;&lt;strong&gt;Figure 1 – All Systems go for binding&lt;/strong&gt;&lt;/h3&gt;
        &lt;/strong&gt;&lt;/td&gt;

      &lt;td valign="top" width="675" align="center"&gt;
        &lt;h3&gt;&lt;strong&gt;Figure 2 – Houston, we have a problem&lt;/strong&gt;&lt;/h3&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="242" align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_525928A2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_5E7AA2C9.png" width="223" height="463" /&gt;&lt;/a&gt; &lt;/td&gt;

      &lt;td valign="top" width="675" align="center"&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_4B59761D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_74810E5B.png" width="656" height="501" /&gt;&lt;/a&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Using a Static Resource When Binding Nested Controls&lt;/h2&gt;

&lt;p&gt;
  &lt;br /&gt;While the ComboBox can’t bind to the Branches property using the standard {Binding Branches} syntax when it’s nested in something like a DataGrid (or ListBox or another items control) it can still get to the ViewModel object’s Branches property with a few minor changes.&amp;#160; The first way that this little dilemma can be solved is to write code that assigns the ViewModel object’s Branches collection to each ComboBox in the LoadingRow event of the DataGrid.&amp;#160; This works but who wants to write code when you don’t have to?&amp;#160; The second way is to create a mini ViewModel class that each row binds to that references the Branches collection.&amp;#160; That’s also an option, but there’s a “codeless” way to do it as well that’s quite easy.&amp;#160; If the ViewModel object is defined in the Resources section of the Page or UserControl you can get to it using its &lt;strong&gt;key&lt;/strong&gt; name directly in XAML.&amp;#160; Here’s an example of defining a the ViewModel object declaratively in XAML: 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;
    &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;vm&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;clr-namespace:JobPlan.ViewModel;assembly=JobPlan.ViewModel&amp;quot;
    &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;JobPlan.View.UserControls.JobEdit&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &lt;strong&gt;&amp;lt;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="color: #a31515"&gt;vm&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;ViewModel &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;=&amp;quot;ViewModel&amp;quot; /&amp;gt;&lt;/strong&gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    
    &lt;/span&gt;&lt;span style="color: #a31515"&gt;...
    
&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;A ComboBox control within a DataGrid row (or nested in another type of control) can get to the ViewModel object’s Branches property using the following binding syntax:

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ComboBox 
    &lt;/span&gt;&lt;span style="color: red"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding Source={StaticResource ViewModel},Path=&lt;/span&gt;&lt;span style="color: blue"&gt;Branches}&amp;quot; 
&lt;/span&gt;&lt;span style="color: blue"&gt;    &lt;/span&gt;&lt;span style="color: red"&gt;DisplayMemberPath&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Title&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;This XAML code tells the ComboBox control to access a statically defined resource with a key of “ViewModel” and then find a property of that resource object named Branches.&amp;#160; Pretty cool because you don’t have to write any C# or VB code at all by using this solution which is great if you’re dealing with a lot of nested ComboBox controls.&amp;#160; For developers that don’t like defining their ViewModel objects in XAML you can always use an intermediary ViewModel lookup object when things need to be as loosely coupled as possible.&lt;/p&gt;

&lt;p&gt;Now that you see how nested objects can get to properties defined at higher levels I can cover the main point of this post.&amp;#160; Everything mentioned to this point works great out of the box especially if you want to avoid writing code as much as possible.&amp;#160; However, there’s one final problem where the StaticResource binding trick won’t work.&amp;#160; Take a look at the figure below to get an idea of the problem:
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_47F7DE75.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_2AA286AB.png" width="758" height="550" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;If the DataGrid and nested ComboBox controls are moved into a User Control you can’t use the StaticResource keyword to get to the ViewModel object.&amp;#160; Why?&amp;#160; Because the ViewModel object is defined in the Resources of the parent not in the actual User Control itself.&amp;#160; You could of course write code to get to it and then bind the data (writing code is always an option but can quickly get out of control in larger applications with a lot of controls), but what if you want to bind everything declaratively in XAML?&amp;#160; I don’t know of a built-in way to do that (and I’ve asked many people and have yet to hear an answer that didn’t involve mini ViewModels for each row or writing code) so I ended up creating a fairly simple solution to address the problem.&amp;#160; &lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;The DataContextProxy Class
  &lt;br /&gt;&lt;/h2&gt;

&lt;p&gt;When I first tried to solve this problem I figured I could define the ViewModel again up in the Resources of the nested User Control.&amp;#160; Try this and you’ll quickly realize that it doesn’t work because it’ll cause a new ViewModel object to be created and two will now be in memory (one for the parent and one for the child User Control).&amp;#160; I needed a way to get to the DataContext from the parent but couldn’t do it using Resources it seemed…without writing code anyway (on a side note, I’m not opposed to writing code at all but the application I’m working on encounters the problem defined here frequently and the code started to get ridiculous).&amp;#160; I started thinking about how the ScriptManagerProxy class works in ASP.NET AJAX and played around with something I now call the “DataContextProxy”.&amp;#160; I needed a way to get to the parent’s DataContext and came up with the following class that does just that:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Windows;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Windows.Controls;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Windows.Data;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;JobPlan.Controls
{
    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DataContextProxy &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;FrameworkElement
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;public &lt;/span&gt;DataContextProxy()
        {
            &lt;span style="color: blue"&gt;this&lt;/span&gt;.Loaded += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;RoutedEventHandler&lt;/span&gt;(DataContextProxy_Loaded);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;DataContextProxy_Loaded(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;RoutedEventArgs &lt;/span&gt;e)
        {
            &lt;span style="color: #2b91af"&gt;Binding &lt;/span&gt;binding = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Binding&lt;/span&gt;();
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(!&lt;span style="color: #2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(BindingPropertyName))
            {
                binding.Path = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyPath&lt;/span&gt;(BindingPropertyName);
            }
            binding.Source = &lt;span style="color: blue"&gt;this&lt;/span&gt;.DataContext;
            binding.Mode = BindingMode;
            &lt;span style="color: blue"&gt;this&lt;/span&gt;.SetBinding(&lt;span style="color: #2b91af"&gt;DataContextProxy&lt;/span&gt;.DataSourceProperty, binding);             
        }

        &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Object &lt;/span&gt;DataSource
        {
            &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Object&lt;/span&gt;)GetValue(DataSourceProperty); }
            &lt;span style="color: blue"&gt;set &lt;/span&gt;{ SetValue(DataSourceProperty, &lt;span style="color: blue"&gt;value&lt;/span&gt;); }
        }

        &lt;span style="color: blue"&gt;public static readonly &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DependencyProperty &lt;/span&gt;DataSourceProperty =
            &lt;span style="color: #2b91af"&gt;DependencyProperty&lt;/span&gt;.Register(&lt;span style="color: #a31515"&gt;&amp;quot;DataSource&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Object&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;DataContextProxy&lt;/span&gt;), &lt;span style="color: blue"&gt;null&lt;/span&gt;);


        &lt;span style="color: blue"&gt;public string &lt;/span&gt;BindingPropertyName { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }

        &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;BindingMode &lt;/span&gt;BindingMode { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }
        
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;The DataContextProxy class grabs the parent DataContext that flows down to the child User Control and binds it to a dependency property named DataSourceProperty.&amp;#160; The DataContextProxy object can be defined in the User Control’s Resource section as shown next:

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;controls&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;DataContextProxy &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Key&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;DataContextProxy&amp;quot; /&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;This allows the ViewModel defined in the parent to be accessed using XAML in the child User Control.&amp;#160; For example, a ComboBox control nested in a DataGrid can easily get to the Branches property using the following binding syntax:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ComboBox 
    &lt;/span&gt;&lt;span style="color: red"&gt;DisplayMemberPath&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Title&amp;quot;
    &lt;/span&gt;&lt;span style="color: red"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;Source&lt;/span&gt;&lt;span style="color: blue"&gt;={&lt;/span&gt;&lt;span style="color: #a31515"&gt;StaticResource &lt;/span&gt;&lt;span style="color: red"&gt;DataContextProxy&lt;/span&gt;&lt;span style="color: blue"&gt;},&lt;/span&gt;&lt;span style="color: red"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;=DataSource.Branches}&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;The binding syntax tells the ComboBox to bind to the statically defined DataContextProxy object’s DataSource property.&amp;#160; This allows the control to get to the original ViewModel object originally defined in the parent’s Resources section.&amp;#160; The syntax then says to bind to the Branches property of the ViewModel by using the Path property.&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;/p&gt;

&lt;h2&gt;Wrapping it Up
  &lt;br /&gt;&lt;/h2&gt;

&lt;p&gt;Silverlight has a lot of nice data binding features but there will be times when you’ll run into a few road blocks as you’re developing applications.&amp;#160; In this post you’ve seen different techniques that can be used when binding nested controls to data objects and seen how the DataContextProxy object can be used.&amp;#160; Hopefully this will help some of you out down the road when you’re working with a lot of nested controls.
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.thewahlingroup.com/"&gt;&lt;img title="Logo" border="0" alt="Logo" src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width="240" height="57" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information about &lt;strong&gt;onsite, online and video training, mentoring and consulting solutions&lt;/strong&gt; for .NET, SharePoint or Silverlight please visit &lt;a href="http://www.thewahlingroup.com/"&gt;http://www.thewahlingroup.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7176078" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Building Line of Business Applications with Silverlight 3 – Pros and Cons</title><link>http://weblogs.asp.net/dwahlin/archive/2009/08/18/building-line-of-business-applications-with-silverlight-3-pros-and-cons.aspx</link><pubDate>Tue, 18 Aug 2009 07:06:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7172146</guid><dc:creator>dwahlin</dc:creator><slash:comments>47</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7172146</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/08/18/building-line-of-business-applications-with-silverlight-3-pros-and-cons.aspx#comments</comments><description>&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_31F38968.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_31F38968.png"&gt;&lt;IMG style="MARGIN: 0px 15px 10px 0px" title=image border=0 alt=image align=left src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_460CA5F1.png" width=125 height=131 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_460CA5F1.png"&gt;&lt;/A&gt;I’ve been hearing a lot of people talk about how Silverlight 3 can or can’t do various things lately throughout the blogosphere and &lt;A href="http://www.twitter.com/" target=_blank mce_href="http://www.twitter.com"&gt;Twitter&lt;/A&gt;.&amp;nbsp; The sad part is that some of the people giving their two cents about what Silverlight can’t do haven’t built a “real world” application so I’m not sure how their opinion carries any weight (I know because I’ve asked a few of them). Their list of cons are typically based on what they heard on Twitter or various rumors floating around.&amp;nbsp; As with any technology there are pros and cons and Silverlight is no exception.&amp;nbsp; The goal of this post is to talk through some of the pros and cons I’ve personally encountered while building a “real world”, enterprise-scale timesheet and job management application for a large electrical contracting company.&amp;nbsp; I’ll point out what has worked really well and what hasn’t so that people looking to move applications to Silverlight 3 can get an honest assessment on what can be done and what can’t be done.&lt;/P&gt;
&lt;P&gt;The application my company is building has a lot of different screens (30+), integrates with the backend database using WCF, uses reporting services for reports and leverages many of the key features Silverlight 3 has to offer.&amp;nbsp; The existing application used by the client was written using Access Forms and is being ported to Silverlight 3 along with a bunch of new functionality. &lt;/P&gt;
&lt;P&gt;Let’s start by going through what I personally feel are the pros and cons that Silverlight brings to the table for Line of Business (LOB) applications.&lt;/P&gt;
&lt;H3&gt;Silverlight 3 Pros&lt;/H3&gt;
&lt;P&gt;Here are some of the pros I’ve found as I’ve worked through the application:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Excellent data binding support&lt;/STRONG&gt; – my favorite feature.&amp;nbsp; This changes how you look at building applications and allows you to write data-centric code instead of control-centric code as with normal Web applications.&amp;nbsp; There’s a lot I could cover here but I wrote up a post awhile back that gives additional details about what I like.&amp;nbsp; &lt;A href="http://weblogs.asp.net/dwahlin/archive/2009/06/20/control-oriented-vs-data-oriented-programming-in-silverlight.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2009/06/20/control-oriented-vs-data-oriented-programming-in-silverlight.aspx"&gt;Read it here&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Server code and client code can written in the same language&lt;/STRONG&gt;.&amp;nbsp; Business and validation rules can be shared between the client and server code base which definitely makes applications more maintainable into the future.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;A rich set of controls&lt;/STRONG&gt; – I really like the controls available with the Silverlight SDK as well as those in the &lt;A href="http://www.codeplex.com/silverlight" target=_blank mce_href="http://www.codeplex.com/silverlight"&gt;Silverlight toolkit&lt;/A&gt;.&amp;nbsp; There are a few (mentioned below) that can test your patience when you’re building a more involved application and not a simple demo.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Support for just about any type of animation or effect you want&lt;/STRONG&gt;.&amp;nbsp; Don’t need that in a LOB app?&amp;nbsp; I beg to differ.&amp;nbsp; You can get quite creative with how data is displayed with Silverlight and not be limited to simple slide, sizing or opacity animations.&amp;nbsp; I’ll show an example of what I call the “card flow” interface later in this post and show how it allows managers to get to timecards faster and easier than before.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Excellent designer support&lt;/STRONG&gt; through Expression Blend 3 – Visual Studio 2008 is great for coding but doesn’t provide any design-time features for Silverlight 3.&amp;nbsp; Not a big deal….you can use &lt;A href="http://www.microsoft.com/expression/products/Blend_Overview.aspx" target=_blank mce_href="http://www.microsoft.com/expression/products/Blend_Overview.aspx"&gt;Expression Blend 3&lt;/A&gt; which provides a great interface for designing your applications.&amp;nbsp; The new SketchFlow application can even be used to prototype applications upfront and get customer feedback more quickly and easily than in the past.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Easy to integrate distributed data&lt;/STRONG&gt; using WCF, ASMX, REST, ADO.NET Data Services, .NET RIA Services, etc.&amp;nbsp; The application that I’m working on leverages WCF as well as some &lt;A href="http://weblogs.asp.net/dwahlin/archive/2009/07/12/simplifying-the-process-of-calling-a-wcf-service-from-silverlight-or-any-net-application.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2009/07/12/simplifying-the-process-of-calling-a-wcf-service-from-silverlight-or-any-net-application.aspx"&gt;dynamic code&lt;/A&gt; on the client-side to make calls to the service.&amp;nbsp; It works great and FaultExceptions can even be handled now with Silverlight 3.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Desktop-style application&lt;/STRONG&gt; with a web deployment model – Get the responsiveness of a desktop application that can be deployed right through the browser and even run on Macs.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Support for styling of controls&lt;/STRONG&gt;.&amp;nbsp; Silverlight 3 now allows styles to be changed on the fly and styles to be based on other styles.&amp;nbsp; If you don’t like how a control currently looks you can completely change it by using styles and control templates.&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Out of browser support&lt;/STRONG&gt; – This was a key reason why my client choose Silverlight 3.&amp;nbsp; They have a lot of remote workers that don’t always have access to the Internet and needed to be able to enter timesheets even when disconnected and then sync them later once a given employee has connectivity.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Support for behaviors&lt;/STRONG&gt;.&amp;nbsp; &lt;A href="http://blogs.msdn.com/expression/archive/2009/03/30/behaviors-under-the-hood-api-details-and-constraining-the-type.aspx" target=_blank mce_href="http://blogs.msdn.com/expression/archive/2009/03/30/behaviors-under-the-hood-api-details-and-constraining-the-type.aspx"&gt;Behaviors&lt;/A&gt; are very, very useful in Silverlight applications.&amp;nbsp; I needed to add mouse wheel scroll capabilities to a ScrollViewer control to simplify scrolling in a screen and did it within minutes by using a behavior (thanks to &lt;A href="http://silverlightplayground.boschin.it/post/2009/07/10/Silverlight-30-RTW-An-universal-MouseWheelScrolling-behavior.aspx" target=_blank mce_href="http://silverlightplayground.boschin.it/post/2009/07/10/Silverlight-30-RTW-An-universal-MouseWheelScrolling-behavior.aspx"&gt;Andrea Boschin&lt;/A&gt; who created the behavior).&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Manipulate pixels using WriteableBitmap&lt;/STRONG&gt;.&amp;nbsp; This can be used to create some &lt;A href="http://blois.us/blog/2009/07/explode.html" target=_blank mce_href="http://blois.us/blog/2009/07/explode.html"&gt;very cool effects&lt;/A&gt; (some which may not be applicable to LOB applications…but they’re still cool).&amp;nbsp; I’m using it mainly to fill the printing hole mentioned below.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Support for storing local data through isolated storage – &lt;/STRONG&gt;By using isolated storage you can cache data, store data when no network connectivity is available plus more.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Support for navigation&lt;/STRONG&gt; – Silverlight 3 has a new navigation application template in Visual Studio that makes creating an application with multiple pages quite easy.&amp;nbsp; Each “page” can be linked to directly through deep linking and has built-in support for history.&amp;nbsp; If the client hits the back or forward button in the browser they’re taken to the appropriate Silverlight application page.&amp;nbsp; The navigation framework allows code to be placed into separate pages (or user controls) and then loaded as a particular link or menu item is clicked.&amp;nbsp; It’s a great feature that can really reduce the amount of code you have to write especially compared to Silverlight 2.&lt;/LI&gt;&lt;/OL&gt;
&lt;H3&gt;Silverlight 3 Cons&lt;/H3&gt;
&lt;P&gt;So everything’s all peachy right? Both the client and I are very happy with how things are going with the application but there have been some challenges along the way.&amp;nbsp; At the beginning of this post I said I’d mention the cons as well and I’m going to be brutally honest here with some of the areas where Silverlight 3 is missing the mark when it comes to Line of Business applications.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;No printing support&lt;/STRONG&gt;.&amp;nbsp; Microsoft is working hard on this for future versions of Silverlight but if you can’t wait until then it’s definitely something to be aware of.&amp;nbsp; We knew about this going into the project so it was supposed to be a non issue since we could pop-up HTML overlays or open new browser windows that could be printed.&amp;nbsp; But, for one particular screen the lack of printing support is proving to be a challenge since it turns out the end user always prints the screen as they’re doing payroll work and the screen is quite complex.&amp;nbsp; I’ve come up with a work around using Silverlight 3’s WriteableBitmap but am currently sending bytes up to the server, converting them into a JPEG and then displaying the image in the browser.&amp;nbsp; Definitely a hack solution.&amp;nbsp; We’re now looking at generating dynamic Excel files on the fly at the client with a snapshot image of the Silverlight data since Excel will print the image properly and the browser doesn’t (still researching this option). If that doesn’t work we’ll just use reporting services to generate the same screen…not my preference though.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Binding data to controls such as a ComboBox&lt;/STRONG&gt; that is nested in other controls is harder than it should be.&amp;nbsp; I use a lot of ComboBox controls that are nested in DataGrid or ListBox rows in the application.&amp;nbsp; While I have it working fine now (after beating my head against the monitor a few times), the ComboBox control itself really needs a SelectedValue and ValueMember property for some situations and a way to more easily bind its ItemsSource to collections that may be defined outside of the current DataContext. All of this can be done via code but if you want to handle the majority of it declaratively in XAML it can be challenging in some cases especially once you start breaking parts of a page into user controls.&amp;nbsp; I ended up enhancing some code &lt;A href="http://www.lhotka.net/weblog/CommentView,guid,f3353b7c-a1b5-41f2-a9bf-00f0c4e6a999.aspx" target=_blank mce_href="http://www.lhotka.net/weblog/CommentView,guid,f3353b7c-a1b5-41f2-a9bf-00f0c4e6a999.aspx"&gt;Rocky Lhotka&lt;/A&gt; blogged about and created my own ComboBox control that simplifies things a lot.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Lack of built-in support for commanding&lt;/STRONG&gt;.&amp;nbsp; What’s “commanding”?&amp;nbsp; In a nutshell it’s the ability to call a method within an object directly from XAML as an event fires instead of going through a code-behind file.&amp;nbsp; For example, when a button is clicked the click event can call directly into a ViewModel object that acts on the event.&amp;nbsp; By using commanding you can make your applications more testable. Frameworks such as &lt;A href="http://www.codeplex.com/CompositeWPF" target=_blank mce_href="http://www.codeplex.com/CompositeWPF"&gt;Prism&lt;/A&gt; (and many others that have popped up) support simple button commanding and provide a code framework that can be used to build other types of commands.&amp;nbsp; The application I’m working on handles just about every event in the book (click, mouseenter, mouseleave, rowloaded, lostfocus, gotfocus, plus others) though and writing custom code just to handle events got old (so we simplified things and handle the event in the code-behind which notifies the ViewModel via events).&amp;nbsp; If you want to handle events directly in the code-behind file this is a non-issue for you, but if you want to handle them in another class it can be more challenging than it should be.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Learning curve&lt;/STRONG&gt; – There is certainly a learning curve associated with building Silverlight applications especially if you’re coming from building standard Web applications.&amp;nbsp; However, I think that’s the case with any technology.&amp;nbsp; I had already built several demo applications with Silverlight, co-authored a book and several articles on it and still ran into a few challenges with architecture choices along the way (we’re following the MVVM pattern).&amp;nbsp; I think it boils down to experience though so I list this one simply so that people know they will spend some time learning.&amp;nbsp; If you’re one of those people who doesn’t like to learn new things then Silverlight probably isn’t for you.&amp;nbsp; If you enjoy learning new things then I think you’ll love Silverlight once you get the hang of it.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;No built-in support for displaying Reporting Services reports&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;within Silverlight&lt;/STRONG&gt; – This isn’t a huge issue in my opinion since a report can be brought up in a separate browser window or displayed using an HTML overlay.&amp;nbsp; However, if you need to display the report directly in Silverlight there isn’t any built-in way to do that in Silverlight 3.&amp;nbsp; 3rd party vendors to the rescue though.&amp;nbsp; &lt;A href="http://perpetuumsoft.com/Product.aspx?lang=en&amp;amp;pid=116" target=_blank mce_href="http://perpetuumsoft.com/Product.aspx?lang=en&amp;amp;pid=116"&gt;Perpetuum Software&lt;/A&gt; now has a product that can integrate reports directly into Silverlight.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;The client has to have the Silverlight plugin installed&lt;/STRONG&gt;.&amp;nbsp; I personally don’t view this as much of a con for internal enterprise LOB applications since it’s fairly easy for a PC manager to push out Silverlight to client PCs in many environments.&amp;nbsp; If the application will be run externally then installation of the plugin on each client has to be considered though. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Sharing service types between proxy objects&lt;/STRONG&gt; &lt;STRONG&gt;needs to be enhanced&lt;/STRONG&gt; - When the project was initially started I wanted to use ADO.NET Data Services for some things and WCF for others.&amp;nbsp; The problem is that if both types of services reference the same type (such as Customer) then both generated proxy objects will contain a copy of that type which ultimately bloats the XAP size and leads to having to reference types by namespace down in the code&amp;nbsp;versus a using statement at the top.&amp;nbsp; Although&amp;nbsp;proxies can share code libraries from other projects (that's an option in the proxy generation wizard), my&amp;nbsp;Model entities use .NET language features not available in Silverlight class libraries so type sharing won't work there.&amp;nbsp; It's something to keep in mind as you decide&amp;nbsp;how you'll get data into your application.&lt;BR&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;There are definitely more pros than I’ve listed and probably a few more cons although I honestly can’t think of many more that I’ve had to deal with.&amp;nbsp; The bottom line is that all of the pieces are there (aside from printing) to build powerful Line of Business applications that are built using existing .NET languages.&amp;nbsp; You can make the applications look however you’d like and not have to worry if they’ll look good across different browsers.&amp;nbsp; Here’s a picture of a payroll screen in the early stages of development:&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/Makeover_504BDA92.jpg" mce_href="http://weblogs.asp.net/blogs/dwahlin/Makeover_504BDA92.jpg"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=Makeover border=0 alt=Makeover src="http://weblogs.asp.net/blogs/dwahlin/Makeover_thumb_2E800201.jpg" width=802 height=523 mce_src="http://weblogs.asp.net/blogs/dwahlin/Makeover_thumb_2E800201.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Here’s what the screen looks like after applying a few styles to the controls and adding support for things like inline editing of data:&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_65E6132F.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_65E6132F.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_4BA5AA0B.png" width=804 height=464 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_4BA5AA0B.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Some of the more “fun” features in Silverlight 3 can also be put to good use in Line of Business applications.&amp;nbsp; I needed to create a way for warehouse managers to easily manage multiple time cards for employees.&amp;nbsp; I ended up going with what I call a “card flow” interface (similar to cover flow in iTunes) to display the time cards.&amp;nbsp; The end user can use the mouse wheel to quickly navigate through different cards.&amp;nbsp; The selected card will slide to the middle with a cool animation and the others are angled using perspective 3D.&amp;nbsp; Here’s what the “card flow” interface looks like (I need to give credit to &lt;A href="http://www.cynergysystems.com/blogs/page/josefajardo?entry=coverflow_built_using_silverlight_3" target=_blank mce_href="http://www.cynergysystems.com/blogs/page/josefajardo?entry=coverflow_built_using_silverlight_3"&gt;Jose Fajardo&lt;/A&gt; for blogging about the concept): &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_7BEC7EC1.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_7BEC7EC1.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_19EA8CB6.png" width=806 height=549 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_19EA8CB6.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;To Wrap It Up&lt;/H3&gt;
&lt;P&gt;So is Silverlight 3 ready for prime time, enterprise level Line of Business applications?&amp;nbsp; Having worked with the framework nearly every day for the past 3 months in a “real world” scenario my short answer is a big “YES”!&amp;nbsp; I don’t say this because I’ve been drinking the Kool-Aid though.&amp;nbsp; Anyone who knows me understands that I use what I feel works best for a given application (unless the client wants something specific of course).&amp;nbsp; I truly enjoy working with the framework and think it can do a lot of powerful things.&lt;/P&gt;
&lt;P&gt;Every company is unique though so the answer really depends on what features your application needs.&amp;nbsp; Our previous client’s application was built using ASP.NET MVC and jQuery and it did everything they wanted it to do (I really like ASP.NET MVC and jQuery by the way).&amp;nbsp; However, Silverlight provides a more consistent way to develop enterprise applications that doesn’t require learning JavaScript, additional libraries like jQuery, CSS, HTML and other Web technologies.&amp;nbsp; With Silverlight you can write code using your favorite .NET language on both the client and server, debug applications like any normal .NET application, bind data in flexible ways, retrieve data from remote services, animate objects as needed, round corners and work with gradients without ever creating a .gif, .jpg or .png and have a ton of controls right at your finger tips.&amp;nbsp; I’m a big fan.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.thewahlingroup.com/" mce_href="http://www.thewahlingroup.com/"&gt;&lt;IMG title=Logo border=0 alt=Logo src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width=240 height=57 mce_src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit &lt;A href="http://www.thewahlingroup.com/" mce_href="http://www.thewahlingroup.com"&gt;http://www.thewahlingroup.com&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7172146" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>So What’s a Silverlight Value Converter Anyway?</title><link>http://weblogs.asp.net/dwahlin/archive/2009/08/15/so-what-s-a-silverlight-value-converter-anyway.aspx</link><pubDate>Sun, 16 Aug 2009 04:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7170562</guid><dc:creator>dwahlin</dc:creator><slash:comments>11</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7170562</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/08/15/so-what-s-a-silverlight-value-converter-anyway.aspx#comments</comments><description>&lt;P&gt;Silverlight has an excellent data binding engine that allows data to be bound through XAML or programmatically with code.&amp;nbsp; My number one reason for using Silverlight on client projects is the data binding support.&amp;nbsp; Once you get into it and understand how it works it can save a lot of time when building applications.&lt;/P&gt;
&lt;P&gt;When you’re binding data to controls there will be times when the data needs to be modified or tweaked some on the way into a control or as the data leaves a control and goes back to the source property (during a TwoWay binding for example).&amp;nbsp; Sure, you can always write code to change a given value, but in many cases it’s much easier to write a simple value converter instead that can be re-used.&amp;nbsp; In this post I’ll walk through creating a value converter and then show the code for a few of the value converters I find myself using fairly frequently. &lt;BR&gt;&lt;/P&gt;
&lt;H3&gt;Creating a Value Converter&lt;/H3&gt;
&lt;P&gt;Let’s look at a simple example of creating a value converter to get started.&amp;nbsp; Many applications work with DateTime objects but don’t want the time displayed or want the date formatted a specific way.&amp;nbsp; If you bind a DateTime property to something like a TextBlock in Silverlight you’ll get the standard output based upon the current culture: &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/clip_image00211_140D92B9.jpg" mce_href="http://weblogs.asp.net/blogs/dwahlin/clip_image00211_140D92B9.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image002[11] border=0 alt=clip_image002[11] src="http://weblogs.asp.net/blogs/dwahlin/clip_image00211_thumb_0BA9BD62.jpg" width=211 height=179 mce_src="http://weblogs.asp.net/blogs/dwahlin/clip_image00211_thumb_0BA9BD62.jpg"&gt;&lt;/A&gt; &lt;BR&gt;&lt;BR&gt;In the case of a birthday you want to show the date but don’t need the time of course.&amp;nbsp; You’d want something like the following: &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/clip_image00213_4690F02B.jpg" mce_href="http://weblogs.asp.net/blogs/dwahlin/clip_image00213_4690F02B.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image002[13] border=0 alt=clip_image002[13] src="http://weblogs.asp.net/blogs/dwahlin/clip_image00213_thumb_45B88A41.jpg" width=176 height=180 mce_src="http://weblogs.asp.net/blogs/dwahlin/clip_image00213_thumb_45B88A41.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Although a separate property could be created in the source object being bound that handles formatting the date, a value converter can be created and re-used over and over anytime a specific date format needs to be created.&amp;nbsp; To create a value converter you’ll need to add a Silverlight class into your project and implement an interface named IValueConverter (located in the System.Windows.Data namespace).&amp;nbsp; This interface defines two members including Convert and ConvertBack. Convert is used to modify data as its bound from the source object to the control. ConvertBack works the other way. As a user changes data in a control such as a TextBox the data can be "converted back" to the original data type in the source object by using ConvertBack. &lt;/P&gt;
&lt;P&gt;Both Convert and ConvertBack accept the same parameters including the data being bound, the type of the data being bound, any parameter data passed in that can be used in the data conversion process as well as the target culture that the entire process is running under (English, Spanish, French, etc.). Here's what the method signatures look like: &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;object Convert(object value, Type targetType, object parameter, CultureInfo culture); &lt;BR&gt;object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);&lt;/FONT&gt; &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;Once IValueConverter is added to your class you can right-click it in Visual Studio and select &lt;EM&gt;Implement Interface&lt;/EM&gt; from the menu to automatically fill in the Convert and ConvertBack methods. If you're using Visual Basic you can simply hit enter after the interface name to accomplish the same thing.&amp;nbsp; Here’s an example of a date value converter that allows dates to be formatted: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows.Data;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Globalization;

&lt;SPAN style="COLOR: blue"&gt;namespace &lt;/SPAN&gt;View.Converters
{
   &lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DateConverter &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;IValueConverter
    &lt;/SPAN&gt;{

        &lt;SPAN style="COLOR: blue"&gt;#region &lt;/SPAN&gt;IValueConverter Members

        &lt;SPAN style="BACKGROUND: #e2e2e2; COLOR: #008200"&gt;//Called when binding from an object property to a control property
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;Convert(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(value == &lt;SPAN style="COLOR: blue"&gt;null &lt;/SPAN&gt;|| (&lt;SPAN style="COLOR: #2b91af"&gt;DateTime&lt;/SPAN&gt;)value == &lt;SPAN style="COLOR: #2b91af"&gt;DateTime&lt;/SPAN&gt;.MinValue) &lt;SPAN style="COLOR: blue"&gt;return null&lt;/SPAN&gt;;
            &lt;SPAN style="COLOR: #2b91af"&gt;DateTime &lt;/SPAN&gt;dt = (&lt;SPAN style="COLOR: #2b91af"&gt;DateTime&lt;/SPAN&gt;)value;
            &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;dt.ToString((&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;)parameter, culture);
        }

        &lt;SPAN style="BACKGROUND: #e2e2e2; COLOR: #008200"&gt;//Called with two-way data binding as value is pulled out of control and put back into the property
&lt;/SPAN&gt;        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;ConvertBack(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;val = (&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;)value;
            &lt;SPAN style="COLOR: #2b91af"&gt;DateTime &lt;/SPAN&gt;outDate;
            &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;DateTime&lt;/SPAN&gt;.TryParse(val, culture, &lt;SPAN style="COLOR: #2b91af"&gt;DateTimeStyles&lt;/SPAN&gt;.None, &lt;SPAN style="COLOR: blue"&gt;out &lt;/SPAN&gt;outDate))
            {
                &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;outDate;
            }
            &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;.UnsetValue;

        }

        &lt;SPAN style="COLOR: blue"&gt;#endregion
    &lt;/SPAN&gt;}
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR&gt;To use a value converter you’ll need to first reference the class’s namespace (and assembly if the class is in a separate project).&amp;nbsp; This can be done in the XAML file where the value converter will be used, in App.xaml or in a merged resource dictionary file.&amp;nbsp; An example of defining a namespace in a resource dictionary file named Styles.xaml is shown next: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary
  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;converters&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="clr-namespace:View.Converters"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;

&lt;SPAN style="COLOR: blue"&gt;   …&lt;/SPAN&gt;

&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&amp;gt; &lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;Once the namespace is defined you need to define the converter using XAML and give it a key that can be used to reference the value converter (similar to an ID in ASP.NET): &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;converters&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DateConverter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="DateConverter" /&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR&gt;Now that the converter is defined you can use it in any data binding that handles a DateTime object using the Binding object’s Converter and ConverterParameter properties.&amp;nbsp; Looking at the code below you can see that the converter is referenced using the StaticResource keyword (since it’s defined as a resource within your Silverlight project) which locates the appropriate key for the converter. &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBox &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="txtBirthday" 
         &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Birthday&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Mode&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=TwoWay, &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Converter&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;={&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DateConverter&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;},&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ConverterParameter&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=d}"
         &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;FontFamily&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Arial" 
         &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="200" 
         &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="20" 
         &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="5"  /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;This automatically routes all in and out data binding operations (since it’s a TwoWay binding) through the value converter.&amp;nbsp; If data is being bound to a control such as a TextBox the parameter passed (“d” in this example) is used to format the DateTime object data.&amp;nbsp; If data is updated in the control it’ll automatically be converted from a string back into a DateTime object. &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;
&lt;H3&gt;Value Converter Examples&lt;/H3&gt;
&lt;P&gt;&lt;BR&gt;I have quite a few value converters that I use from time to time in client applications and have listed some of them below.&amp;nbsp; If you have a favorite one you’re willing to share with others please add a comment to this post with your name, a description of the value converter as well as the code and I’ll update the blog (and give you credit of course) so that a nice library of value converters built-up over time. Update: &lt;A href="http://wildermuth.com/" target=_blank mce_href="http://wildermuth.com/"&gt;Shawn Wildermuth&lt;/A&gt; let me know that the&amp;nbsp;&lt;A href="http://silverlightcontrib.codeplex.com/" target=_blank mce_href="http://silverlightcontrib.codeplex.com/"&gt;Silverlight Contrib project&lt;/A&gt; has some similar value converters as well as others so check that out as well if you get a chance.&lt;/P&gt;
&lt;H4&gt;BoolToVisibilityConverter &lt;/H4&gt;
&lt;P&gt;Handles converting boolean values into Visibility enumeration values.&amp;nbsp; This is useful when controls need to be shown and hidden based upon the value of a boolean property.&amp;nbsp; The &lt;EM&gt;Inverse&lt;/EM&gt; parameter value can be passed when you want to hide a control when the property being bound is true or show the control when the value is false. &lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows.Data;

&lt;SPAN style="COLOR: blue"&gt;namespace &lt;/SPAN&gt;JobPlan.View.Converters
{
    &lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;BoolToVisibilityConverter &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;IValueConverter
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;#region &lt;/SPAN&gt;IValueConverter Members

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;Convert(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(parameter == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)
            {
                &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;((&lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt;)value == &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;) ? &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Visible : &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Collapsed;
            }
            &lt;SPAN style="COLOR: blue"&gt;else if &lt;/SPAN&gt;(parameter.ToString() == &lt;SPAN style="COLOR: #a31515"&gt;"Inverse"&lt;/SPAN&gt;)
            {
                &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;((&lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt;)value == &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;) ? &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Collapsed : &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Visible;
            }
            &lt;SPAN style="COLOR: blue"&gt;return false&lt;/SPAN&gt;;
        }

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;ConvertBack(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;throw new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotImplementedException&lt;/SPAN&gt;();
        }

        &lt;SPAN style="COLOR: blue"&gt;#endregion
    &lt;/SPAN&gt;}
}&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;BR&gt;DecimalFormatterConverter&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Converts decimal values into different formats.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows.Data;

&lt;SPAN style="COLOR: blue"&gt;namespace &lt;/SPAN&gt;JobPlan.View.Converters
{
    &lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DecimalFormatterConverter &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;IValueConverter
    &lt;/SPAN&gt;{

        &lt;SPAN style="COLOR: blue"&gt;#region &lt;/SPAN&gt;IValueConverter Members

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;Convert(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;format = (parameter == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) ? &lt;SPAN style="COLOR: #a31515"&gt;"#.##" &lt;/SPAN&gt;: parameter.ToString();
            &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;(value == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) ? &lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt;.Empty : &lt;SPAN style="COLOR: blue"&gt;decimal&lt;/SPAN&gt;.Parse(value.ToString()).ToString(format);
        }

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;ConvertBack(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;try
            &lt;/SPAN&gt;{
                &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(value != &lt;SPAN style="COLOR: blue"&gt;null &lt;/SPAN&gt;&amp;amp;&amp;amp; value.ToString() != &lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt;.Empty)
                {
                    &lt;SPAN style="COLOR: blue"&gt;return decimal&lt;/SPAN&gt;.Parse(value.ToString());
                }
            }
            &lt;SPAN style="COLOR: blue"&gt;catch &lt;/SPAN&gt;{ }
            &lt;SPAN style="COLOR: blue"&gt;return null&lt;/SPAN&gt;;
        }

        &lt;SPAN style="COLOR: blue"&gt;#endregion
    &lt;/SPAN&gt;}
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR&gt;&lt;/P&gt;
&lt;H4&gt;ListCountVisibilityConverter&lt;/H4&gt;
&lt;P&gt;Handles showing and hiding controls such as ListBox based upon the number of items in the collection the control is bound to.&amp;nbsp; For example if there is only one item in a collection you may not want to show a ListBox control due to the data being shown with other controls in the UI.&amp;nbsp; You could pass a value of 1 for the ConverterParameter and the ListBox would automatically be hidden.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows.Data;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Collections;

&lt;SPAN style="COLOR: blue"&gt;namespace &lt;/SPAN&gt;JobPlan.View.Converters
{
    &lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ListCountVisibilityConverter &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;IValueConverter
    &lt;/SPAN&gt;{

        &lt;SPAN style="COLOR: blue"&gt;#region &lt;/SPAN&gt;IValueConverter Members

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;Convert(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(value != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)
            {
                &lt;SPAN style="COLOR: #2b91af"&gt;IList &lt;/SPAN&gt;list = value &lt;SPAN style="COLOR: blue"&gt;as &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;IList&lt;/SPAN&gt;;
                &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(list != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)
                {
                    &lt;SPAN style="COLOR: blue"&gt;int &lt;/SPAN&gt;minCount = &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;.Parse(parameter.ToString());
                    &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;(list.Count &amp;gt; minCount) ? &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Visible : &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Collapsed;
                }
                
            }
            &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Collapsed;
        }

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;ConvertBack(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;throw new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotImplementedException&lt;/SPAN&gt;();
        }

        &lt;SPAN style="COLOR: blue"&gt;#endregion
    &lt;/SPAN&gt;}
}&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;&lt;/P&gt;
&lt;H4&gt;NullToVisibilityConverter&lt;/H4&gt;
&lt;P&gt;Handles showing and hiding a control based upon a value being null or not.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows.Data;

&lt;SPAN style="COLOR: blue"&gt;namespace &lt;/SPAN&gt;JobPlan.View.Converters
{
    &lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NullToVisibilityConverter &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;IValueConverter
    &lt;/SPAN&gt;{

        &lt;SPAN style="COLOR: blue"&gt;#region &lt;/SPAN&gt;IValueConverter Members

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;Convert(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(parameter == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) &lt;SPAN style="BACKGROUND: #e2e2e2; COLOR: #008200"&gt;//Not invert parameter passed
&lt;/SPAN&gt;            {
                &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;(value == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) ? &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Collapsed : &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Visible;
            }
            &lt;SPAN style="COLOR: blue"&gt;else if &lt;/SPAN&gt;(parameter.ToString() == &lt;SPAN style="COLOR: #a31515"&gt;"Inverse"&lt;/SPAN&gt;)
            {
                &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;(value == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) ? &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Visible : &lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Collapsed;
            }
            &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;.Collapsed;
        }

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;ConvertBack(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;throw new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotImplementedException&lt;/SPAN&gt;();
        }

        &lt;SPAN style="COLOR: blue"&gt;#endregion
    &lt;/SPAN&gt;}
}&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;&lt;/P&gt;
&lt;H4&gt;StringTruncateConverter&lt;/H4&gt;
&lt;P&gt;Trims a string down to a specific length for display in the user interface.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System;
&lt;SPAN style="COLOR: blue"&gt;using &lt;/SPAN&gt;System.Windows.Data;

&lt;SPAN style="COLOR: blue"&gt;namespace &lt;/SPAN&gt;JobPlan.View.Converters
{
    &lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;StringTruncateConverter &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;IValueConverter
    &lt;/SPAN&gt;{

        &lt;SPAN style="COLOR: blue"&gt;#region &lt;/SPAN&gt;IValueConverter Members

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;Convert(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;int &lt;/SPAN&gt;maxLength;
            &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;.TryParse(parameter.ToString(), &lt;SPAN style="COLOR: blue"&gt;out &lt;/SPAN&gt;maxLength))
            {
                &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;val = (value == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) ? &lt;SPAN style="COLOR: blue"&gt;null &lt;/SPAN&gt;: value.ToString();
                &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(val != &lt;SPAN style="COLOR: blue"&gt;null &lt;/SPAN&gt;&amp;amp;&amp;amp; val.Length &amp;gt; maxLength)
                {
                    &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;val.Substring(0, maxLength) + &lt;SPAN style="COLOR: #a31515"&gt;".."&lt;/SPAN&gt;;
                }
            }
            &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;value;
        }

        &lt;SPAN style="COLOR: blue"&gt;public object &lt;/SPAN&gt;ConvertBack(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;value, &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;targetType, &lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;parameter, System.Globalization.&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo &lt;/SPAN&gt;culture)
        {
            &lt;SPAN style="COLOR: blue"&gt;throw new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotImplementedException&lt;/SPAN&gt;();
        }

        &lt;SPAN style="COLOR: blue"&gt;#endregion
    &lt;/SPAN&gt;}
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7170562" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Making Silverlight 3 Application Code More Compatible with Blend</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/29/making-silverlight-3-application-code-more-compatible-with-blend.aspx</link><pubDate>Thu, 30 Jul 2009 02:24:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7157399</guid><dc:creator>dwahlin</dc:creator><slash:comments>9</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7157399</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/29/making-silverlight-3-application-code-more-compatible-with-blend.aspx#comments</comments><description>&lt;P&gt;Expression Blend 3 is a great tool for creating Silverlight or WPF user interfaces using design time tools and controls.&amp;nbsp; If you haven’t tried version 3 you’re really missing out since it adds a ton of new time-saving features.&lt;/P&gt;
&lt;P&gt;While I really enjoy working in Blend, one of the things I’ve struggled with in the past is making code work better in Blend.&amp;nbsp; If you’ve ever had an error like the following you know what I mean: &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_31EC0900.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_31EC0900.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_25EA18CC.png" width=770 height=87 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_25EA18CC.png"&gt;&lt;/A&gt; &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;What’s up with the error?&amp;nbsp; In short, I’m declaratively assigning my ViewModel object (my object that contains the data being bound to the Silverlight View if you’re new to the whole MVVM terminology) in the View’s resources area as shown next:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;navigation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Page.Resources&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;viewModel&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;PayrollSummaryViewModel &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ViewModel" /&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;navigation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Page.Resources&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;There’s nothing wrong with that except that when the ViewModel object’s constructor is called an error is occurring due to a null reference exception.&amp;nbsp; &lt;STRONG&gt;Note:&lt;/STRONG&gt; Some people like the declarative way of defining ViewModels and some people don't.&amp;nbsp; A few months ago I was against that approach until I started working on my current project and realized that the pros outweighed the cons (at least for my scenario).&amp;nbsp; Plus, the declarative&amp;nbsp;approach is used when working with test data in Blend 3.&amp;nbsp; Ultimately each application has different requirements so I'll leave it as an "exercise for the reader" to decide what works best for you.&lt;/P&gt;
&lt;P&gt;Here’s the code in the constructor which is calling out to a WCF service to retrieve some data: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public &lt;/SPAN&gt;PayrollSummaryViewModel(&lt;SPAN style="COLOR: #2b91af"&gt;IServiceProxy &lt;/SPAN&gt;proxy)
{
    _Proxy = (proxy != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) ? proxy : &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ServiceProxy&lt;/SPAN&gt;();
    GetPayrollSummary();
}&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You obviously can’t call out to a WCF service when you don’t have access to an HTTP stack.&amp;nbsp; Fortunately, fixing the problem and making the code more “Blendable” is easy.&amp;nbsp; Silverlight has a class named DesignerProperties that can be used to check if the code is being run in a designer such as Blend or if the code is being run live.&amp;nbsp; Here’s an example of using the DesignerProperties class and wrapping it in a property named IsDesignTime:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public bool &lt;/SPAN&gt;IsDesignTime
{
    &lt;SPAN style="COLOR: blue"&gt;get
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DesignerProperties&lt;/SPAN&gt;.GetIsInDesignMode(&lt;SPAN style="COLOR: #2b91af"&gt;Application&lt;/SPAN&gt;.Current.RootVisual);
    }
}&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;To avoid trying to call the WCF service in the ViewModel object’s constructor when the code is run in Blend I can wrap the code with the call to IsDesignTime as shown next and Blend is happy with everything.&amp;nbsp; &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public &lt;/SPAN&gt;PayrollSummaryViewModel(&lt;SPAN style="COLOR: #2b91af"&gt;IServiceProxy &lt;/SPAN&gt;proxy)
{
    &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(!&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.IsDesignTime)
    {
        _Proxy = (proxy != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) ? proxy : &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ServiceProxy&lt;/SPAN&gt;();
        GetPayrollSummary();
    }
}&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;You can see that creating more “Blendable” code is pretty easy once you know this simple trick.&amp;nbsp; More info on the &lt;A href="http://msdn.microsoft.com/en-us/library/system.componentmodel.designerproperties.getisindesignmode(VS.95).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.componentmodel.designerproperties.getisindesignmode(VS.95).aspx"&gt;DesignerProperties class can be found here&lt;/A&gt; if you’re interested.&amp;nbsp; There are apparently some issues using it with the Visual Studio designer used for Silverlight 2, but since Silverlight 3 doesn’t have a Visual Studio designer that’s kind of a moot point. &lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7157399" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Expression+Blend/default.aspx">Expression Blend</category></item><item><title>Previewing Websites in Multiple Browsers with Expression Web 3’s SuperPreview</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/24/previewing-websites-in-multiple-browsers-with-expression-web-3-s-superpreview.aspx</link><pubDate>Fri, 24 Jul 2009 19:29:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7154130</guid><dc:creator>dwahlin</dc:creator><slash:comments>10</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7154130</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/24/previewing-websites-in-multiple-browsers-with-expression-web-3-s-superpreview.aspx#comments</comments><description>&lt;p&gt;Expression Studio 3 has a great new feature that was announced and demonstrated back at the Mix 09 conference called SuperPreview.&amp;#160; It allows you to compare how a page looks across multiple browsers including IE6, IE7, IE8 and FireFox (with more reportedly coming in the future).&amp;#160; In this post I’m going to provide a quick look at SuperPreview and walk you through some screen shots to get you started using it.   &lt;br /&gt;    &lt;br /&gt;After installing Expression Studio 3 I opened SuperPreview and saw the browsers shown in the image below.&amp;#160; The first thing you’ll notice is that you can test IE6.&amp;#160; Although I personally wish this browser would die and go away, my company still works with several clients who have large IE6 deployments across the enterprise so it’s nice to be able to test it easily.&amp;#160; Previously I used &lt;a href="http://www.my-debugbar.com/wiki/IETester/HomePage" target="_blank"&gt;IETester&lt;/a&gt; (which works quite well) to test different versions of IE.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_13EB87D0.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_77FA52D7.png" width="794" height="530" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;I’m a big fan of the new Safari 4 browser for Windows and wanted to be able to test against that as well but it’s not currently supported.&amp;#160; Based on various Microsoft blog posts I’ve seen they’re planning to release support for Safari and other browsers later so I’m hoping that’s the case.&amp;#160; To see how a site looks in multiple browsers select a browser on each side of the SuperPreview interface by clicking the browser icon, type the URL to test into the Location textbox (at the top center of the SuperPreview window) and hit Enter:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_49C0571D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_27884B97.png" width="802" height="486" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;The browsers that your testing will show at the bottom of the screen and you can even test in different resolutions by clicking the Browser Size drop-down in the bottom-right corner.&amp;#160; Click the X icon next to a browser to remove it.&lt;/p&gt;  &lt;p&gt;If you’d like to test multiple browsers in one window and compare them against a baseline browser you can select a browser on the left side followed by another browser from the right side.&amp;#160; Then click the + icon at the bottom left of the screen (to the right of the second browser) and add others.&amp;#160; Here’s what it looks like after selecting several browsers:&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_6F8657B3.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_540155B0.png" width="805" height="489" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;SuperPreview also includes a DOM viewer that can be used to compare the DOMs across multiple browsers.&amp;#160; To use it click the DOM tab located in the bottom-right corner of the SuperPreview window.&amp;#160; Once the DOM window is showing you can click on anything within the browser preview windows and you’ll see the associated HTML tags and CSS styles associated with the element:&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&amp;#160;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_6E01F990.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_31F5B7DB.png" width="811" height="492" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;You can also drag the ruler onto pages to compare how things line up vertically and horizontally:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_39517788.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_3D7B4F4D.png" width="827" height="501" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Finally, you can overlay browsers to see how pages match up by clicking the D key.&amp;#160; Here’s an example of overlaying Firefox 3.5 and IE 6 screens (brace your eyes since it creates a blur type of effect…gotta love IE6):&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&amp;#160;&lt;a href="http://weblogs.asp.net/blogs/dwahlin/image_6B98417C.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_08BDE987.png" width="817" height="495" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;There’s more you can do with SuperPreview but the features shown here are quite important when you’re trying to make sure a site looks good across multiple browsers.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7154130" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Running a WCF Service on IIS 7</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/21/running-a-wcf-service-on-iis-7.aspx</link><pubDate>Wed, 22 Jul 2009 06:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7152589</guid><dc:creator>dwahlin</dc:creator><slash:comments>6</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7152589</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/21/running-a-wcf-service-on-iis-7.aspx#comments</comments><description>&lt;P&gt;I was trying to get a WCF service going on my Windows 7 machine tonight that I call from a Silverlight 3 application and ran into the following error when trying to view the .svc file in the browser:&lt;/P&gt;
&lt;H4&gt;&lt;STRONG&gt;HTTP Error 404.3 - Not Found&lt;/STRONG&gt;&lt;/H4&gt;
&lt;H5&gt;&lt;STRONG&gt;The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.&lt;/STRONG&gt;&lt;/H5&gt;
&lt;P&gt;&lt;BR&gt;After scratching my head for a few minutes I figured something must not be installed since IIS 7 is very “componentized”.&amp;nbsp; After looking through Programs and Features –&amp;gt; Turn Windows features on or off I came across a Microsoft .NET Framework 3.5.1 section.&amp;nbsp; I checked the two Windows Communication Foundation checkboxes shown below (the second box enables Windows Activation Service - WAS so that IIS can host WCF services that can be called using non-HTTP bindings such as TCP): &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_4A79EB31.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_4A79EB31.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_7A548CF2.png" width=447 height=392 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_7A548CF2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;After fixing the problem the .svc file loaded fine and I was off and running.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Arial, Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span&gt;&lt;SPAN style="TEXT-ALIGN: left; FONT-SIZE: 12px" class=Apple-style-span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Arial, Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span&gt;&lt;SPAN style="TEXT-ALIGN: left; FONT-SIZE: 12px" class=Apple-style-span&gt;
&lt;P style="MARGIN: 10px 0px"&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/" mce_href="http://www.thewahlingroup.com/"&gt;&lt;IMG style="MARGIN: 0.5em; MAX-WIDTH: 100%" title=Logo border=0 alt=Logo src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width=240 height=57 mce_src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="MARGIN: 10px 0px"&gt;For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit&lt;SPAN class=Apple-converted-space&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/" mce_href="http://www.thewahlingroup.com/"&gt;&lt;FONT color=#0066cc&gt;http://www.thewahlingroup.com/&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7152589" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Using Element to Element Binding for ToolTips in Silverlight 3</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/13/using-element-to-element-binding-for-tooltips-in-silverlight-3.aspx</link><pubDate>Tue, 14 Jul 2009 03:43:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146911</guid><dc:creator>dwahlin</dc:creator><slash:comments>10</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7146911</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/13/using-element-to-element-binding-for-tooltips-in-silverlight-3.aspx#comments</comments><description>&lt;P&gt;Silverlight 3 provides a new feature called “element to element” binding that allows one element to bind to another element’s property.&amp;nbsp; It’s really useful when you want to tie two objects together so that when one object changes the other changes as well.&lt;/P&gt;
&lt;P&gt;A lot of the samples I see for this new technology tend to focus on using slider controls but I just don’t have a need for sliders most of the time (although it certainly depends upon what type of application you’re building).&amp;nbsp; Here’s a simple yet effective way to leverage element to element binding for tooltips.&amp;nbsp; I currently have a ComboBox control with a data template and want to show a description of the selected item as the user mouses over the control.&amp;nbsp; With Silverlight 2 you’d have to write code since there wouldn’t be a way for the tooltip service to bind to the selected item declaratively.&amp;nbsp; Now, you can do something like this (notice the ToolTipService attribute): &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ComboBox 
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="WorkCodeComboBox"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;    ItemsSource&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Source&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;={&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ViewModel&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;},&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Path&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=CurrentTimeSheetView.WorkCodes}"
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;TimeSheetComboBoxStyle&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}" 
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;SelectionChanged&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="WorkCode_SelectionChanged"
    &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="COLOR: red"&gt;ToolTipService.ToolTip&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Path&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=SelectedItem.Description, &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ElementName&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;STRONG&gt;=WorkCodeComboBox}"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ComboBox.ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DataTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Orientation&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Horizontal" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0"&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBlock &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;WorkCodeID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="30" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="5,0,0,0" /&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Rectangle &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ComboBoxVerticalLine&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}" /&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBlock &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Description&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="250" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="10,0,0,0" /&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DataTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
   &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ComboBox.ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ComboBox&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;In this case I’m binding the tooltip to the selected item’s Description property.&amp;nbsp; At first glance it looks like the ComboBox is binding to itself but in reality it’s binding to the ToolTipService’s Tooltip property.&amp;nbsp; A simple little trick but nice when you need it since it saves a line or two of C# code.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Arial, Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span&gt;&lt;SPAN style="TEXT-ALIGN: left; FONT-SIZE: 12px" class=Apple-style-span&gt;
&lt;P style="MARGIN: 10px 0px"&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/"&gt;&lt;IMG style="MARGIN: 0.5em; MAX-WIDTH: 100%" title=Logo border=0 alt=Logo src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width=240 height=57&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="MARGIN: 10px 0px"&gt;For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit&lt;SPAN class=Apple-converted-space&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/"&gt;&lt;FONT color=#0066cc&gt;http://www.thewahlingroup.com/&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146911" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Simplifying the Process of Calling a WCF Service from Silverlight (or any .NET Application)</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/12/simplifying-the-process-of-calling-a-wcf-service-from-silverlight-or-any-net-application.aspx</link><pubDate>Mon, 13 Jul 2009 00:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146175</guid><dc:creator>dwahlin</dc:creator><slash:comments>17</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7146175</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/12/simplifying-the-process-of-calling-a-wcf-service-from-silverlight-or-any-net-application.aspx#comments</comments><description>&lt;P&gt;I’m currently working on a large Silverlight 3 project for a client that will ultimately have hundreds of calls from Silverlight to WCF service operations.&amp;nbsp; Initially I did things the standard way which is to define a client-side class that’s used to call the WCF service using the generated service proxy (I’m basically following a service agent type of pattern).&amp;nbsp; The service agent class handles instantiating the WCF proxy object and calling the appropriate operations.&amp;nbsp; Here are a few examples….each of these methods accept the parameters passed to the WCF service as well as a callback method that’s called when the service returns data. &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;GetJobs(&lt;SPAN style="COLOR: #2b91af"&gt;EventHandler&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;GetJobsCompletedEventArgs&lt;/SPAN&gt;&amp;gt; callback)
{
    &lt;SPAN style="COLOR: #2b91af"&gt;IJobPlanService &lt;/SPAN&gt;proxy = &lt;SPAN style="COLOR: blue"&gt;GetProxy&lt;/SPAN&gt;();
    proxy.GetJobsCompleted += callback;
    proxy.GetJobsAsync();
}

&lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;GetEmployees(&lt;SPAN style="COLOR: #2b91af"&gt;EventHandler&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;GetEmployeesCompletedEventArgs&lt;/SPAN&gt;&amp;gt; callback)
{
    &lt;SPAN style="COLOR: #2b91af"&gt;IJobPlanService &lt;/SPAN&gt;proxy = &lt;SPAN style="COLOR: blue"&gt;GetProxy&lt;/SPAN&gt;();
    proxy.GetEmployeesCompleted += callback;
    proxy.GetEmployeesAsync();
}

&lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;GetEmployeesByJobID(&lt;SPAN style="COLOR: blue"&gt;int &lt;/SPAN&gt;jobID, &lt;SPAN style="COLOR: #2b91af"&gt;EventHandler&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;GetEmployeesByJobIDCompletedEventArgs&lt;/SPAN&gt;&amp;gt; callback)
{
    &lt;SPAN style="COLOR: #2b91af"&gt;IJobPlanService &lt;/SPAN&gt;proxy = &lt;SPAN style="COLOR: blue"&gt;GetProxy&lt;/SPAN&gt;();
    proxy.GetEmployeesByJobIDCompleted += callback;
    proxy.GetEmployeesByJobIDAsync(jobID);
}

&lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;GetTimeSheetViews(&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;? jobID, &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;? empID, &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;weekEnding, &lt;SPAN style="COLOR: #2b91af"&gt;EventHandler&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;GetTimeSheetViewsCompletedEventArgs&lt;/SPAN&gt;&amp;gt; callback)
{
    &lt;SPAN style="COLOR: #2b91af"&gt;IJobPlanService &lt;/SPAN&gt;proxy = &lt;SPAN style="COLOR: blue"&gt;GetProxy&lt;/SPAN&gt;();
    proxy.GetTimeSheetViewsCompleted += callback;
    proxy.GetTimeSheetViewsAsync(jobID, empID, weekEnding);
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;After writing nearly the same code method after method (aside from changes in the event name and method name) I opted for a simplified approach that allows me to call any WCF service operation using a single method.&amp;nbsp; That way I don’t have to continually write wrapper methods just to call a service operation which really seems pointless to me.&amp;nbsp; Some people will like the following code since it can eliminate a ton of code from your Silverlight project (the code would work fine outside of Silverlight too by the way) while others won’t like it since reflection is involved (I personally don’t view reflection as a big deal here since it’s running on the client-side).&lt;/P&gt;
&lt;P&gt;Here’s how it works:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The CallService method shown next accepts an async callback delegate as well as the parameter data that should be passed to the service.&amp;nbsp; In other words, tell it what method to call once the service returns data as well as what data to pass up to the service operation. &lt;/LI&gt;
&lt;LI&gt;When calling the CallService method you must supply the type of EventArgs that will be returned from the service call.&amp;nbsp; This is done using generics.&amp;nbsp; &lt;/LI&gt;&lt;/OL&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: gray"&gt;/// &amp;lt;summary&amp;gt;
/// &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;Used to call a WCF service operation.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;/// &amp;lt;/summary&amp;gt;
/// &amp;lt;typeparam name="T"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;The type of EventArgs that will be returned by the service operation.&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/typeparam&amp;gt;
/// &amp;lt;param name="callback"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;The method to call once the WCF call returns (the callback).&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;
/// &amp;lt;param name="parameters"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;Any parameters that the service operation expects.&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;CallService&amp;lt;T&amp;gt;(&lt;SPAN style="COLOR: #2b91af"&gt;EventHandler&lt;/SPAN&gt;&amp;lt;T&amp;gt; callback, &lt;SPAN style="COLOR: blue"&gt;params object&lt;/SPAN&gt;[] parameters) &lt;SPAN style="COLOR: blue"&gt;where &lt;/SPAN&gt;T : &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs
&lt;/SPAN&gt;{
    &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;action = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(T).Name.Replace(&lt;SPAN style="COLOR: #a31515"&gt;"CompletedEventArgs"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt;.Empty);
    &lt;SPAN style="COLOR: #2b91af"&gt;IJobPlanService &lt;/SPAN&gt;proxy = &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;JobPlanServiceClient&lt;/SPAN&gt;();
    &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;t = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;JobPlanServiceClient&lt;/SPAN&gt;);
    t.GetEvent(action + &lt;SPAN style="COLOR: #a31515"&gt;"Completed"&lt;/SPAN&gt;).AddEventHandler(proxy, callback);
    t.InvokeMember(action + &lt;SPAN style="COLOR: #a31515"&gt;"Async"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #2b91af"&gt;BindingFlags&lt;/SPAN&gt;.InvokeMethod, &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;, proxy, parameters);
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR&gt;An example of using the CallService method is shown next: &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public void &lt;/SPAN&gt;GetAreasByJobID()
{
    _Proxy.CallService&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;GetAreasByJobIDCompletedEventArgs&lt;/SPAN&gt;&amp;gt;((s,e) =&amp;gt; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.CurrentTimeSheetView.Areas = e.Result,
        &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.TimeSheetJob.JobID);
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;The GetAreasByJobID method passes a type of GetAreasByJobIDCompletedEventArgs as the generic type to CallService, defines the async callback using a lambda expression (although a separate method could certainly be defined) and passes the parameter that the service operation expects (multiple parameters can be passed when needed).&amp;nbsp; CallService knows which WCF service operation to call based upon the generic type that’s passed since WCF service proxy object’s always create EventArgs classes that end with “CompletedEventArgs”.&amp;nbsp; The method simply removes the string “CompletedEventArgs” to get the operation name, instantiates the service proxy object and then uses reflection to wire up the appropriate event and async method to call.&amp;nbsp; If you use several different service proxy objects you could certainly handle that as well with generics.&amp;nbsp; I played around with ChannelFactory as well but opted for this approach mainly because it was more straightforward in my opinion and because I wanted to use the generated WCF proxy anyway.&lt;/P&gt;
&lt;P&gt;If scalability was an issue (which is not the case here since this runs on the client-side) then I’d go with the standard approach of using the WCF proxy methods that are generated as shown in the first section of code above.&amp;nbsp; For this application it’s eliminated hundreds of lines of redundant code though (which would’ve grown to 1000s since we’re only 25% of the way through the project) which means we have less to worry about plus this eliminates the time it would’ve taken to write the wrapper methods.&amp;nbsp; Ultimately I view this as a significant benefit to future maintenance since there’s less wrapper code that can get out of sync.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Arial, Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span&gt;&lt;SPAN style="TEXT-ALIGN: left; FONT-SIZE: 12px" class=Apple-style-span&gt;
&lt;P style="MARGIN: 10px 0px"&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/"&gt;&lt;IMG style="MARGIN: 0.5em; MAX-WIDTH: 100%" title=Logo border=0 alt=Logo src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width=240 height=57&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="MARGIN: 10px 0px"&gt;For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit&lt;SPAN class=Apple-converted-space&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/"&gt;&lt;FONT color=#0066cc&gt;http://www.thewahlingroup.com/&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146175" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 3 Released – Exciting Stuff Here!</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/10/silverlight-3-released-exciting-stuff-here.aspx</link><pubDate>Fri, 10 Jul 2009 17:54:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7144924</guid><dc:creator>dwahlin</dc:creator><slash:comments>9</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7144924</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/10/silverlight-3-released-exciting-stuff-here.aspx#comments</comments><description>&lt;IMG style="MARGIN: 0px; DISPLAY: inline" align=right src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_460CA5F1.png" width=176 height=184 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_460CA5F1.png"&gt; 
&lt;P&gt;&lt;A href="http://silverlight.net/getstarted/" target=_blank mce_href="http://silverlight.net/getstarted/"&gt;Silverlight 3&lt;/A&gt; is now officially released and available for download!&amp;nbsp; It’s definitely exciting for me personally because my company has been working on a Silverlight 3 client application for the past few months and really enjoyed the new features.&amp;nbsp; Here are some of the key features Silverlight 3 brings to the table:&lt;/P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=975&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Out of Browser Support&lt;/STRONG&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;Users can run a Silverlight 3 application in the browser or run it directly from the desktop even when they’re not connected to the Internet.&amp;nbsp; This supports several sync scenarios that can be useful when a connection isn’t always available.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Enhanced Graphics Support&lt;/STRONG&gt; &lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;New features include GPU acceleration, perspective 3D support, bitmap and pixel APIs for dynamically generating images, videos, etc.&amp;nbsp; Animations can also be eased in and out and perform many other cool effects.&amp;nbsp; Pixel shaders allow objects to have different effects applied to them such as shadows and blurs.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;New Controls&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;Silverlight 3 provides many new controls that can be used to build solid line of business (LOB) applications.&amp;nbsp; Controls can be bound to each other using element to element binding and validation can also be perform more easily.&amp;nbsp; Several new controls are also available in the Silverlight 3 toolkit released by Microsoft.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Better Navigation &lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;Navigating between Silverlight “pages” is now built in along with better search engine optimization (SEO) support and deep linking.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Enhanced Text&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;Rendering&lt;/STRONG&gt; &lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;One knock against Silverlight 2 was that text didn’t render as clearly as it should in some situations.&amp;nbsp; Silverlight 3 includes a major update to the text rendering engine.&amp;nbsp; Text renders very crisply now.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Enhanced Styles&lt;/STRONG&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;Silverlight 3 provides merged dictionary support allowing multiple style files to be merged into an application (similar to how a standard web application can use multiple CSS files).&amp;nbsp; This allows themes and other styles to be switched much more easily.&amp;nbsp; Styles can also be based on other styles (similar to inheritance in OO languages).&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Faster Transfer of Data&lt;/STRONG&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;Windows Communication Foundation (WCF) support was available in Silverlight 2 but Silverlight 3 now adds support for binary XML serialization which allows data to be transferred between a Silverlight application and a WCF service much faster than before.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Assembly Caching&lt;/STRONG&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;Silverlight 3 allows developers to store assemblies on a central company server and Silverlight 3 applications can then download them as needed rather than downloading everything up front in a single .xap file.&amp;nbsp; This can significantly speed-up application load times.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;Enhanced Networking Support&lt;/STRONG&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;A new client networking (ClientHttp) stack is available that supports more verbs than simply GET/POST.&amp;nbsp; Applications that fully leverage REST APIs will benefit from this new feature.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=189&gt;&lt;STRONG&gt;HD Media Support&lt;/STRONG&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD vAlign=top width=784&gt;Silverlight 3 includes support for GPU acceleration (as mentioned earlier) as well as 1080p HD videos to be played over the web.&amp;nbsp; New codec support for H.264, AAC audio and MPEG-4 content is also included.&amp;nbsp; If you need to provide media solutions then Silverlight covers all of the major scenarios now.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;BR&gt;Some other changes to Visual Studio and Silverlight applications in general:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The Visual Studio 2008 designer has been removed for Silverlight 3 applications.&amp;nbsp; A lot of developers turned it off anyway so all of the dev efforts have gone into the designer that’ll be available in Visual Studio 2010.&amp;nbsp; Expression Blend 3 can also be used of course. &lt;/LI&gt;
&lt;LI&gt;The Silverlight ASP.NET server control isn’t used now.&amp;nbsp; It simply emitted the object and associated params tags anyway. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=92e1db7a-5d36-449b-8c6b-d25f078f3609&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=92e1db7a-5d36-449b-8c6b-d25f078f3609&amp;amp;displaylang=en"&gt;Expression Blend 3&lt;/A&gt; has also been released (currently a release candidate) along with a new feature called SketchFlow.&amp;nbsp; SketchFlow allows application prototypes and mockups to be created more easily in order to get customer feedback…very cool if you haven’t seen it.&amp;nbsp; Although I rarely used Blend for coding previously, it now includes code intellisense which is a nice feature to have and adds support for behaviors, importing Adobe Photoshop and Illustrator files and integrating sample data into applications. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;To get started with Silverlight 3 visit &lt;A title=http://silverlight.net/getstarted/ href="http://silverlight.net/getstarted/" mce_href="http://silverlight.net/getstarted/"&gt;http://silverlight.net/getstarted/&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.amazon.com/gp/product/images/0981511805/sr=8-6/qid=1247275759/ref=dp_image_0?ie=UTF8&amp;amp;n=283155&amp;amp;s=books&amp;amp;qid=1247275759&amp;amp;sr=8-6" mce_href="http://www.amazon.com/gp/product/images/0981511805/sr=8-6/qid=1247275759/ref=dp_image_0?ie=UTF8&amp;amp;n=283155&amp;amp;s=books&amp;amp;qid=1247275759&amp;amp;sr=8-6"&gt;&lt;IMG style="DISPLAY: inline; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px" border=0 alt="Silverlight 3 Jumpstart" src="http://ecx.images-amazon.com/images/I/51QdRgcgaOL._SL500_AA240_.jpg" width=240 height=240 mce_src="http://ecx.images-amazon.com/images/I/51QdRgcgaOL._SL500_AA240_.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you’re interested in a focused look at some of the new features in Silverlight 3 check out David Yack’s new &lt;A href="http://www.amazon.com/Silverlight-3-Jumpstart-David-Yack/dp/0981511805/ref=sr_1_6?ie=UTF8&amp;amp;s=books&amp;amp;qid=1247275759&amp;amp;sr=8-6" target=_blank mce_href="http://www.amazon.com/Silverlight-3-Jumpstart-David-Yack/dp/0981511805/ref=sr_1_6?ie=UTF8&amp;amp;s=books&amp;amp;qid=1247275759&amp;amp;sr=8-6"&gt;Silverlight 3 JumpStart&lt;/A&gt; Book.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Arial, Helvetica; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span&gt;&lt;SPAN style="TEXT-ALIGN: left; FONT-SIZE: 12px" class=Apple-style-span&gt;
&lt;P style="MARGIN: 10px 0px"&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/"&gt;&lt;IMG style="MARGIN: 0.5em; MAX-WIDTH: 100%" title=Logo border=0 alt=Logo src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width=240 height=57&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="MARGIN: 10px 0px"&gt;For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit&lt;SPAN class=Apple-converted-space&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A style="COLOR: rgb(51,153,255)" href="http://www.thewahlingroup.com/"&gt;&lt;FONT color=#0066cc&gt;http://www.thewahlingroup.com/&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7144924" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Validating Properties in Silverlight Classes</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/07/validating-properties-in-silverlight-classes.aspx</link><pubDate>Tue, 07 Jul 2009 16:35:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7143328</guid><dc:creator>dwahlin</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7143328</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/07/validating-properties-in-silverlight-classes.aspx#comments</comments><description>&lt;P&gt;Silverlight classes rely on the &lt;A href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(VS.95).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(VS.95).aspx"&gt;INotifyPropertyChanged interface&lt;/A&gt; and associated PropertyChanged event it contains to ensure that data binding stays up-to-date in an application.&amp;nbsp; It’s a great feature because you don’t have to worry about ensuring that changes to object properties are propagated back to controls….Silverlight handles refreshing control values for you automatically as long as the class that’s being data bound implements INotifyPropertyChanged and property set blocks raise the event.&amp;nbsp; I use a fairly standard pattern for defining my properties and raising property changed events (there are several options for doing this…see a &lt;A href="http://compositeextensions.codeplex.com/Thread/View.aspx?ThreadId=53731" target=_blank mce_href="http://compositeextensions.codeplex.com/Thread/View.aspx?ThreadId=53731"&gt;nice list here&lt;/A&gt;).&amp;nbsp; Here’s an example of a property: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Job &lt;/SPAN&gt;CurrentJob
{
    &lt;SPAN style="COLOR: blue"&gt;get
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;_CurrentJob;
    }
    &lt;SPAN style="COLOR: blue"&gt;set
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;value &lt;/SPAN&gt;!= _CurrentJob)
        {
            _CurrentJob = &lt;SPAN style="COLOR: blue"&gt;value&lt;/SPAN&gt;;
            OnPropertyChanged(&lt;SPAN style="COLOR: #a31515"&gt;"CurrentJob"&lt;/SPAN&gt;);
        }
    }
}&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;The problem is that I tend to change property names from time to time within an application and use the Visual Studio refactor feature to do it.&amp;nbsp; This works great for changing the property name or field name but doesn’t change the quoted value passed to OnPropertyChanged.&amp;nbsp; I’ve run into a few issues where I missed renaming the string value and decided that I needed to be more proactive with validating the value.&amp;nbsp; I ended up going with the following validation code after looking at a few options: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;protected void &lt;/SPAN&gt;OnPropertyChanged(&lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;propertyName)
{
    CheckPropertyExists(propertyName);

    &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.PropertyChanged != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)
    {
        &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.PropertyChanged.Invoke(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;PropertyChangedEventArgs&lt;/SPAN&gt;(propertyName));
    }
}

[&lt;SPAN style="COLOR: #2b91af"&gt;Conditional&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"DEBUG"&lt;/SPAN&gt;)]
&lt;SPAN style="COLOR: blue"&gt;private void &lt;/SPAN&gt;CheckPropertyExists(&lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;propertyName)
{
    &lt;SPAN style="COLOR: #2b91af"&gt;Type &lt;/SPAN&gt;type = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.GetType();
    &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(type.GetProperty(propertyName) == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)
    {
        &lt;SPAN style="COLOR: blue"&gt;string &lt;/SPAN&gt;errorMessage = &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;.Format(&lt;SPAN style="COLOR: #a31515"&gt;"Invalid property found: {0} in {1}"&lt;/SPAN&gt;, propertyName, type.FullName);
        &lt;SPAN style="COLOR: #2b91af"&gt;Debug&lt;/SPAN&gt;.Assert(&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;, errorMessage);
    }
}&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;BR&gt;Originally I used #if..#endif statements to conditionally add or take out the CheckPropertyExists method until I came across a &lt;A href="http://joshsmithonwpf.wordpress.com/2007/08/29/a-base-class-which-implements-inotifypropertychanged/" target=_blank mce_href="http://joshsmithonwpf.wordpress.com/2007/08/29/a-base-class-which-implements-inotifypropertychanged/"&gt;nice post by Josh Smith&lt;/A&gt; where he used the Conditional attribute in a WPF application.&amp;nbsp; If you’re new to it, the compiler will leave CheckPropertyExists in the compiled code if you’re in debug mode.&amp;nbsp; If you switch to release mode it’ll take it out which is good since at that point you wouldn’t want to slow down the application with the reflection statements.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;With the CheckPropertyExists method in place I now have an easy way to know if I missed renaming a property value that’s passed to OnPropertyChanged which saves a few headaches.&amp;nbsp; I put the code in my ViewModelBase class so I only have to write it once and have it available for just about everything I do in Silverlight.&amp;nbsp; Here’s the message that I get if there’s a problem: &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_6D437274.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_6D437274.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_320F96A9.png" width=719 height=475 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_320F96A9.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Update:&amp;nbsp; The same day I posted this I ran into a mis-named property.&amp;nbsp; The assert message popped up and I fixed it within a matter of seconds instead of searching through the code for minutes (or longer) to locate the problem.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.thewahlingroup.com/"&gt;&lt;IMG title=Logo border=0 alt=Logo src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width=240 height=57&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit &lt;A href="http://www.thewahlingroup.com/"&gt;&lt;FONT color=#0066cc&gt;http://www.thewahlingroup.com/&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7143328" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Creating a ComboBox Style AutoCompleteBox Control in Silverlight</title><link>http://weblogs.asp.net/dwahlin/archive/2009/07/06/creating-an-combobox-style-autocompletebox-control-in-silverlight.aspx</link><pubDate>Mon, 06 Jul 2009 20:40:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7141327</guid><dc:creator>dwahlin</dc:creator><slash:comments>7</slash:comments><wfw:commentRss>http://weblogs.asp.net/dwahlin/rsscomments.aspx?PostID=7141327</wfw:commentRss><comments>http://weblogs.asp.net/dwahlin/archive/2009/07/06/creating-an-combobox-style-autocompletebox-control-in-silverlight.aspx#comments</comments><description>&lt;P&gt;Silverlight’s AutoCompleteBox control provides a nice way to filter a list of items as the user types into a TextBox.&amp;nbsp; If you haven’t used it before you can see an example &lt;A href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" target=_blank mce_href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html"&gt;here&lt;/A&gt;.&amp;nbsp; In a &lt;A href="http://weblogs.asp.net/dwahlin/archive/2009/06/30/handling-events-within-silverlight-control-templates-autocompletebox-example.aspx" target=_blank mce_href="http://weblogs.asp.net/dwahlin/archive/2009/06/30/handling-events-within-silverlight-control-templates-autocompletebox-example.aspx"&gt;previous post&lt;/A&gt; I showed how you could customize AutoCompleteBox to make it look and feel more like an editable ComboBox so that users can click a down arrow to see the list of items and also filter the items by typing into the TextBox.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/dwahlin/image_79BB5D52.png" mce_href="http://weblogs.asp.net/blogs/dwahlin/image_79BB5D52.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_6B10B16D.png" width=493 height=96 mce_src="http://weblogs.asp.net/blogs/dwahlin/image_thumb_6B10B16D.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The solution I wrote about in the previous post relied upon a custom control template which works fine but you may want to encapsulate that functionality into a re-useable control so that you don’t have to worry about adding the template into each application project.&amp;nbsp; Fortunately, it’s not too hard to derive from AutoCompleteBox and create a custom control.&amp;nbsp; Here are the steps I went through to build a derived version of AutoCompleteBox that I call AutoCompleteComboBox. &lt;BR&gt;&lt;/P&gt;
&lt;H3&gt;Step 1: Create a Silverlight Class Library&lt;/H3&gt;
&lt;P&gt;Create a new Silverlight class library and add a class named AutoCompleteComboBox into it.&amp;nbsp; Derive the class from AutoCompleteBox: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public partial class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AutoCompleteComboBox &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;AutoCompleteBox
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Once the class is created add a folder into the project named &lt;STRONG&gt;Themes&lt;/STRONG&gt; that contains a file named &lt;STRONG&gt;Generic.xaml&lt;/STRONG&gt; in it.&amp;nbsp; Right-click on Generic.xaml, select Properties and ensure that the Build Action is set to Resource.&lt;/P&gt;
&lt;H3&gt;Step 2: Define the Control’s Template&lt;/H3&gt;
&lt;P&gt;Since AutoCompleteComboBox needs to look like a ComboBox I took a template available in one of the AutoCompleteBox &lt;A href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" target=_blank mce_href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html"&gt;toolkit samples&lt;/A&gt; that added the drop down arrow (normally seen on the ComboBox control) and tweaked it a little bit.&amp;nbsp; The template code needs to go in the Generic.xaml file that was created in the previous step.&amp;nbsp; Here’s what my Generic.xaml file looks like.&amp;nbsp; You’ll see that there’s a ComboToggleButton style which is referenced by the AutoCompleteComboBox style. &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary 
  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"
  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;system&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="clr-namespace:System;assembly=mscorlib"
  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;custom&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="clr-namespace:MyCustomControls"&amp;gt;
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;&amp;lt;!-- AutoCompleteBox Styles --&amp;gt;

    &amp;lt;!-- Custom toggle button template --&amp;gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ComboToggleButton" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButton"&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Foreground" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FF333333"/&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="IsTabStop" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="False" /&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Background" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FF1F3B53"/&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Padding" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0"/&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Template"&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ControlTemplate &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButton"&amp;gt;
                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Grid&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Rectangle &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Fill&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Transparent" /&amp;gt;
                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ContentPresenter
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="contentPresenter"
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}"
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ContentTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ContentTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}"
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;HorizontalContentAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}"
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;VerticalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;VerticalContentAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}"
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Padding&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}"/&amp;gt;
                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Grid&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;&amp;lt;!-- Custom control template used for the IntelliSense sample --&amp;gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="custom:AutoCompleteComboBox"&amp;gt;

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;&amp;lt;!-- ComboBox should not perform text completion by default --&amp;gt;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="IsTextCompletionEnabled" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="False" /&amp;gt;

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;&amp;lt;!-- The minimum prefix length should be 0 for combo box scenarios --&amp;gt;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="MinimumPrefixLength" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1" /&amp;gt;

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;&amp;lt;!-- Regular template values --&amp;gt;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Background" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FF1F3B53"/&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="IsTabStop" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="False" /&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="HorizontalContentAlignment" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Left"/&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="BorderBrush"&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;LinearGradientBrush &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;EndPoint&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0.5,1" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;StartPoint&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0.5,0"&amp;gt;
                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;GradientStop &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FFA3AEB9" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Offset&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0"/&amp;gt;
                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;GradientStop &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FF8399A9" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Offset&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0.375"/&amp;gt;
                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;GradientStop &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FF718597" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Offset&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0.375"/&amp;gt;
                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;GradientStop &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FF617584" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Offset&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1"/&amp;gt;
                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;LinearGradientBrush&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Template"&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ControlTemplate &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="custom:AutoCompleteComboBox"&amp;gt;
                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Grid &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Padding&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}"&amp;gt;
                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBox &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;IsTabStop&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="True" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Text" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;TextBoxStyle&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0,0,0,2" /&amp;gt;
                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ToggleButton &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButton"
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Right"
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;VerticalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Center"
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ComboToggleButton&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}"
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;BorderBrush&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Black" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;BorderThickness&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1,0,0,0"
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;HorizontalContentAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Center" 
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Background&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="LightGray" 
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="16" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="16"&amp;gt;
                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ToggleButton.Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Path &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="BtnArrow" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="4" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="8" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Stretch&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Uniform" 
                                      &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Data&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z " 
                                          &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0,0,6,0" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Right"&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Path.Fill&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SolidColorBrush &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="BtnArrowColor" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#FF333333"/&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Path.Fill&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Path.RenderTransform&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ScaleTransform &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonScale" /&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Path.RenderTransform&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Path&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ToggleButton.Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ToggleButton&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Popup &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Popup"&amp;gt;
                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupBorder" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Stretch" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Opacity&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1.0" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;BorderThickness&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0"&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border.RenderTransform&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TranslateTransform &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;X&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="2" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Y&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="-2" /&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border.RenderTransform&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border.Background&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SolidColorBrush &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="#11000000" /&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border.Background&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ListBox &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Selector" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ScrollViewer.HorizontalScrollBarVisibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Auto" 
                                                 &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ScrollViewer.VerticalScrollBarVisibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Auto" 
                                                 &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateBinding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}" /&amp;gt;
                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Popup&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateManager.VisualStateGroups&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="FocusStates"&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup.Transitions&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualTransition &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;GeneratedDuration&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0:0:0.2" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonOver" /&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualTransition &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;GeneratedDuration&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0:0:0.2" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonOut" /&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup.Transitions&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonOver"&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DoubleAnimation &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonScale" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ScaleX" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1.3" /&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DoubleAnimation &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonScale" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ScaleY" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1.3" /&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonOut"&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DoubleAnimation &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonScale" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ScaleX" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1" /&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DoubleAnimation &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ToggleButtonScale" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ScaleY" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1" /&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupStates"&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup.Transitions&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualTransition &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;GeneratedDuration&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0:0:0.4" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupOpened" /&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualTransition &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;GeneratedDuration&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0:0:0.2" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupClosed" /&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup.Transitions&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupOpened"&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DoubleAnimation &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupBorder" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Opacity" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="1.0" /&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupClosed"&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DoubleAnimation &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="PopupBorder" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Opacity" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;To&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0.0" /&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ValidationStates"&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Valid" /&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="InvalidUnfocused"&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ObjectAnimationUsingKeyFrames &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ValidationErrorElement" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Visibility"&amp;gt;
                                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;KeyTime&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0"&amp;gt;
                                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Visibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Visible&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Visibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ObjectAnimationUsingKeyFrames&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="InvalidFocused"&amp;gt;
                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ObjectAnimationUsingKeyFrames &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ValidationErrorElement" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Visibility"&amp;gt;
                                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;KeyTime&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0"&amp;gt;
                                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Visibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Visible&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Visibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ObjectAnimationUsingKeyFrames&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ObjectAnimationUsingKeyFrames &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="validationTooltip" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Storyboard.TargetProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="IsOpen"&amp;gt;
                                            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;KeyTime&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0"&amp;gt;
                                                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                                    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;system&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Boolean&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;True&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;system&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Boolean&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DiscreteObjectKeyFrame&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ObjectAnimationUsingKeyFrames&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Storyboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualState&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;VisualStateManager.VisualStateGroups&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Grid&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
                &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;

&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;H3&gt;Step 3: Add a TemplatePart Attribute&lt;/H3&gt;
&lt;P&gt;Go back to the AutoCompleteComboBox class created in Step 1 and add a TemplatePart attribute on it that references the ToggleButton control name (which will represent the drop down arrow) defined in the control template.&amp;nbsp; Template parts are used to be able to reference the different controls defined in the template.&amp;nbsp; Although TemplatePart’s Name property can be given a direct string value, I followed the convention seen in Silverlight controls and used a constant to define the name value.&lt;/P&gt;&lt;PRE class=code&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TemplatePart&lt;/SPAN&gt;(Name = &lt;SPAN style="COLOR: #2b91af"&gt;AutoCompleteComboBox&lt;/SPAN&gt;.ElementToggleButton, Type = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;ToggleButton&lt;/SPAN&gt;))]
&lt;SPAN style="COLOR: blue"&gt;public partial class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AutoCompleteComboBox &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;AutoCompleteBox
&lt;/SPAN&gt;{
    &lt;SPAN style="COLOR: blue"&gt;private const string &lt;/SPAN&gt;ElementToggleButton = &lt;SPAN style="COLOR: #a31515"&gt;"ToggleButton"&lt;/SPAN&gt;;
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;H3&gt;Step 4: Add the ToggleButton Property&lt;/H3&gt;
&lt;P&gt;Add a ToggleButton property into the AutoCompleteComboBox class as shown next.&amp;nbsp; You can call it whatever you want but I like to keep things simple and call it what it really is….a ToggleButton.&amp;nbsp; The event handlers referenced in the code below are shown in Step 6. &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;#region &lt;/SPAN&gt;Template Parts

&lt;SPAN style="COLOR: #2b91af"&gt;ToggleButton &lt;/SPAN&gt;_ToggleButton;

&lt;SPAN style="COLOR: #2b91af"&gt;ToggleButton &lt;/SPAN&gt;ToggleButton
{
    &lt;SPAN style="COLOR: blue"&gt;get &lt;/SPAN&gt;{ &lt;SPAN style="COLOR: blue"&gt;return &lt;/SPAN&gt;_ToggleButton; }
    &lt;SPAN style="COLOR: blue"&gt;set
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(_ToggleButton != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)
        {
            _ToggleButton.Click -= &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventHandler&lt;/SPAN&gt;(ToggleButton_Click);
            _ToggleButton.MouseEnter -= &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseEventHandler&lt;/SPAN&gt;(ToggleButton_MouseEnter);
            _ToggleButton.MouseLeave -= &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseEventHandler&lt;/SPAN&gt;(ToggleButton_MouseLeave);
        }

        _ToggleButton = &lt;SPAN style="COLOR: blue"&gt;value&lt;/SPAN&gt;;

        &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(_ToggleButton != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)
        {
            _ToggleButton.Click += &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventHandler&lt;/SPAN&gt;(ToggleButton_Click);
            _ToggleButton.MouseEnter += &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseEventHandler&lt;/SPAN&gt;(ToggleButton_MouseEnter);
            _ToggleButton.MouseLeave += &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseEventHandler&lt;/SPAN&gt;(ToggleButton_MouseLeave);
        }
    }
}

&lt;SPAN style="COLOR: blue"&gt;#endregion&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;
&lt;H3&gt;Step 5: Set the DefaultStyleKey for the AutoCompleteComboBox Control&lt;/H3&gt;
&lt;P&gt;Next you need to tell the AutoCompleteComboBox to use the Style you defined in Generic.xaml instead of the default style used by AutoCompleteBox.&amp;nbsp; Do this by adding the following constructor into the class (which also adds code to call the ApplyTemplate class shown in the next step): &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public &lt;/SPAN&gt;AutoCompleteComboBox()
{
    &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.DefaultStyleKey = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;AutoCompleteComboBox&lt;/SPAN&gt;);
    Loaded += (sender, e) =&amp;gt; ApplyTemplate();
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR&gt;&lt;/P&gt;
&lt;H3&gt;Step 6: Override ApplyTemplate and Handle Events&lt;/H3&gt;
&lt;P&gt;We’re almost there! The next thing that needs to be done is to override the control’s OnApplyTemplate method.&amp;nbsp; We need to do this so that the ToggleButton can be injected into the process so that we can handle the user clicking on it to show all of the items like a normal ComboBox would do.&amp;nbsp; Here’s the remaining code that needs to be added into the class.&amp;nbsp; &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public override void &lt;/SPAN&gt;OnApplyTemplate()
{
    &lt;SPAN style="COLOR: blue"&gt;base&lt;/SPAN&gt;.OnApplyTemplate();
    ToggleButton = GetTemplateChild(ElementToggleButton) &lt;SPAN style="COLOR: blue"&gt;as &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ToggleButton&lt;/SPAN&gt;;
}

&lt;SPAN style="COLOR: blue"&gt;void &lt;/SPAN&gt;ToggleButton_MouseEnter(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;sender, &lt;SPAN style="COLOR: #2b91af"&gt;MouseEventArgs &lt;/SPAN&gt;e)
{
    &lt;SPAN style="COLOR: #2b91af"&gt;VisualStateManager&lt;/SPAN&gt;.GoToState(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"ToggleButtonOver"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;);
}

&lt;SPAN style="COLOR: blue"&gt;void &lt;/SPAN&gt;ToggleButton_MouseLeave(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;sender, &lt;SPAN style="COLOR: #2b91af"&gt;MouseEventArgs &lt;/SPAN&gt;e)
{
    &lt;SPAN style="COLOR: #2b91af"&gt;VisualStateManager&lt;/SPAN&gt;.GoToState(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"ToggleButtonOut"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;);
}

&lt;SPAN style="COLOR: blue"&gt;void &lt;/SPAN&gt;ToggleButton_Click(&lt;SPAN style="COLOR: blue"&gt;object &lt;/SPAN&gt;sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs &lt;/SPAN&gt;e)
{
    &lt;SPAN style="COLOR: blue"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt;.IsNullOrEmpty(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.SearchText))
    {
        &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.Text = &lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt;.Empty;
    }
    &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.IsDropDownOpen = !&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.IsDropDownOpen;
}&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;&lt;/P&gt;This code accesses the ToggleButton control defined in the Generic.xaml template using the base class’s GetTemplateChild method.&amp;nbsp; Once the ToggleButton control is found it’s assigned to the ToggleButton property of our control which handles hooking up the Click, MouseEnter and MouseLeave events.&amp;nbsp; The ToggleButton_Click event handler does the magic of making the AutoCompleteComboBox control look and feel like a standard ComboBox. &lt;BR&gt;
&lt;H3&gt;&lt;BR&gt;Step 7: Use the AutoCompleteComboBox Control&lt;/H3&gt;
&lt;P&gt;Once the custom control is finished and you successfully build it you can use the control in a Silverlight application.&amp;nbsp; To do that, create a Silverlight application project and reference the control project created in Step 1 (or reference the dll that’s generated by the project).&amp;nbsp; Within the XAML for your Silverlight application add a reference to the control’s namespace and assembly:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Usercontrol&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Class&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="SilverlightApplication1"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;    xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;controls&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="clr-namespace:YourCustomControlNamespace;assembly=YourCustomControlAssemblyName"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;UserControl&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR&gt;Once the assembly and namespace are referenced you can define the control and bind items to it using it’s ItemSource property: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;c&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ontrols&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;AutoCompleteComboBox &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ItemsSource&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Jobs&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;}" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;    Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="5,0,5,10" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="150"  &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Left"
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;MinimumPopulateDelay&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;MinimumPrefixLength&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="0" /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;If I had to pick out the key parts from these steps they’d be creating the Generic.xaml file, adding the TemplatePart attribute, setting the control’s DefaultStyleKey, overriding ApplyTemplate and calling GetTemplateChild to locate the ToggleButton control.&amp;nbsp; These changes allow the AutoCompleteComboBox to look like a regular ComboBox while still allowing the user to type into it to filter the items.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.xmlforasp.net/CodeBank/Download/Blog/Silverlight3/AutoCompleteComboBox.zip" mce_href="http://www.xmlforasp.net/CodeBank/Download/Blog/Silverlight3/AutoCompleteComboBox.zip"&gt;Download Code&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.thewahlingroup.com/"&gt;&lt;IMG title=Logo border=0 alt=Logo src="http://weblogs.asp.net/blogs/dwahlin/Logo_702D5F60.jpg" width=240 height=57&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit &lt;A href="http://www.thewahlingroup.com/"&gt;&lt;FONT color=#0066cc&gt;http://www.thewahlingroup.com/&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7141327" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/dwahlin/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/dwahlin/archive/tags/Silverlight/default.aspx">Silverlight</category></item></channel></rss>
