<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Delay's Blog</title><link>http://blogs.msdn.com/delay/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Blogging code samples stays easy [Update to free ConvertClipboardRtfToHtmlText tool and source code for Visual Studio 2010!]</title><link>http://blogs.msdn.com/delay/archive/2009/12/20/blogging-code-samples-stays-easy-update-to-free-convertclipboardrtftohtmltext-tool-and-source-code-for-visual-studio-2010.aspx</link><pubDate>Mon, 21 Dec 2009 06:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9939436</guid><dc:creator>Delay</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/delay/comments/9939436.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9939436</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;A big part of my blog is sharing code and so most of the posts I write include sample source. Therefore, it's pretty important to me that the code I share be easy for readers to understand and use. For me, that means I want it to be static, syntax-highlighted, and in text form so it's copy+paste-able and indexable by search engines. &lt;/P&gt;
&lt;P&gt;I'm a big fan of keeping things simple and avoiding dependencies, so I ended up writing a very simple tool about two years ago called &lt;CODE&gt;ConvertClipboardRtfToHtmlText&lt;/CODE&gt;. As you can see from the &lt;A href="http://blogs.msdn.com/delay/archive/2008/03/13/blogging-code-samples-should-be-easy-free-convertclipboardrtftohtmltext-tool-and-source-code.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/03/13/blogging-code-samples-should-be-easy-free-convertclipboardrtftohtmltext-tool-and-source-code.aspx"&gt;original ConvertClipboardRtfToHtmlText post&lt;/A&gt; and the &lt;A href="http://blogs.msdn.com/delay/archive/2008/04/02/blogging-code-samples-a-tad-more-easily-updated-free-convertclipboardrtftohtmltext-tool-and-source-code.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/04/02/blogging-code-samples-a-tad-more-easily-updated-free-convertclipboardrtftohtmltext-tool-and-source-code.aspx"&gt;subsequent follow-up&lt;/A&gt;, it's a very simple tool intended for a very specific scenario. That said, it works beautifully for my purposes and I've used it to blog every snippet of source code since then! &lt;/P&gt;
&lt;P&gt;So I was surprised and a little disappointed when it stopped working recently... Why? Because I switched to &lt;A href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Visual Studio 2010 (Beta 2)&lt;/A&gt; and they've changed the &lt;A href="http://en.wikipedia.org/wiki/Rich_Text_Format" mce_href="http://en.wikipedia.org/wiki/Rich_Text_Format"&gt;RTF&lt;/A&gt; clipboard format slightly with that release. Now, while I'm sure VS 2010's RTF is still 100% legal RTF, it's different enough from VS 2008's output that &lt;CODE&gt;ConvertClipboardRtfToHtmlText&lt;/CODE&gt; chokes on it. Clearly, it was time to dust off the source code and make it work again! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P&gt;Not surprisingly, the update process was quite painless - and by tweaking the code slightly, I've arrived at an implementation that works well for &lt;STRONG&gt;both&lt;/STRONG&gt; versions of Visual Studio: 2008 &lt;STRONG&gt;and&lt;/STRONG&gt; 2010! The source code download includes a VS 2010 solution and project, but takes advantage of the multi-targeting capabilities of Visual Studio to compile for the .NET 2.0 Framework, ensuring that the resulting executable runs pretty much everywhere. &lt;/P&gt;
&lt;P&gt;As long as I was touching the code, I added the following simple banner text: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE&gt;ConvertClipboardRtfToHtmlText
Version 2009-12-19 - http://blogs.msdn.com/delay/

Converts the Visual Studio 2008/2010 RTF clipboard format to HTML by replacing
the RTF clipboard contents with its HTML representation in text form.

Instructions for use:
1. Copy syntax-highlighted text to the clipboard in Visual Studio
2. Run ConvertClipboardRtfToHtmlText (which has no UI and exits immediately)
3. Paste HTML text into an editor, web page, blog post, etc.&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So if you're in the market for a nice way to blog code and you're using Visual Studio 2008 or 2010, maybe &lt;CODE&gt;ConvertClipboardRtfToHtmlText&lt;/CODE&gt; can help you out! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/ConvertClipboardRtfToHtmlText/ConvertClipboardRtfToHtmlText.zip" mce_href="http://cesso.org/Samples/ConvertClipboardRtfToHtmlText/ConvertClipboardRtfToHtmlText.zip"&gt;[Click here to download the ConvertClipboardRtfToHtmlText tool along with its complete source code.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the complete source code for &lt;CODE&gt;ConvertClipboardRtfToHtmlText&lt;/CODE&gt;, provided by - you guessed it! - &lt;CODE&gt;ConvertClipboardRtfToHtmlText&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System.Collections.Generic;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System.Drawing;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System.Text;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System.Windows.Forms;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// NOTE: This is NOT a general-purpose RTF-to-HTML converter! It works well
// enough on the input I've tried, but may break in other scenarios.
// TODO: Convert into a real application with a notify icon and hotkey.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ConvertClipboardRtfToHtmlText
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ConvertClipboardRtfToHtmlText
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;const&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; colorTbl = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"\\colortbl;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;const&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; colorFieldTag = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"cf"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;const&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; tabExpansion = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"    "&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;

        [&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;STAThread&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;]
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Main()
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"ConvertClipboardRtfToHtmlText"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Version 2009-12-19 - http://blogs.msdn.com/delay/"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine();
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Converts the Visual Studio 2008/2010 RTF clipboard format to HTML by replacing"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"the RTF clipboard contents with its HTML representation in text form."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine();
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Instructions for use:"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"1. Copy syntax-highlighted text to the clipboard in Visual Studio"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"2. Run ConvertClipboardRtfToHtmlText (which has no UI and exits immediately)"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.WriteLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"3. Paste HTML text into an editor, web page, blog post, etc."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Clipboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.ContainsText(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;TextDataFormat&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Rtf))
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Create color table, populate with default color
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; colors = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt;();
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; defaultColor = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.FromArgb(0, 0, 0);
                colors.Add(defaultColor);

                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get RTF
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; rtf = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Clipboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetText(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;TextDataFormat&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Rtf);

                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Strip meaningless "\r\n" pairs (used by VS 2008)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                rtf = rtf.Replace(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"\r\n"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;""&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);

                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Parse color table
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i = rtf.IndexOf(colorTbl);
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (-1 != i)
                {
                    i += colorTbl.Length;
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;while&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((i &amp;lt; rtf.Length) &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'}'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; != rtf[i]))
                    {
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Add color to color table
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                        SkipExpectedText(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"\\red"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; red = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)ParseNumericField(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i);
                        SkipExpectedText(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"\\green"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; green = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)ParseNumericField(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i);
                        SkipExpectedText(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"\\blue"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; blue = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)ParseNumericField(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i);
                        colors.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Color&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.FromArgb(red, green, blue));
                        SkipExpectedText(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;";"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                    }
                }
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotSupportedException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Missing/unknown colorTbl."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                }

                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Find start of text and parse
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                i = rtf.IndexOf(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"\\fs"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (-1 != i)
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Skip font size tag
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;while&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((i &amp;lt; rtf.Length) &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; != rtf[i]))
                    {
                        i++;
                    }
                    i++;

                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Begin building HTML text
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;StringBuilder&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; sb = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;StringBuilder&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;();
                    sb.AppendFormat(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"&amp;lt;pre&amp;gt;&amp;lt;span style='color:#{0:x2}{1:x2}{2:x2}'&amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
                        defaultColor.R, defaultColor.G, defaultColor.B);
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;while&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (i &amp;lt; rtf.Length)
                    {
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'\\'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == rtf[i])
                        {
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Parse escape code
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                            i++;
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((i &amp;lt; rtf.Length) &amp;amp;&amp;amp;
                                ((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'{'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == rtf[i]) || (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'}'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == rtf[i]) || (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'\\'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == rtf[i])))
                            {
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Escaped '{' or '}' or '\'
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                                sb.Append(rtf[i]);
                            }
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                            {
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Parse tag
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; tagEnd = rtf.IndexOf(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, i);
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (-1 != tagEnd)
                                {
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (rtf.Substring(i, tagEnd - i).StartsWith(colorFieldTag))
                                    {
                                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Parse color field tag
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                                        i += colorFieldTag.Length;
                                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; colorIndex = ParseNumericField(rtf, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i);
                                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((colorIndex &amp;lt; 0) || (colors.Count &amp;lt;= colorIndex))
                                        {
                                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotSupportedException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Bad color index."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                                        }

                                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Change to new color
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                                        sb.AppendFormat(
                                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"&amp;lt;/span&amp;gt;&amp;lt;span style='color:#{0:x2}{1:x2}{2:x2}'&amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
                                            colors[colorIndex].R, colors[colorIndex].G,
                                            colors[colorIndex].B);
                                    }
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"tab"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == rtf.Substring(i, tagEnd - i))
                                    {
                                        sb.Append(tabExpansion);
                                    }
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"par"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == rtf.Substring(i, tagEnd - i))
                                    {
                                        sb.Append(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"\r\n"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                                    }

                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Skip tag
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                                    i = tagEnd;
                                }
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                                {
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotSupportedException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Malformed tag."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                                }
                            }
                        }
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'}'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == rtf[i])
                        {
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Terminal curly; done
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;break&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
                        }
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                        {
                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Normal character; HTML-escape '&amp;lt;', '&amp;gt;', and '&amp;amp;'
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;switch&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (rtf[i])
                            {
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;case&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;lt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;:
                                    sb.Append(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"&amp;amp;lt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;break&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;case&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;:
                                    sb.Append(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"&amp;amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;break&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;case&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'&amp;amp;'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;:
                                    sb.Append(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"&amp;amp;amp;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;break&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
                                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;default&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;:
                                    sb.Append(rtf[i]);
                                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;break&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
                            }
                        }
                        i++;
                    }

                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Trim any trailing empty lines
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;while&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((2 &amp;lt;= sb.Length) &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'\r'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == sb[sb.Length - 2]) &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'\n'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == sb[sb.Length - 1]))
                    {
                        sb.Length -= 2;
                    }

                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Finish building HTML text
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                    sb.Append(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"&amp;lt;/span&amp;gt;&amp;lt;/pre&amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);

                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Update the clipboard text
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Clipboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.SetText(sb.ToString());
                }
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotSupportedException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Missing text section."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                }
            }
        }

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Skip the specified text
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SkipExpectedText(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; s, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; text)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;char&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; c &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; text)
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((s.Length &amp;lt;= i) || (c != s[i]))
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NotSupportedException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Expected text missing."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                }
                i++;
            }
        }

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Parse a numeric field
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ParseNumericField(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; s, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;ref&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; i)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; value = 0;
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;while&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((i &amp;lt; s.Length) &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;char&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.IsDigit(s[i]))
            {
                value *= 10;
                value += s[i] - &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'0'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
                i++;
            }
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; value;
        }
    }
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9939436" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Technical/default.aspx">Technical</category></item><item><title>Wrap music [A more flexible balanced WrapPanel implementation for Silverlight and WPF!]</title><link>http://blogs.msdn.com/delay/archive/2009/12/13/wrap-music-a-more-flexible-balanced-wrappanel-implementation-for-silverlight-and-wpf.aspx</link><pubDate>Mon, 14 Dec 2009 07:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9936399</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9936399.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9936399</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/12/08/that-s-a-wrappanel-and-i-am-outta-here-a-balanced-wrappanel-implementation-for-silverlight-and-wpf.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/12/08/that-s-a-wrappanel-and-i-am-outta-here-a-balanced-wrappanel-implementation-for-silverlight-and-wpf.aspx"&gt;In my last post&lt;/A&gt;, I told the story of a customer who asked for an easy way to make the Silverlight/WPF &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.aspx"&gt;WrapPanel&lt;/A&gt; use all available space to spread its children out evenly instead of bunching them up together. The following sample shows off the default WrapPanel behavior on top - and my alternate &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt; behavior on the bottom: &lt;/P&gt;&lt;IMG alt="BalancedWrapPanel, Horizontal, ItemWidth and ItemHeight set" src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-HorizontalWidth.png" width=386 height=390 mce_src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-HorizontalWidth.png"&gt; 
&lt;P&gt;The default &lt;CODE&gt;WrapPanel&lt;/CODE&gt; behavior fills each horizontal (or vertical) line as much as it can before moving on to the next line, but leaves any extra space at the end of each line. &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt; began as a copy of the WrapPanel code (available as part of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt;) and contains a modified copy of one of the helper methods that instead distributes the unsightly chunk of extra space evenly through the entire column (or row). That was what I set out to do with &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt;, so I was fairly happy with the results. Unfortunately, the customer wasn't 100% satisfied... &lt;/P&gt;
&lt;P&gt;In particular, the desire was for those items in the last line to align with the items above instead of centering like they do in my initial implementation. It's a perfectly reasonable request - and something I thought about when I first started on &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt;! But things are a little tricky because those orderly columns only show up when the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemwidth.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemwidth.aspx"&gt;ItemWidth&lt;/A&gt; and/or &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemheight.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemheight.aspx"&gt;ItemHeight&lt;/A&gt; properties are set. In fact, the &lt;CODE&gt;WrapPanel&lt;/CODE&gt; code doesn't actually have any concept of columns at all! Rather, the columns you see are a natural consequence of the algorithm laying out lots of constant-width items within constant-width bounds. So the columns are very real, but the code doesn't really know anything about them. And they don't even exist when &lt;CODE&gt;ItemWidth&lt;/CODE&gt;/&lt;CODE&gt;ItemHeight&lt;/CODE&gt; aren't set; despite each column of this vertically-oriented &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt; being vertically balanced, there are no overall rows in the horizontal direction because all the elements are different sizes: &lt;/P&gt;&lt;IMG alt="BalancedWrapPanel, Vertical, ItemWidth and ItemHeight not set" src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-VerticalNan.png" width=340 height=349 mce_src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-VerticalNan.png"&gt; 
&lt;P&gt;When I was first thinking about this scenario, it seemed to me that I'd need to add some code to track the columns and then do things differently for the last line in order to keep everything aligned properly. I was afraid this additional code would overly complicate the original sample, and decided not to implement it until and unless someone asked. Besides, it's called &lt;CODE&gt;&lt;STRONG&gt;Balanced&lt;/STRONG&gt;WrapPanel&lt;/CODE&gt;, so it seemed natural that everything should be balanced! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P&gt;But now that I had a specific request, I thought more carefully and realized that not only was it easy to align the last items, but that it was also a tad more efficient to do so! I didn't want to change the current behavior of &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt; (because I think that's what people expect), but I wanted to enable the new aligning behavior, too. So I added a new property to align the last items, but it only works when &lt;CODE&gt;ItemWidth&lt;/CODE&gt;/&lt;CODE&gt;ItemHeight&lt;/CODE&gt; are set (otherwise it has no effect because items can be all different sizes and don't line up to begin with). I considered trying to explain this technicality in the name of the new property, but everything I came up with was long and cumbersome. So the new property is simply named &lt;CODE&gt;AlignLastItems&lt;/CODE&gt; - setting it to &lt;CODE&gt;True&lt;/CODE&gt; changes the first example to look like this instead: &lt;/P&gt;&lt;IMG alt="BalancedWrapPanel, Horizontal, ItemWidth and ItemHeight set, AlignLastItems set" src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-HorizontalAlign.png" width=386 height=376 mce_src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-HorizontalAlign.png"&gt; 
&lt;P&gt;Notice how the basic &lt;CODE&gt;WrapPanel&lt;/CODE&gt; behavior is maintained, but the items are spread out evenly and there are no gaping holes. And there you have it - a balanced &lt;CODE&gt;WrapPanel&lt;/CODE&gt; implementation that should work for most common scenarios. What's more, the customer is satisfied and maybe other folks will start using &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt; in their projects, too! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/BalancedWrapPanel/BalancedWrapPanel.zip" mce_href="http://cesso.org/Samples/BalancedWrapPanel/BalancedWrapPanel.zip"&gt;Click here to download the source code for BalancedWrapPanel and the Silverlight/WPF demo application.&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PS&lt;/STRONG&gt; - Please refer to &lt;A href="http://blogs.msdn.com/delay/archive/2009/12/08/that-s-a-wrappanel-and-i-am-outta-here-a-balanced-wrappanel-implementation-for-silverlight-and-wpf.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/12/08/that-s-a-wrappanel-and-i-am-outta-here-a-balanced-wrappanel-implementation-for-silverlight-and-wpf.aspx"&gt;my previous BalancedWrapPanel post&lt;/A&gt; for information about why I coded it like I did along with some other details. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PPS&lt;/STRONG&gt; - As I mention above, the changes from what I'd already written were surprisingly minimal. Other than adding the &lt;CODE&gt;AlignLastItems&lt;/CODE&gt; DependencyProperty, the only differences are highlighted below: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ArrangeLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; lineStart, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; lineEnd, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;? directDelta, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directMaximum, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; indirectOffset, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; indirectGrowth)
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Orientation&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; o = Orientation;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;bool&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; isHorizontal = o == &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Orientation&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Horizontal;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElementCollection&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; children = Children;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directLength = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a52a2a"&gt;0.0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;    double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; itemCount = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a52a2a"&gt;0.0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; itemLength = isHorizontal ? ItemWidth : ItemHeight;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (AlignLastItems &amp;amp;&amp;amp; !itemLength.IsNaN())
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Length is easy to calculate in this case
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        itemCount = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Math&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Floor(directMaximum / itemLength);
        directLength = itemCount * itemLength;
    }
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Make first pass to calculate the slack space
&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #000000"&gt;        itemCount = lineEnd - lineStart;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;
        for&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; index = lineStart; index &amp;lt; lineEnd; index++)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get the size of the element
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element = children[index];
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; elementSize = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(o, element.DesiredSize.Width, element.DesiredSize.Height);

            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Determine if we should use the element's desired size or the
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// fixed item width or height
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directGrowth = directDelta != &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ?
                directDelta.Value :
                elementSize.Direct;

            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Update total length
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            directLength += directGrowth;
        }
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Determine slack
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directSlack = directMaximum - directLength;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directSlackSlice = directSlack / (&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;itemCount&lt;/SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a52a2a"&gt;1.0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directOffset = directSlackSlice;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Make second pass to arrange items
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;for&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; index = lineStart; index &amp;lt; lineEnd; index++)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get the size of the element
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element = children[index];
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; elementSize = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(o, element.DesiredSize.Width, element.DesiredSize.Height);

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Determine if we should use the element's desired size or the
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// fixed item width or height
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directGrowth = directDelta != &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ?
            directDelta.Value :
            elementSize.Direct;

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Arrange the element
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Rect&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; bounds = isHorizontal ?
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Rect&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(directOffset, indirectOffset, directGrowth, indirectGrowth) :
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Rect&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(indirectOffset, directOffset, indirectGrowth, directGrowth);
        element.Arrange(bounds);

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Update offset for next time
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        directOffset += directGrowth + directSlackSlice;
    }
}
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9936399" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category></item><item><title>That's a WrapPanel and I am outta here... [A balanced WrapPanel implementation for Silverlight and WPF!]</title><link>http://blogs.msdn.com/delay/archive/2009/12/08/that-s-a-wrappanel-and-i-am-outta-here-a-balanced-wrappanel-implementation-for-silverlight-and-wpf.aspx</link><pubDate>Wed, 09 Dec 2009 06:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9934427</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9934427.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9934427</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;A customer contacted me a few days ago asking whether there was an easy way to make the Silverlight/WPF &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.aspx"&gt;WrapPanel&lt;/A&gt; use all available space to spread its children out evenly instead of bunching them up against each other as it usually does. Instead of trying to explain what I mean by that, please have a look at the top half of the following screen shot: &lt;/P&gt;&lt;IMG alt="BalancedWrapPanel, Horizontal, ItemWidth and ItemHeight set" src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-HorizontalWidth.png" width=386 height=390 mce_src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-HorizontalWidth.png"&gt; 
&lt;P&gt;The default &lt;CODE&gt;WrapPanel&lt;/CODE&gt; behavior fills each horizontal (or vertical) line as much as it can before moving on to the next line - but it leaves all the extra space at the end of the line. That big, vertical gap of empty space at the right of the colored boxes is a bit unsightly, so what would be nice is if &lt;CODE&gt;WrapPanel&lt;/CODE&gt; distributed the extra space across the &lt;STRONG&gt;entire&lt;/STRONG&gt; line - kind of like you see in the bottom half of the window above! &lt;/P&gt;
&lt;P&gt;My reply to the customer was that I didn't know of a way to do this with &lt;CODE&gt;WrapPanel&lt;/CODE&gt; as-is, but that it should be pretty straightforward to modify the code and &lt;STRONG&gt;add&lt;/STRONG&gt; the balancing logic. Well, I got curious on the bus yesterday, so I went ahead and implemented &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt;, the control I used in the second example above. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/BalancedWrapPanel/BalancedWrapPanel.zip" mce_href="http://cesso.org/Samples/BalancedWrapPanel/BalancedWrapPanel.zip"&gt;Click here to download the source code for BalancedWrapPanel and the Silverlight/WPF demo application.&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To implement this alternate behavior, I started with the &lt;CODE&gt;WrapPanel&lt;/CODE&gt; source code that comes with the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt;. For WPF 3.5 (or Silverlight 4), I needed to copy &lt;CODE&gt;WrapPanel.cs&lt;/CODE&gt;, &lt;CODE&gt;OrientedSize.cs&lt;/CODE&gt;, and &lt;CODE&gt;NumericExtensions.cs&lt;/CODE&gt;. For Silverlight 3 (which doesn't have &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.lengthconverter.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.lengthconverter.aspx"&gt;LengthConverter&lt;/A&gt;) I also needed to copy &lt;CODE&gt;LengthConverter.cs&lt;/CODE&gt; and &lt;CODE&gt;TypeConverters.cs&lt;/CODE&gt;. I renamed "WrapPanel" to "BalancedWrapPanel" everywhere, linked the copied files into a new Visual Studio solution containing sample projects for Silverlight 3 and WPF 3.5, and compiled successfully. After that, it was just a matter of tweaking the code a bit, and I was done! &lt;/P&gt;
&lt;P&gt;I've highlighted my additions to the existing helper method below: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ArrangeLine(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; lineStart, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; lineEnd, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;? directDelta, &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow; COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow; COLOR: #000000"&gt; directMaximum, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; indirectOffset, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; indirectGrowth
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Orientation&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; o = Orientation;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;bool&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; isHorizontal = o == &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Orientation&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Horizontal;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElementCollection&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; children = Children;

&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #008000"&gt;    // Make first pass to calculate the slack space
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directLength = 0.0;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;for&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; index = lineStart; index &amp;lt; lineEnd; index++)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get the size of the element
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element = children[index];
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; elementSize = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(o, element.DesiredSize.Width, element.DesiredSize.Height);

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Determine if we should use the element's desired size or the
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// fixed item width or height
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directGrowth = directDelta != &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ?
            directDelta.Value :
            elementSize.Direct;

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Update total length
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        directLength += directGrowth;
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Determine slack
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directSlack = directMaximum - directLength;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directSlackSlice = directSlack / (lineEnd - lineStart + 1.0);
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directOffset = directSlackSlice;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;

    // Make second pass to arrange items
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;for&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; index = lineStart; index &amp;lt; lineEnd; index++)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get the size of the element
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UIElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element = children[index];
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; elementSize = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OrientedSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(o, element.DesiredSize.Width, element.DesiredSize.Height);

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Determine if we should use the element's desired size or the
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// fixed item width or height
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;double&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; directGrowth = directDelta != &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ?
            directDelta.Value :
            elementSize.Direct;

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Arrange the element
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Rect&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; bounds = isHorizontal ?
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Rect&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(directOffset, indirectOffset, directGrowth, indirectGrowth) :
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Rect&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(indirectOffset, directOffset, indirectGrowth, directGrowth);
        element.Arrange(bounds);

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Update offset for next time
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        directOffset += directGrowth &lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;+ directSlackSlice&lt;/SPAN&gt;;
    }
}
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;That's all there is to it: a few simple changes, a wave of the magic compiler wand, and &lt;STRONG&gt;POOF!&lt;/STRONG&gt; a more pleasing layout for both platforms. &lt;/P&gt;
&lt;P&gt;Woot! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Notes:&lt;/STRONG&gt; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;I could have refactored the method above for a slightly more efficient solution, but decided the code would be easier to understand if I changed as little as possible and kept the edits distinct. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Alternatively, I could have subclassed &lt;CODE&gt;WrapPanel&lt;/CODE&gt; and implemented my changes in &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.arrangeoverride.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.arrangeoverride.aspx"&gt;ArrangeOverride&lt;/A&gt;. This would have had the benefit of requiring fewer files from the Silverlight Toolkit, but would have required somewhat more code on my part. I didn't see a particularly compelling argument for either option, so I chose copy+edit because it demonstrates how really &lt;STRONG&gt;easy&lt;/STRONG&gt; it is to reuse code from the Silverlight Toolkit, because it's more flexible in general, and because it makes it easy to add further enhancements in the future. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;The example screen shot above uses &lt;CODE&gt;WrapPanel&lt;/CODE&gt;'s &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemwidth.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemwidth.aspx"&gt;ItemWidth&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemheight.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.wrappanel.itemheight.aspx"&gt;ItemHeight&lt;/A&gt; properties to specify that all items should take up the same space. That seemed like the most likely case for someone who wants to use the new balancing behavior. However, the changes I've made work just as well when these properties are unset (i.e., &lt;CODE&gt;NaN&lt;/CODE&gt;). They &lt;STRONG&gt;also&lt;/STRONG&gt; work well when using a vertically-oriented &lt;CODE&gt;BalancedWrapPanel&lt;/CODE&gt; - as the following screen shot shows: &lt;/P&gt;&lt;IMG alt="BalancedWrapPanel, Vertical, ItemWidth and ItemHeight not set" src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-VerticalNan.png" width=340 height=349 mce_src="http://blogs.msdn.com/blogfiles/delay/BalancedWrapPanel-VerticalNan.png"&gt; &lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;If you download the source code and build for Silverlight 4, you'll get the following warning because Silverlight 4 adds support for &lt;CODE&gt;LengthConverter&lt;/CODE&gt;: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;warning CS0436: The type 'System.Windows.LengthConverter' in '...\LengthConverter.cs' conflicts with the imported type 'System.Windows.LengthConverter' in '...\System.Windows.Controls.Toolkit.dll'. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can either ignore the warning or remove the files &lt;CODE&gt;LengthConverter.cs&lt;/CODE&gt; and &lt;CODE&gt;TypeConverters.cs&lt;/CODE&gt; from the project. &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9934427" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category></item><item><title>Normal booting is old school [Windows 7 tricks detailed: USB key install, VHD creation, and native VHD boot/dual-boot!]</title><link>http://blogs.msdn.com/delay/archive/2009/12/03/normal-booting-is-old-school-windows-7-tricks-detailed-usb-key-install-vhd-creation-and-native-vhd-boot-dual-boot.aspx</link><pubDate>Thu, 03 Dec 2009 20:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9932178</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9932178.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9932178</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;Windows 7 can boot and run in some ways that are a little surprising when you first learn about them. One example is that it can seamlessly install from any sufficiently large &lt;A href="http://en.wikipedia.org/wiki/Usb_key" mce_href="http://en.wikipedia.org/wiki/Usb_key"&gt;USB key&lt;/A&gt;; another is that it can natively boot &lt;A href="http://en.wikipedia.org/wiki/VHD_%28file_format%29" mce_href="http://en.wikipedia.org/wiki/VHD_%28file_format%29"&gt;VHD&lt;/A&gt; files. Neither of these is hard to configure and both have already been discussed by other web sites. However, it has been my experience that some of the relevant information on the web is confusing, misleading, or incomplete. So in the interest of saving others - and myself! - some trouble, I explain a few interesting scenarios below with exact steps and brief notes on what each step does. (That way, if anything goes wrong, troubleshooting is a lot easier.) &lt;/P&gt;
&lt;P&gt;If you already do this kind of thing and have a process that's working for you, there's probably little here that's new. But if you've been thinking of getting your feet wet with any of this, maybe I can help make things a little easier! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Notes&lt;/STRONG&gt;:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The tasks described here are potentially &lt;STRONG&gt;&lt;SPAN style="COLOR: red"&gt;dangerous&lt;/SPAN&gt;&lt;/STRONG&gt; and can result in the &lt;STRONG&gt;&lt;SPAN style="COLOR: red"&gt;complete loss of your data&lt;/SPAN&gt;&lt;/STRONG&gt; if done improperly. Always back up your data first, think about what you're doing, check your work, and otherwise take sensible precautions! While I've done my best to ensure the steps below work as intended, I can offer no guarantee they'll work the same under all conditions. &lt;EM&gt;&lt;A href="http://en.wikipedia.org/wiki/Caveat_emptor" mce_href="http://en.wikipedia.org/wiki/Caveat_emptor"&gt;Caveat emptor&lt;/A&gt;.&lt;/EM&gt; &lt;/LI&gt;
&lt;LI&gt;Things you &lt;STRONG&gt;type&lt;/STRONG&gt; look like &lt;CODE&gt;this&lt;/CODE&gt; - things you &lt;STRONG&gt;do&lt;/STRONG&gt; look like &lt;CODE&gt;[this]&lt;/CODE&gt; - things you need to &lt;STRONG&gt;replace&lt;/STRONG&gt; when you type them (like drive letters that vary by machine) look like &lt;CODE&gt;&lt;EM&gt;this&lt;/EM&gt;&lt;/CODE&gt;. &lt;/LI&gt;
&lt;LI&gt;Unless otherwise noted, all tasks should be carried out on a machine running Windows 7. &lt;/LI&gt;
&lt;LI&gt;Each task is self-contained and can be done independently of the others. &lt;/LI&gt;
&lt;LI&gt;Although I refer to Windows 7 everywhere, Windows Server 2008 R2 supports these same scenarios as well. &lt;/LI&gt;
&lt;LI&gt;While it's possible to apply &lt;A href="http://en.wikipedia.org/wiki/BitLocker_Drive_Encryption" mce_href="http://en.wikipedia.org/wiki/BitLocker_Drive_Encryption"&gt;BitLocker drive encryption&lt;/A&gt; to a natively-booted VHD, the host drive (i.e., the drive containing the VHD) can &lt;STRONG&gt;not&lt;/STRONG&gt; be encrypted. (And if you're going to use BitLocker, you should be aware that the default location for &lt;CODE&gt;pagefile.sys&lt;/CODE&gt; of a natively-booted VHD is on the host disk &lt;STRONG&gt;outside&lt;/STRONG&gt; the VHD.) &lt;/LI&gt;
&lt;LI&gt;Here are some good resources for more information: 
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://edge.technet.com/Media/Installing-Win7-using-a-USB-Stick/" mce_href="http://edge.technet.com/Media/Installing-Win7-using-a-USB-Stick/"&gt;Installing Win7 using a USB Stick&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://technet.microsoft.com/en-us/library/dd440865(WS.10).aspx" mce_href="http://technet.microsoft.com/en-us/library/dd440865(WS.10).aspx"&gt;Frequently Asked Questions: Virtual Hard Disks in Windows 7&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://technet.microsoft.com/en-us/library/dd799282(WS.10).aspx" mce_href="http://technet.microsoft.com/en-us/library/dd799282(WS.10).aspx"&gt;Understanding Virtual Hard Disks with Native Boot&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 13pt"&gt;&lt;STRONG&gt;Installing Windows 7 (or Vista) from a USB Key &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Besides making it possible to install Windows on machines without a DVD drive, installing from a USB key has a big advantage: it's &lt;STRONG&gt;fast&lt;/STRONG&gt;. All you need is a blank USB key that's big enough to hold everything on the DVD (typically about 3GB of data). Then follow these easy steps and - BAM! - install runs faster than ever! &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;[Open a Command Prompt as administrator] &lt;/CODE&gt;
&lt;P&gt;Open the Start Menu, expand "All Programs", "Accessories", right-click on "Command Prompt", then "Run as administrator". &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Insert the USB key] &lt;/CODE&gt;
&lt;P&gt;Give the system a moment to identify it. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;diskpart &lt;/CODE&gt;
&lt;P&gt;Run the interactive disk partitioning tool. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;list disk &lt;/CODE&gt;
&lt;P&gt;Display the available disks. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;select disk &lt;EM&gt;#&lt;/EM&gt; &lt;/CODE&gt;
&lt;P&gt;Select the USB key; identify it using the "Size" column. USB keys will usually be near the bottom of the list, especially if they've just been plugged-in (when they're likely to be last). &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;list disk &lt;/CODE&gt;
&lt;P&gt;Look for the '*' identifying the selected disk and be &lt;STRONG&gt;sure&lt;/STRONG&gt; you've selected the right one because &lt;STRONG&gt;&lt;SPAN style="COLOR: red"&gt;the next step will delete all data on that disk&lt;/SPAN&gt;&lt;/STRONG&gt;. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;clean &lt;/CODE&gt;
&lt;P&gt;Remove all partition/formatting information from the selected disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;create partition primary &lt;/CODE&gt;
&lt;P&gt;Create a primary partition on the selected disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;format quick &lt;/CODE&gt;
&lt;P&gt;Format the new partition of the selected disk with the default file system. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;active &lt;/CODE&gt;
&lt;P&gt;Mark the new partition on the selected disk active and bootable. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;assign &lt;/CODE&gt;
&lt;P&gt;Assign a drive letter to the new volume of the selected disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;list volume &lt;/CODE&gt;
&lt;P&gt;Display the available volumes. Look for the '*' identifying the newly created volume. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;exit &lt;/CODE&gt;
&lt;P&gt;Exit the interactive disk partitioning tool. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;robocopy &lt;EM&gt;W&lt;/EM&gt;:\ &lt;EM&gt;U&lt;/EM&gt;:\ /e &lt;/CODE&gt;
&lt;P&gt;Copy the entire contents of the Windows 7 (or Vista) DVD in drive &lt;CODE&gt;&lt;EM&gt;W&lt;/EM&gt;&lt;/CODE&gt; to the USB key at drive &lt;CODE&gt;&lt;EM&gt;U&lt;/EM&gt;&lt;/CODE&gt;. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Safely remove/unplug the USB key] &lt;/CODE&gt;
&lt;P&gt;This key can now be inserted in any machine that supports booting from USB (nearly all of them do these days). The experience will be just the same as if the original DVD were used - but it runs considerably faster! &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: You may need to hit a special key as the machine starts to tell it to boot from the USB key instead of the internal hard drive - it's usually one of F2/F12/DEL/ESC, but check the manual if you're not sure. &lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 13pt"&gt;&lt;STRONG&gt;Create a VHD containing an up-to-date Windows 7 image &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Installing from USB may be fast, but what's even faster is not having to install at all! If you'll be running Windows 7 in &lt;A href="http://en.wikipedia.org/wiki/Windows_Virtual_PC" mce_href="http://en.wikipedia.org/wiki/Windows_Virtual_PC"&gt;Windows Virtual PC&lt;/A&gt;, &lt;A href="http://en.wikipedia.org/wiki/Hyper-V" mce_href="http://en.wikipedia.org/wiki/Hyper-V"&gt;Hyper-V&lt;/A&gt;, or natively from a VHD, it's convenient to start out with an image that already has the bits in the right places and the latest security patches applied. What's cool is that there's a script to make creating one of these VHDs easy: &lt;A href="http://code.msdn.microsoft.com/wim2vhd" mce_href="http://code.msdn.microsoft.com/wim2vhd"&gt;WIM2VHD&lt;/A&gt; by &lt;A href="http://blogs.msdn.com/mikekol/" mce_href="http://blogs.msdn.com/mikekol/"&gt;Mike Kolitz&lt;/A&gt;. Start by going to that web site and following the directions to download WIM2VHD and its dependencies before carrying out the steps below. &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;[Open a Command Prompt as administrator] &lt;/CODE&gt;
&lt;P&gt;Open the Start Menu, expand "All Programs", "Accessories", right-click on "Command Prompt", then "Run as administrator". &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Change to the directory containing WIM2VHD.wsf] &lt;/CODE&gt;
&lt;P&gt;For convenience, this directory should also contain all the QFE patches that will be applied. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;PRE&gt;&lt;CODE&gt;cscript WIM2VHD.wsf
  /wim:&lt;EM&gt;W&lt;/EM&gt;:\sources\install.wim
  /sku:ULTIMATE
  &lt;EM&gt;/disktype:fixed
  /size:10000&lt;/EM&gt;
  /vhd:Windows7Ultimate.vhd
  /qfe:Windows6.1-KB973525-x86.msu,Windows6.1-KB974332-x86.msu,Windows6.1-KB974431-x86.msu,Windows6.1-KB974455-x86.msu,Windows6.1-KB974571-x86.msu,Windows6.1-KB975364-x86.msu,Windows6.1-KB975467-x86.msu,Windows6.1-KB976749-x86.msu&lt;/CODE&gt;
&lt;/PRE&gt;
&lt;P&gt;Create a VHD named &lt;EM&gt;&lt;CODE&gt;Windows7Ultimate.vhd&lt;/CODE&gt;&lt;/EM&gt; from the original Windows 7 DVD in drive &lt;CODE&gt;&lt;EM&gt;W&lt;/EM&gt;&lt;/CODE&gt; using the Ultimate SKU, a fixed size disk of 10GB, and with the listed QFEs pre-applied. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: I'm using the x86 DVD here, so I'm providing the x86 versions of the relevant security patches. This should all work the same for 64-bit, but I prefer 32-bit because it's smaller and works pretty much everywhere. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: You can create a dynamic disk (which starts small and grows as necessary) by omitting the &lt;EM&gt;italic&lt;/EM&gt; &lt;CODE&gt;/disktype&lt;/CODE&gt; and &lt;CODE&gt;/size&lt;/CODE&gt; options above. That's going to be faster and easier to deal with for Virtual PC and Hyper-V - but for native VHD boot a fixed size is easier and performs better. That's what I'm going to do in the next task, so I've specified a small, fixed disk above. (Please refer to the &lt;A href="http://technet.microsoft.com/en-us/library/dd440865(WS.10).aspx" mce_href="http://technet.microsoft.com/en-us/library/dd440865(WS.10).aspx"&gt;FAQ&lt;/A&gt; for more detail.) &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: Per the &lt;A href="http://technet.microsoft.com/en-us/library/dd440865(WS.10).aspx" mce_href="http://technet.microsoft.com/en-us/library/dd440865(WS.10).aspx"&gt;FAQ&lt;/A&gt;, "Native boot from VHD is only available with Windows 7 Enterprise, Windows 7 Ultimate and all versions of Windows Server 2008 R2." &lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 13pt"&gt;&lt;STRONG&gt;Configure a clean machine for native VHD booting &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Is it possible to boot a machine without a "real" operating system? Yes! &lt;/P&gt;
&lt;P&gt;The steps below will clean a machine and configure it to boot into a VHD image from a nearly-empty hard drive. While there &lt;STRONG&gt;are&lt;/STRONG&gt; some sensible reasons to do this (e.g., implementing poor-man's undo disks or making it easy to transfer a pre-configured Windows 7 install around), this is mainly just a cool way to show off. &lt;NOBR&gt;:)&lt;/NOBR&gt; Rumor has it that these steps can even be used to create a USB key that hosts and boots a running copy of Windows 7, though I don't have a USB key large enough to try myself. (And besides, that would probably wear out the USB key's flash memory quite quickly.) &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: If you already have Windows 7 installed on a machine, and want to add an &lt;STRONG&gt;additional&lt;/STRONG&gt; boot option for VHD, please scroll down to the &lt;STRONG&gt;next&lt;/STRONG&gt; task instead. &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;[Boot the machine from the Windows 7 DVD or a Windows 7 USB key created by the steps above] &lt;/CODE&gt;
&lt;P&gt;Load a simple shell that can be used to make low-level changes to the disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Wait for the "Install Windows" dialog to display] &lt;/CODE&gt;
&lt;P&gt;Allow the system to boot completely. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Optional: Plug in an external USB drive containing the VHD image] &lt;/CODE&gt;
&lt;P&gt;If you're booting from the DVD or using a USB key that's too small to hold the 10GB VHD image, you can store the VHD file on a separate USB hard disk. Plug that disk in now, and give the system a moment to find it and assign it a drive letter. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Press Shift+F10] &lt;/CODE&gt;
&lt;P&gt;Open an interactive command prompt with administrator permissions &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;diskpart &lt;/CODE&gt;
&lt;P&gt;Run the interactive disk partitioning tool. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;list disk &lt;/CODE&gt;
&lt;P&gt;Display the available disks. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;select disk &lt;EM&gt;#&lt;/EM&gt; &lt;/CODE&gt;
&lt;P&gt;Select the primary hard disk; it will usually be at index 0. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;list disk &lt;/CODE&gt;
&lt;P&gt;Look for the '*' identifying the selected disk and be &lt;STRONG&gt;sure&lt;/STRONG&gt; you've selected the right one because &lt;STRONG&gt;&lt;SPAN style="COLOR: red"&gt;the next step will delete all data on that disk&lt;/SPAN&gt;&lt;/STRONG&gt;. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;clean &lt;/CODE&gt;
&lt;P&gt;Remove all partition/formatting information from the selected disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;create partition primary &lt;/CODE&gt;
&lt;P&gt;Create a primary partition on the selected disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;format quick &lt;/CODE&gt;
&lt;P&gt;Format the new partition of the selected disk with the default file system. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;active &lt;/CODE&gt;
&lt;P&gt;Mark the new partition on the selected disk active and bootable. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;assign &lt;/CODE&gt;
&lt;P&gt;Assign a drive letter to the new volume of the selected disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;list volume &lt;/CODE&gt;
&lt;P&gt;Display the available volumes. Look for the '*' identifying the newly created volume. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;exit &lt;/CODE&gt;
&lt;P&gt;Exit the interactive disk partitioning tool. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;copy &lt;EM&gt;E&lt;/EM&gt;:\&lt;EM&gt;Windows7Ultimate.vhd&lt;/EM&gt; &lt;EM&gt;C&lt;/EM&gt;:\ &lt;/CODE&gt;
&lt;P&gt;Copy the VHD file &lt;CODE&gt;&lt;EM&gt;Windows7Ultimate.vhd&lt;/EM&gt;&lt;/CODE&gt; from (external) drive &lt;CODE&gt;&lt;EM&gt;E&lt;/EM&gt;&lt;/CODE&gt; to the now-empty primary hard drive &lt;CODE&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;/CODE&gt;. This may take a little while... &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;diskpart &lt;/CODE&gt;
&lt;P&gt;Run the interactive disk partitioning tool. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;select vdisk file=&lt;EM&gt;C&lt;/EM&gt;:\&lt;EM&gt;Windows7Ultimate.vhd&lt;/EM&gt; &lt;/CODE&gt;
&lt;P&gt;Select the VHD file &lt;CODE&gt;&lt;EM&gt;Windows7Ultimate.vhd&lt;/EM&gt;&lt;/CODE&gt; just copied to the primary hard drive &lt;CODE&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;/CODE&gt;. Make sure &lt;STRONG&gt;not&lt;/STRONG&gt; to reference the VHD file on the removable disk because that disk won't be available in the future. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;attach vdisk &lt;/CODE&gt;
&lt;P&gt;Attach the selected virtual disk to the system. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;list volume &lt;/CODE&gt;
&lt;P&gt;Display the available volumes. Look for the new virtual disk volume; identify it using the "Size" column (it will probably be the last one listed). &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;exit &lt;/CODE&gt;
&lt;P&gt;Exit the interactive disk partitioning tool. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;bcdboot &lt;EM&gt;V&lt;/EM&gt;:\Windows /s &lt;EM&gt;C&lt;/EM&gt;: &lt;/CODE&gt;
&lt;P&gt;Configure primary hard disk drive &lt;CODE&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;/CODE&gt; to boot into the copy of Windows installed on virtual drive &lt;CODE&gt;&lt;EM&gt;V&lt;/EM&gt;&lt;/CODE&gt; (the newly attached virtual disk volume). &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;exit &lt;/CODE&gt;
&lt;P&gt;Close the Command Prompt window. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Close the "Install Windows" dialog by clicking the 'X' in the upper-right corner] &lt;/CODE&gt;
&lt;P&gt;Cancel the install process. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Confirm you want to cancel the install process] &lt;/CODE&gt;
&lt;P&gt;Yes, really cancel the install process. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Wait while the machine automatically reboots] &lt;/CODE&gt;
&lt;P&gt;Allow the machine to boot into the new VHD image. (&lt;STRONG&gt;Note&lt;/STRONG&gt;: This may require unplugging the USB key and/or external USB drive.) After booting into the VHD image, Windows will run through the last stages of setup (e.g., user name, time zone, etc.) and finalize the install. &lt;/P&gt;
&lt;P&gt;Enjoy your new VHD-based Windows! &lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 13pt"&gt;&lt;STRONG&gt;Add native VHD booting to a machine with Windows 7 &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you already have a machine with Windows 7 installed (perhaps via the previous set of steps), you can modify it to boot a separate instance of Windows 7 from VHD. &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;[Open a Command Prompt as administrator] &lt;/CODE&gt;
&lt;P&gt;Open the Start Menu, expand "All Programs", "Accessories", right-click on "Command Prompt", then "Run as administrator". &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;copy &lt;EM&gt;E&lt;/EM&gt;:\&lt;EM&gt;Windows7Ultimate.vhd&lt;/EM&gt; &lt;EM&gt;C&lt;/EM&gt;:\ &lt;/CODE&gt;
&lt;P&gt;Copy the VHD file &lt;CODE&gt;&lt;EM&gt;Windows7Ultimate2.vhd&lt;/EM&gt;&lt;/CODE&gt; from (any) drive &lt;CODE&gt;&lt;EM&gt;E&lt;/EM&gt;&lt;/CODE&gt; to drive &lt;CODE&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;/CODE&gt; which should be the machine's primary hard disk. (It will already contain a VHD file if you're continuing along from the previous task.) Make sure drive &lt;CODE&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;/CODE&gt; does &lt;STRONG&gt;not&lt;/STRONG&gt; correspond to a VHD-based disk. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;bcdedit /copy {default} /d "&lt;EM&gt;Windows 7 VHD&lt;/EM&gt;" &lt;/CODE&gt;
&lt;P&gt;Creates a copy of the default boot configuration with the name &lt;CODE&gt;&lt;EM&gt;Windows 7 VHD&lt;/EM&gt;&lt;/CODE&gt;. Note the GUID that is returned by this command; use it in place of &lt;CODE&gt;&lt;EM&gt;GUID&lt;/EM&gt;&lt;/CODE&gt; in the following commands. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;bcdedit /set &lt;EM&gt;GUID&lt;/EM&gt; device vhd=[&lt;EM&gt;C&lt;/EM&gt;:]\&lt;EM&gt;Windows7Ultimate2.vhd&lt;/EM&gt; &lt;/CODE&gt;
&lt;P&gt;Set the device for the new boot configuration to the &lt;CODE&gt;&lt;EM&gt;Windows7Ultimate2.vhd&lt;/EM&gt;&lt;/CODE&gt; file on drive &lt;CODE&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;/CODE&gt;. (&lt;STRONG&gt;Note&lt;/STRONG&gt;: Use the "[C:]\..." syntax exactly as shown above with the square brackets.) &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;bcdedit /set &lt;EM&gt;GUID&lt;/EM&gt; osdevice vhd=[&lt;EM&gt;C&lt;/EM&gt;:]\&lt;EM&gt;Windows7Ultimate2.vhd&lt;/EM&gt; &lt;/CODE&gt;
&lt;P&gt;Set the OS device for the new configuration to the &lt;CODE&gt;&lt;EM&gt;Windows7Ultimate2.vhd&lt;/EM&gt;&lt;/CODE&gt; file on drive &lt;CODE&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;/CODE&gt;. (&lt;STRONG&gt;Note&lt;/STRONG&gt;: Use the "[C:]\..." syntax exactly as shown above with the square brackets.) &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;[Reboot and choose the new ""Windows 7 VHD" option] &lt;/CODE&gt;
&lt;P&gt;Boot into the new VHD. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: If that doesn't work, please have a look at the end of &lt;A href="http://technet.microsoft.com/en-us/library/dd799299(WS.10).aspx" mce_href="http://technet.microsoft.com/en-us/library/dd799299(WS.10).aspx"&gt;this document&lt;/A&gt; and try the "detecthal on" step. I haven't found this to be necessary, so I haven't listed it - but if others find that it's helpful, I'll call that out. &lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932178" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Technical/default.aspx">Technical</category></item><item><title>Two birds, squared! [Silverlight/WPF Data Visualization Development Release 3 and a DataVisualizationDemos update]</title><link>http://blogs.msdn.com/delay/archive/2009/11/30/two-birds-squared-silverlight-wpf-data-visualization-development-release-3-and-a-datavisualizationdemos-update.aspx</link><pubDate>Mon, 30 Nov 2009 20:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9930348</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9930348.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9930348</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;We shipped the &lt;A href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36060" mce_href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36060"&gt;November 2009 release&lt;/A&gt; of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; a little over a week ago and it includes a &lt;A href="http://blogs.msdn.com/delay/archive/2009/11/18/silverlight-4-beta-is-out-and-the-toolkit-has-it-covered-silverlight-toolkit-november-2009-release-now-available-for-silverlight-3-and-4.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/11/18/silverlight-4-beta-is-out-and-the-toolkit-has-it-covered-silverlight-toolkit-november-2009-release-now-available-for-silverlight-3-and-4.aspx"&gt;handful of improvements to the Data Visualization assembly&lt;/A&gt;. It also adds support for the new &lt;A href="http://www.silverlight.net/getstarted/silverlight-4-beta/" mce_href="http://www.silverlight.net/getstarted/silverlight-4-beta/"&gt;Silverlight 4 Beta&lt;/A&gt;! And while &lt;STRONG&gt;we&lt;/STRONG&gt; were busy getting the October/November Toolkits out the door, the &lt;STRONG&gt;WPF&lt;/STRONG&gt; team previewed WPF 4 along with the &lt;A href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;.NET 4 and Visual Studio 2010 Beta&lt;/A&gt;! &lt;/P&gt;
&lt;P&gt;Which means there are now &lt;STRONG&gt;four&lt;/STRONG&gt; platforms of interest to developers: &lt;U&gt;Silverlight 3&lt;/U&gt;, &lt;U&gt;Silverlight 4&lt;/U&gt;, &lt;U&gt;WPF 3.5&lt;/U&gt;, and &lt;U&gt;WPF 4&lt;/U&gt;. And the Silverlight/WPF Data Visualization assembly supports them &lt;STRONG&gt;all&lt;/STRONG&gt;! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Silverlight/WPF Data Visualization Development Release 3 &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;As with previous &lt;A href="http://blogs.msdn.com/delay/archive/2009/07/16/bringing-the-silverlight-toolkit-s-treemap-to-wpf-silverlight-wpf-data-visualization-development-release-0.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/16/bringing-the-silverlight-toolkit-s-treemap-to-wpf-silverlight-wpf-data-visualization-development-release-0.aspx"&gt;Data Visualization Development Releases&lt;/A&gt;, I've updated to the most recent Toolkit code. And like &lt;A href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx"&gt;last time&lt;/A&gt;, the Silverlight Toolkit shipped most recently so the code in the new Development Release is identical to what just went out with the Silverlight 3/4 Toolkits. However, people using Data Visualization on WPF 3.5 or 4 can take advantage of the latest changes by updating to the binaries included with this Development Release or by compiling the corresponding code themselves. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/SilverlightWpfDataVisualization/SilverlightWpfDataVisualization.zip" mce_href="http://cesso.org/Samples/SilverlightWpfDataVisualization/SilverlightWpfDataVisualization.zip"&gt;[Click here to download the SilverlightWpfDataVisualization solution including complete source code and pre-compiled binaries for all four platforms.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Notes: &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;This is the first release I know of that supports four different platforms with distinct implementations on each. While the code and XAML are 99+% identical across the platforms, each has at least one customization that makes it unique. [Bonus points for identifying them all! &lt;NOBR&gt;:)&lt;/NOBR&gt; ] &lt;/LI&gt;
&lt;LI&gt;Previously, there was a single Visual Studio 2008 &lt;CODE&gt;SilverlightWpfDataVisualization.sln&lt;/CODE&gt; file for both Silverlight 3 and WPF 3.5. Because Silverlight 4 and WPF 4 use Visual Studio 2010, there's a new &lt;CODE&gt;SilverlightWpfDataVisualization&lt;STRONG&gt;4&lt;/STRONG&gt;.sln&lt;/CODE&gt; file for those two platforms. The two solutions (and the projects within) look and act exactly the same - they're separate because they compile with different tools and because separation lets people who haven't upgraded continue to use the VS 2008 solution. &lt;/LI&gt;
&lt;LI&gt;I always strive for code that builds with no compile or code analysis warnings, and that's still the case when compiling for Silverlight 3, WPF 3.5, and Silverlight 4 (though the last is a bit of a cheat because code analysis doesn't work there yet). But the new .NET 4 tools include some improvements, and there were three new kinds of warnings when I first compiled for WPF 4. Two of them were easily addressed with trivial changes I already made, but the third requires a bit more (potentially destabilizing) work that was &lt;STRONG&gt;not&lt;/STRONG&gt; done for this release: &lt;EM&gt;Warning 2 CA1062 : Microsoft.Design : In externally visible method 'Foo', validate parameter 'Bar' before using it.&lt;/EM&gt; As it happens, there was already a work item for this task because we knew we weren't checking everywhere we should. So if you see this warning when compiling the WPF 4 assembly, please don't be alarmed! &lt;/LI&gt;
&lt;LI&gt;Whereas it used to be fine to wrap platform-specific code in &lt;CODE&gt;#if SILVERLIGHT&lt;/CODE&gt; blocks, that doesn't work anymore because there are now cross-version changes &lt;STRONG&gt;within&lt;/STRONG&gt; each platform. Therefore, I've switched to the form &lt;CODE&gt;#if !NO_FEATURE&lt;/CODE&gt; instead. It's usually best to avoid double-negatives, but their use here is a consequence of a deliberate decision. My goal is that, by default, the code tries to use every feature it supports and if the target platform doesn't implement something, there's a compile error. At which point it's easy to identify the problem and add the relevant &lt;CODE&gt;#define&lt;/CODE&gt; to the project file to "turn off" the unsupported feature. This seem better to me than forcing developers to know all the relevant flags and use them to "turn on" features for each platform. Just another example of the &lt;A href="http://blogs.msdn.com/brada/archive/2003/10/02/50420.aspx" mce_href="http://blogs.msdn.com/brada/archive/2003/10/02/50420.aspx"&gt;pit of success&lt;/A&gt;, really... &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/LI&gt;
&lt;LI&gt;WPF 4 includes the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager(VS.100).aspx"&gt;Visual State Manager&lt;/A&gt; classes in the framework, so the WPF 4 Data Visualization assembly no longer has a dependency on the WPF Toolkit! &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;IMG alt="DataVisualizationDemos on WPF 4" src="http://blogs.msdn.com/blogfiles/delay/DataVisualizationDemos-WPF4.png" width=405 height=381 mce_src="http://blogs.msdn.com/blogfiles/delay/DataVisualizationDemos-WPF4.png"&gt; 
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;DataVisualizationDemos Sample Project Updated &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The DataVisualizationDemos application is a collection of all the Data Visualization samples I've posted to my blog. Like the Data Visualization assembly itself, the demo application runs on Silverlight 3 and 4 as well as WPF 3.5 and 4 and shares the same code and XAML across all &lt;STRONG&gt;four&lt;/STRONG&gt; platforms. Not only is it a convenient way to look at a variety of sample code, it also has links back to the relevant blog posts for more detail about each sample. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/DataVisualizationDemos/DataVisualizationDemos.zip" mce_href="http://cesso.org/Samples/DataVisualizationDemos/DataVisualizationDemos.zip"&gt;Click here to download the complete source code for the cross-platform DataVisualizationDemos sample application.&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Notes: &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I've followed the same dual-solution and &lt;CODE&gt;#if&lt;/CODE&gt; approaches that I describe above. &lt;/LI&gt;
&lt;LI&gt;Because WPF 4 now supports &lt;A href="http://msdn.microsoft.com/en-us/library/cc189019(VS.96).aspx#easing_functions" mce_href="http://msdn.microsoft.com/en-us/library/cc189019(VS.96).aspx#easing_functions"&gt;easing functions&lt;/A&gt;, the "Gelatin Sales" example on the "Charting Introduction" tab runs on that platform - as does the entire "Jelly Charting" demo. And boy, is it smooth on WPF! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the release of Silverlight/WPF Data Visualization Development Release 3, it's easy for anyone to compile and run the Data Visualization assembly on any of Microsoft's four premier development platforms. So what are you waiting for? &lt;NOBR&gt;;)&lt;/NOBR&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9930348" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF+Toolkit/default.aspx">WPF Toolkit</category></item><item><title>Sharing isn't easy for anyone [Tricks for sharing the same XAML files across Silverlight and WPF]</title><link>http://blogs.msdn.com/delay/archive/2009/11/23/sharing-isn-t-easy-for-anyone-tricks-for-sharing-the-same-xaml-files-across-silverlight-and-wpf.aspx</link><pubDate>Tue, 24 Nov 2009 07:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9927747</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9927747.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9927747</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;I casually mentioned &lt;A href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx"&gt;two tricks for sharing the same XAML across Silverlight and WPF&lt;/A&gt; in the notes of a post a couple weeks ago. I used both techniques in my &lt;CODE&gt;DataVisualizationDemos&lt;/CODE&gt; project (which compiles for Silverlight and WPF from the same source code) and wanted to call them out for others in similar situations. The feedback I got was quite positive - until &lt;A href="http://blog.elgaard.com/" mce_href="http://blog.elgaard.com/"&gt;Brian Elgaard Bennett&lt;/A&gt; tried the subclassing trick with &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.hierarchicaldatatemplate.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.hierarchicaldatatemplate.aspx"&gt;HierarchicalDataTemplate&lt;/A&gt;. While there's no reason that shouldn't work, it doesn't. &lt;/P&gt;
&lt;P&gt;What's going on is that WPF doesn't support subclassing &lt;CODE&gt;DataTemplate&lt;/CODE&gt; or any of its children. What's worse, nobody expects this when they bump into it! [I know a few of us have independently reported the same issue to the WPF team - it's kind of like a rite of passage. &lt;NOBR&gt;:)&lt;/NOBR&gt; ] So the right people are aware of the problem, and maybe - just maybe - the new XAML parser in .NET 4 will help fix things. But that doesn't matter for WPF 3.5 development today - and because my XAML sharing trick &lt;STRONG&gt;relies&lt;/STRONG&gt; on subclassing, the situation seems pretty dire. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I'm stubborn, so I thought about the situation a little and foolishly said I had an idea that should work. Unfortunately - like most of my ideas - it didn't work the first time. Or the second time. Or the third. Or... &lt;/P&gt;
&lt;P&gt;I think it was something like the ninety-ninth idea that finally worked. &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;"Genius is one percent inspiration, ninety-nine percent perspiration."&lt;/EM&gt; - Thomas Edison &lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, I won't claim this is genius or anything, but the ratio sure seems right. &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/SharingXamlSilverlightWpf/SharingXamlSilverlightWpf.zip" mce_href="http://cesso.org/Samples/SharingXamlSilverlightWpf/SharingXamlSilverlightWpf.zip"&gt;[Click here to download the complete source code for the SharingXamlSilverlightWpf sample.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way I've solved the &lt;CODE&gt;HierarchicalDataTemplate&lt;/CODE&gt; problem is a lot like the way I went about things before. However, I've implemented it a little differently this time around, so if you want a quick-and-dirty solution and don't care about &lt;CODE&gt;HierarchicalDataTemplate&lt;/CODE&gt;, then do it the way I did in my &lt;A href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx"&gt;previous post&lt;/A&gt;. But if you want a more complete, more comprehensive solution, please keep reading... &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, here's the XAML we'll be sharing. There's nothing fancy, just some standard controls that are part of the core framework for &lt;STRONG&gt;WPF&lt;/STRONG&gt;, and part of the SDK/&lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Toolkit&lt;/A&gt; for &lt;STRONG&gt;Silverlight&lt;/STRONG&gt;. &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;UserControl&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;Class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="SharingXamlSilverlightWpf_SL.MainPage"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;systemWindows&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="clr-namespace:System.Windows;assembly=PresentationFramework"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DockPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBlock&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Inside a DockPanel"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DockPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Viewbox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="40"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBlock&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Inside a ViewBox"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Viewbox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TreeView&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TreeViewItem
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Header&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Inside a TreeView(Item)"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; ItemsSource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; IsExpanded&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="True"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TreeViewItem.ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindows&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;HierarchicalDataTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBlock&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindows&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;HierarchicalDataTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TreeViewItem.ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TreeViewItem&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;systemWindowsControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TreeView&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;UserControl&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: In the ideal world, we wouldn't need to use an XML namespace prefix under Silverlight and therefore this problem would never come up in the first place. Unfortunately, Silverlight 3 and the Silverlight 4 Beta don't support &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.markup.xmlnsdefinitionattribute.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.markup.xmlnsdefinitionattribute.aspx"&gt;XmlnsDefinitionAttribute&lt;/A&gt;, so the fact that the SDK/Toolkit assemblies already properly implement it doesn't help us. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;The interesting thing to note above is that all the relevant controls (&lt;CODE&gt;DockPanel&lt;/CODE&gt;, &lt;CODE&gt;Viewbox&lt;/CODE&gt;, &lt;CODE&gt;TreeView&lt;/CODE&gt;, &lt;CODE&gt;TreeViewItem&lt;/CODE&gt;, and &lt;CODE&gt;HierarchicalDataTemplate&lt;/CODE&gt;) have a prefix and that things look just like you'd expect them to under WPF if you went to the trouble of specifying the namespace explicitly. And, in fact, that's all there is for WPF - just be explicit with the XAML and you're done! &lt;/P&gt;
&lt;P&gt;So what's the magic that makes this work on Silverlight? Well, it's nothing in the application project there, either - just like with WPF there are no special changes required! However, there &lt;STRONG&gt;is&lt;/STRONG&gt; an &lt;STRONG&gt;extra&lt;/STRONG&gt; assembly on the Silverlight side... &lt;/P&gt;
&lt;P&gt;Before I totally spoil the surprise, here's the code for that assembly: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;extern&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;alias&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SWC;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;extern&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;alias&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SWCT;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System.Windows.Markup;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SystemWindows = SWC::System.Windows;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SystemWindowsControls = SWC::System.Windows.Controls;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SystemWindowsControlsToolkit = SWCT::System.Windows.Controls;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System.Windows
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Stub class for HierarchicalDataTemplate
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HierarchicalDataTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : SystemWindows.HierarchicalDataTemplate
    {
    }
}

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; System.Windows.Controls
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Stub class for DockPanel
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DockPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : SystemWindowsControlsToolkit.DockPanel
    {
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Stub class for TreeView
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;TreeView&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : SystemWindowsControls.TreeView
    {
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Stub class for TreeViewItem
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;TreeViewItem&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : SystemWindowsControls.TreeViewItem
    {
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Stub class for Viewbox
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Silverlight's Viewbox is sealed, so simulate it with a ContentControl wrapper
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Viewbox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ContentControl
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Viewbox()
        {
            Template = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;XamlReader&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Load(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;@"
                &amp;lt;ControlTemplate
                    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                    xmlns:controls=""clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit""&amp;gt;
                    &amp;lt;controls:Viewbox&amp;gt;
                        &amp;lt;ContentPresenter/&amp;gt;
                    &amp;lt;/controls:Viewbox&amp;gt;
                &amp;lt;/ControlTemplate&amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        }
    }
}
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Aside from some &lt;A href="http://msdn.microsoft.com/en-us/library/ms173212.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms173212.aspx"&gt;extern alias&lt;/A&gt;/&lt;A href="http://msdn.microsoft.com/en-us/library/zhdeatwt.aspx" mce_href="http://msdn.microsoft.com/en-us/library/zhdeatwt.aspx"&gt;using&lt;/A&gt; stuff at the top to disambiguate references, there's nothing here we didn't see last time around - in fact, the subclassing trick for &lt;CODE&gt;HierarchicalDataTemplate&lt;/CODE&gt; looks just like it does for the other classes. &lt;/P&gt;
&lt;P&gt;&lt;EM&gt;But I thought that trick didn't work for HierarchicalDataTemplate? &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Right, it doesn't work on WPF - but this assembly is &lt;STRONG&gt;Silverlight-only&lt;/STRONG&gt;. &lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Then you need a matching assembly for WPF or else the project won't compile because of the XMLNS reference. &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Unless the corresponding assembly &lt;STRONG&gt;already exists&lt;/STRONG&gt; on WPF. &lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Oh, no you didn't... &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Oh, yes I did! :) &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Silverlight-only assembly is named &lt;CODE&gt;PresentationFramework.dll&lt;/CODE&gt;, the &lt;STRONG&gt;same&lt;/STRONG&gt; name as the platform assembly that contains the actual implementations of the controls for WPF. The Silverlight platform doesn't have a &lt;CODE&gt;PresentationFramework.dll&lt;/CODE&gt;, and this latest trick takes advantage of that fact to sneak one in. Because Silverlight doesn't suffer from the same &lt;CODE&gt;DataTemplate&lt;/CODE&gt; subclassing bug, it's perfectly okay to subclass &lt;CODE&gt;HierarchicalDataTemplate&lt;/CODE&gt; there. &lt;/P&gt;
&lt;P&gt;So the original subclassing trick does 95% of what we want, the control wrapping trick adds &lt;CODE&gt;Viewbox&lt;/CODE&gt;, and the &lt;CODE&gt;PresentationFramework&lt;/CODE&gt; trick adds &lt;CODE&gt;HierarchicalDataTemplate&lt;/CODE&gt; - which means we're &lt;STRONG&gt;100%&lt;/STRONG&gt; covered! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, at least until someone contacts me to report another problem. Which would no doubt be interesting to debug and I'd certainly want to have a look. &lt;/P&gt;
&lt;P&gt;But not right now. Adding that same-named assembly has left me feeling a little slimy and I think I need a shower before I spend more time on this. &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927747" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category></item><item><title>Silverlight 4 Beta is out - and the Toolkit has it covered! [Silverlight Toolkit November 2009 release now available for Silverlight 3 and 4!]</title><link>http://blogs.msdn.com/delay/archive/2009/11/18/silverlight-4-beta-is-out-and-the-toolkit-has-it-covered-silverlight-toolkit-november-2009-release-now-available-for-silverlight-3-and-4.aspx</link><pubDate>Wed, 18 Nov 2009 19:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9924635</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9924635.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9924635</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;We've just published the &lt;A href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36060" mce_href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36060"&gt;November 09&lt;/A&gt; release of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; in conjunction with today's unveiling of the &lt;A href="http://www.silverlight.net/getstarted/silverlight-4-beta/" mce_href="http://www.silverlight.net/getstarted/silverlight-4-beta/"&gt;Silverlight 4 Beta&lt;/A&gt;! The Silverlight 4 Beta offers a bunch of neat new features which enable even more compelling online (and offline!) applications. Stuff like &lt;STRONG&gt;bi-directional text&lt;/STRONG&gt;,&lt;STRONG&gt; web cam and microphone&lt;/STRONG&gt; support, a &lt;STRONG&gt;RichTextArea&lt;/STRONG&gt; control, &lt;STRONG&gt;clipboard&lt;/STRONG&gt; access, &lt;STRONG&gt;ICommand&lt;/STRONG&gt;, an &lt;STRONG&gt;elevated-trust&lt;/STRONG&gt; model, &lt;STRONG&gt;printing&lt;/STRONG&gt;, &lt;STRONG&gt;notifications&lt;/STRONG&gt;, &lt;STRONG&gt;right-click&lt;/STRONG&gt;, and &lt;STRONG&gt;more&lt;/STRONG&gt;! &lt;/P&gt;
&lt;P&gt;Of course, the big news for &lt;STRONG&gt;this&lt;/STRONG&gt; post is a new version of the Silverlight Toolkit that's perfectly suited for developing great applications on Silverlight 4. And though it seems like just yesterday that we finished off the October 09 release, there are some neat, new things in today's release for Silverlight 3, as well. You can be confident that the Silverlight Toolkit has your back &lt;STRONG&gt;whichever&lt;/STRONG&gt; platform you choose! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My announcements are usually all about the &lt;A href="http://cesso.org/r/DVLinks" mce_href="http://cesso.org/r/DVLinks"&gt;Toolkit's Data Visualization assembly&lt;/A&gt; - and there &lt;STRONG&gt;are&lt;/STRONG&gt; some improvements in that area - but it wasn't my primary focus this time around. If you have a look at the &lt;A href="http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20November%202009%20change%20list" mce_href="http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20November%202009%20change%20list"&gt;official release notes&lt;/A&gt;, you'll see there are all kinds of new things across the board. I'm not going to repeat everything here, but I do want to highlight a few things: &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Partial Release Notes &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG style="BACKGROUND-COLOR: orange"&gt;SL3&lt;/STRONG&gt;/&lt;STRONG style="BACKGROUND-COLOR: lime"&gt;SL4&lt;/STRONG&gt;: We've added a new control, &lt;STRONG&gt;BusyIndicator&lt;/STRONG&gt;, based on the &lt;CODE&gt;ActivityControl&lt;/CODE&gt; found in the RIA Services project template and samples. &lt;CODE&gt;BusyIndicator&lt;/CODE&gt; makes it easy to add a "Please wait..." progress indicator to applications and does so in a way that's easy to customize. It's a simple control, but a handy one. I have a few examples below; please see &lt;A href="http://www.davidpoll.com/" mce_href="http://www.davidpoll.com/"&gt;David Poll's blog&lt;/A&gt; for more. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG style="BACKGROUND-COLOR: orange"&gt;SL3&lt;/STRONG&gt;/&lt;STRONG style="BACKGROUND-COLOR: lime"&gt;SL4&lt;/STRONG&gt;: Minor tweaks to &lt;STRONG&gt;Data Visualization&lt;/STRONG&gt;: Support more flexible subclassing scenarios of core classes, provide more helpful exception messages in some scenarios, tweak default Chart template to respect Padding, change type of Chart.LegendItems collection items to &lt;CODE&gt;object&lt;/CODE&gt; for flexibility, convert &lt;CODE&gt;Legend&lt;/CODE&gt; to a &lt;CODE&gt;HeaderedItemsControl&lt;/CODE&gt; for consistency. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG style="BACKGROUND-COLOR: orange"&gt;SL3&lt;/STRONG&gt;/&lt;STRONG style="BACKGROUND-COLOR: lime"&gt;SL4&lt;/STRONG&gt;: It's now possible to collect &lt;STRONG&gt;code coverage&lt;/STRONG&gt; statistics when running unit tests with the Silverlight Unit Test Framework! Jeff spent some time this release productizing some clever hackery Ted Glaza originally did about a year ago, and this new capability fills a pretty big hole in the unit testing story for Silverlight. We're also including a couple of the &lt;STRONG&gt;custom build actions&lt;/STRONG&gt; that we use internally - now you'll be able to use them in your projects! And we're including the XML files to make it easy for customers to enable &lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/dd833069(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd833069(VS.95).aspx"&gt;Application Library Caching&lt;/A&gt;&lt;/STRONG&gt; for their projects. For more information on these topics, please have a look at &lt;A href="http://www.jeff.wilcox.name/" mce_href="http://www.jeff.wilcox.name/"&gt;Jeff Wilcox's blog&lt;/A&gt;. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG style="BACKGROUND-COLOR: lime"&gt;SL4&lt;/STRONG&gt;: We've modified all the Toolkit/SDK control visuals and input handlers to behave correctly for &lt;STRONG&gt;right-to-left cultures&lt;/STRONG&gt; and added &lt;STRONG&gt;mouse wheel support&lt;/STRONG&gt; in some of the obvious places. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG style="BACKGROUND-COLOR: lime"&gt;SL4&lt;/STRONG&gt;: We've removed &lt;STRONG&gt;ImplicitStyleManager&lt;/STRONG&gt; because Silverlight 4 supports implicit styles natively. Correspondingly, we've modified the &lt;CODE&gt;Theme&lt;/CODE&gt;-based wrapper classes (&lt;CODE&gt;TwilightBlue&lt;/CODE&gt;, &lt;CODE&gt;ShinyRed&lt;/CODE&gt;, etc.) to use implicit styles. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG style="BACKGROUND-COLOR: lime"&gt;SL4&lt;/STRONG&gt;: &lt;STRONG&gt;Viewbox&lt;/STRONG&gt; has moved into the Silverlight 4 core (i.e., it's available in the &lt;CODE&gt;System.Windows.dll&lt;/CODE&gt; assembly that every Silverlight 4 install includes), so it has been removed from the Silverlight 4 Toolkit. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG style="BACKGROUND-COLOR: lime"&gt;SL4&lt;/STRONG&gt;: Along with the new &lt;A href="http://mef.codeplex.com/" mce_href="http://mef.codeplex.com/"&gt;MEF (Managed Extensibility Framework)&lt;/A&gt; features in the Silverlight 4 SDK, there's an experimental &lt;STRONG&gt;System.ComponentModel.Composition.Packaging.Toolkit&lt;/STRONG&gt; assembly in the Toolkit that adds support for downloading secondary XAP’s and loading them into a MEF catalog. For more information, please have a look at &lt;A href="http://weblogs.asp.net/whaggard" mce_href="http://weblogs.asp.net/whaggard"&gt;Wes Haggard's blog&lt;/A&gt;. &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;BusyIndicator is in the house...&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;At its core, &lt;CODE&gt;BusyIndicator&lt;/CODE&gt; is a simple wrapper control into which you put whatever makes up the UI of your application. (You can think of it as a special kind of &lt;CODE&gt;Border&lt;/CODE&gt; with special abilities.) &lt;CODE&gt;BusyIndicator&lt;/CODE&gt; exposes an &lt;CODE&gt;IsBusy&lt;/CODE&gt; property which should be set to &lt;CODE&gt;true&lt;/CODE&gt; (possibly via data binding) whenever the relevant portion of the application is busy and won't respond to user input. When this happens, &lt;CODE&gt;BusyIndicator&lt;/CODE&gt; automatically disables its content and shows a simple UI to let the user know what's going on. It's really quite simple! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P&gt;Here's the most basic scenario: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; IsBusy&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; MyBusyProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Content goes here... --&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And this is how it looks when &lt;CODE&gt;IsBusy&lt;/CODE&gt; is set: &lt;/P&gt;&lt;IMG alt="Default BusyIndicator" src="http://blogs.msdn.com/blogfiles/delay/BusyIndicator-Default.png" width=200 height=100 mce_src="http://blogs.msdn.com/blogfiles/delay/BusyIndicator-Default.png"&gt; 
&lt;P&gt;The most common change is to customize the message, and of course that's simple to do: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; IsBusy&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; MyBusyProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BusyContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="My custom message..."&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Content goes here... --&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Yielding: &lt;/P&gt;&lt;IMG alt="BusyIndicator with custom message" src="http://blogs.msdn.com/blogfiles/delay/BusyIndicator-CustomMessage.png" width=200 height=100 mce_src="http://blogs.msdn.com/blogfiles/delay/BusyIndicator-CustomMessage.png"&gt; 
&lt;P&gt;Note that the &lt;CODE&gt;BusyContent&lt;/CODE&gt; property is of type &lt;CODE&gt;object&lt;/CODE&gt;, so we could have used other UI elements (like &lt;CODE&gt;Grid&lt;/CODE&gt;, &lt;CODE&gt;Image&lt;/CODE&gt;, and &lt;CODE&gt;Button&lt;/CODE&gt;) for a message with more than just text. Of course, sometimes you want things to be &lt;STRONG&gt;totally&lt;/STRONG&gt; custom - so there are some straightforward ways to do that which don't require you to completely re-Template: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; IsBusy&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; MyBusyProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BusyContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Provide custom UI for busy display --&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator.BusyContentTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DataTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBlock&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Downloading Email"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; FontWeight&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Bold"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Center"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="6"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TextBlock&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; MyStatus&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ProgressBar&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; MyProgress&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="15"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Cancel"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Center"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DataTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator.BusyContentTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Remove unnecessary default ProgressBar --&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator.ProgressBarStyle&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="ProgressBar"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Visibility"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Collapsed"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator.ProgressBarStyle&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Content goes here... --&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;controlsToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;BusyIndicator&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Which looks like: &lt;/P&gt;&lt;IMG alt="BusyIndicator with custom UI" src="http://blogs.msdn.com/blogfiles/delay/BusyIndicator-CustomTemplate.png" width=230 height=150 mce_src="http://blogs.msdn.com/blogfiles/delay/BusyIndicator-CustomTemplate.png"&gt; 
&lt;P&gt;Another property to be aware of is the &lt;CODE&gt;DisplayAfter&lt;/CODE&gt; property which lets you configure the initial delay before the busy indicator is shown - to avoid the annoying "on/off" flicker that would otherwise result from a lot of quick operations in succession. The &lt;CODE&gt;BusyIndicator&lt;/CODE&gt; page of the &lt;A href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" mce_href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html"&gt;public sample project&lt;/A&gt; has an interactive section where you can experiment with various delays and durations to see how this looks in action. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ImplicitStyleManager has left the building...&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I wanted to show how to convert an existing application using &lt;CODE&gt;ImplicitStyleManager&lt;/CODE&gt; over to using Silverlight 4's new implicit styling support. Because I made this change for the 11 Toolkit themes, I can tell you it is quite easy. &lt;NOBR&gt;:)&lt;/NOBR&gt; Basically, it's just a matter of removing the &lt;CODE&gt;ImplicitStyleManager&lt;/CODE&gt; attached property/properties and - where relevant - moving the &lt;CODE&gt;ResourceDictionary&lt;/CODE&gt; of &lt;CODE&gt;Style&lt;/CODE&gt;s into the &lt;CODE&gt;Resources&lt;/CODE&gt; section of the parent element (or all the way up to &lt;CODE&gt;App.xaml&lt;/CODE&gt;). Also, be sure to go through and remove any explicit assignments to the &lt;CODE&gt;Style&lt;/CODE&gt; property or it's friends (e.g., &lt;CODE&gt;ItemContanerStyle&lt;/CODE&gt;). (This probably isn't common in most applications, but the Toolkit Themes did it all over the place.) &lt;/P&gt;
&lt;P&gt;To make that a little more concrete, here's a simplified "before" example that makes &lt;CODE&gt;Button&lt;/CODE&gt;s have blue text and &lt;CODE&gt;ListBoxItem&lt;/CODE&gt;s purple: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt; &lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #ff0000"&gt;controlsThemingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;ImplicitStyleManager.ApplyMode&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="OneTime"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Styles for controls --&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel.Resources&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Button"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Foreground"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Blue"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="ListBoxItem"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Foreground"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Purple"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel.Resources&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Styled controls --&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Button"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ListBox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ListBoxItem&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Item 1"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ListBoxItem&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Item 2"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ListBox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;

&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StackPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;To convert this XAML over to Silverlight 4's implicit style support, just remove the highlighted portion above. The visuals will look exactly the same, but everything is more efficient because the platform is handling it internally. And what's more, various scenarios that were tricky to get working with &lt;CODE&gt;ImplicitStyleManager&lt;/CODE&gt; (like styling the contents of a &lt;CODE&gt;TabControl&lt;/CODE&gt;) now "just work" thanks to the new framework support for implicit styles! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Silverlight 4 has a lot of great improvements that really raise the bar for rich, interactive web applications. I encourage everyone to check it out today and start thinking about how to take advantage of all the new stuff! &lt;NOBR&gt;:)&lt;/NOBR&gt; And when you're done with that, please check out the live Toolkit samples for &lt;A href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" mce_href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html"&gt;Silverlight 3&lt;/A&gt; or &lt;A href="http://silverlight.net/samples/sl4/toolkitcontrolsamples/run/default.html" mce_href="http://silverlight.net/samples/sl4/toolkitcontrolsamples/run/default.html"&gt;Silverlight 4&lt;/A&gt;, download the Toolkit installer(s) for the platform/platforms of your choice, and &lt;STRONG&gt;enjoy&lt;/STRONG&gt;! &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9924635" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category></item><item><title>Creating something from nothing - and knowing it [Developer-friendly virtual file implementation for .NET refined!]</title><link>http://blogs.msdn.com/delay/archive/2009/11/16/creating-something-from-nothing-and-knowing-it-developer-friendly-virtual-file-implementation-for-net-refined.aspx</link><pubDate>Mon, 16 Nov 2009 18:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923072</guid><dc:creator>Delay</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/delay/comments/9923072.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9923072</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;A couple of weeks ago &lt;A href="http://blogs.msdn.com/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx"&gt;I wrote about VirtualFileDataObject, my developer-friendly virtual file implementation for .NET and WPF&lt;/A&gt;. I followed that up by &lt;A href="http://blogs.msdn.com/delay/archive/2009/11/04/creating-something-from-nothing-asynchronously-developer-friendly-virtual-file-implementation-for-net-improved.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/11/04/creating-something-from-nothing-asynchronously-developer-friendly-virtual-file-implementation-for-net-improved.aspx"&gt;adding support for asynchronous behavior to improve the user experience during long-running operations&lt;/A&gt;. Last week, these posts got a &lt;A href="http://blogs.msdn.com/oldnewthing/archive/2009/11/13/9921677.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2009/11/13/9921677.aspx"&gt;shout-out from blogging legend Raymond Chen&lt;/A&gt;, whose work provided the inspiration for the project. [Best week &lt;EM&gt;ever&lt;/EM&gt;! :) ] Now it's time for one last tweak to wrap things up! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Recall that the Windows APIs for drag-and-drop and clipboard operations deal with objects that implement the &lt;A href="http://msdn.microsoft.com/en-us/library/ms688421(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms688421(VS.85).aspx"&gt;IDataObject COM interface&lt;/A&gt;. And while the native &lt;A href="http://msdn.microsoft.com/en-us/library/ms678486(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms678486(VS.85).aspx"&gt;DoDragDrop function&lt;/A&gt; tries to provide a mechanism for the source and target to communicate (via the &lt;CODE&gt;pdwEffect&lt;/CODE&gt; parameter and the function's return value), there's nothing similar available for the &lt;A href="http://msdn.microsoft.com/en-us/library/ms649051(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms649051(VS.85).aspx"&gt;SetClipboardData function&lt;/A&gt;. And once you enable asynchronous drag-and-drop, it's clear that the return value of &lt;CODE&gt;DoDragDrop&lt;/CODE&gt; isn't going to work, either, because the call returns immediately (before the operation has completed). So it seems like there must be some &lt;STRONG&gt;other&lt;/STRONG&gt; way for the source and target to share information... &lt;/P&gt;
&lt;P&gt;Sure enough, there are some &lt;A href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#communication" mce_href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#communication"&gt;shell clipboard formats specifically for enabling communication between the source and target&lt;/A&gt;! For the purposes of this sample, we're interested in using two of them: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#CFSTR_PREFERREDDROPEFFECT" mce_href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#CFSTR_PREFERREDDROPEFFECT"&gt;CFSTR_PREFERREDDROPEFFECT&lt;/A&gt; - What kind of operation (copy/move/link) the source would &lt;STRONG&gt;like&lt;/STRONG&gt; to happen &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#CFSTR_PERFORMEDDROPEFFECT" mce_href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#CFSTR_PERFORMEDDROPEFFECT"&gt;CFSTR_PERFORMEDDROPEFFECT&lt;/A&gt; - What kind of operation (copy/move/link) actually &lt;STRONG&gt;did&lt;/STRONG&gt; happen &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;And here's another which is relevant enough that I wrote code to support it, though I'll only mention it once more here: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#CFSTR_PASTESUCCEEDED" mce_href="http://msdn.microsoft.com/en-us/library/bb776902(VS.85).aspx#CFSTR_PASTESUCCEEDED"&gt;CFSTR_PASTESUCCEEDED&lt;/A&gt; - Indication that a paste succeeded and what kind of operation (copy/move/link) it did &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Armed with that knowledge, let's tweak the sample application so one of the scenarios does a move/cut instead of a copy: &lt;/P&gt;&lt;IMG alt="VirtualFileDataObjectDemo sample application" src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Move.png" width=400 height=400 mce_src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Move.png"&gt; 
&lt;P&gt;The first tweak to the code modifies our helper function to accept a &lt;CODE&gt;DragDropEffects&lt;/CODE&gt; parameter so the caller can indicate its copy/move preference with the new &lt;CODE&gt;PreferredDropEffect&lt;/CODE&gt; property in the clipboard scenario: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; DoDragDropOrClipboardSetDataObject(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseButton&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; button, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; dragSource,
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; virtualFileDataObject, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DragDropEffects&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; allowedEffects)
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;try
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (button == &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseButton&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Left)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Left button is used to start a drag/drop operation
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.DoDragDrop(dragSource, virtualFileDataObject, allowedEffects);
        }
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (button == &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseButton&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Right)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Right button is used to copy to the clipboard
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Communicate the preferred behavior to the destination
&lt;/SPAN&gt;            &lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #000000"&gt;virtualFileDataObject.PreferredDropEffect = allowedEffects;&lt;/SPAN&gt;&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #2b91af"&gt;Clipboard&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.SetDataObject(virtualFileDataObject);
        }
    }
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;catch&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;COMException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Failure; no way to recover
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    }
}
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Then we can tweak the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; constructor to pass a custom "end" action that uses the new &lt;CODE&gt;PerformedDropEffect&lt;/CODE&gt; property to find out what action took place. If the target performed a move (or a cut with the clipboard), then we'll hide the corresponding "button" to reflect that fact: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; VirtualFile_MouseButtonDown(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; sender, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MouseButtonEventArgs&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; e)
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; virtualFileDataObject = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
        (vfdo) =&amp;gt;
        {
            &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DragDropEffects&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Move == vfdo.PerformedDropEffect)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Hide the element that was moved (or cut)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// BeginInvoke ensures UI operations happen on the right thread
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                Dispatcher.BeginInvoke((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Action&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(() =&amp;gt; VirtualFile.Visibility = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Hidden));
            }
        });

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Provide a virtual file (generated on demand) containing the letters 'a'-'z'
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    ...

    DoDragDropOrClipboardSetDataObject(e.ChangedButton, TextUrl, virtualFileDataObject, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DragDropEffects&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Move);
}
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Please note that the begin/end actions are now of type &lt;CODE&gt;Action&amp;lt;VirtualFileDataObject&amp;gt;&lt;/CODE&gt;. The new parameter is always a reference to the active &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; instance and is provided to make it easy to use anonymous methods like you see above. &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: Otherwise you'd need to capture the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; instance so you could pass it to the action being provided to that same instance's constructor! (&lt;A href="http://en.wikipedia.org/wiki/Catch-22" mce_href="http://en.wikipedia.org/wiki/Catch-22"&gt;Catch-22&lt;/A&gt; much?) While there may be a clever way to do this without making the begin/end actions properties of the class (which I didn't want to do because that wouldn't ensure they're invariant), passing the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; in this manner is both easy and obvious. &lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Further aside&lt;/STRONG&gt;: As a consequence of the changes to support these new properties, &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; now implements the &lt;A href="http://msdn.microsoft.com/en-us/library/ms686626(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms686626(VS.85).aspx"&gt;IDataObject::SetData method&lt;/A&gt; for &lt;CODE&gt;HGLOBAL&lt;/CODE&gt;-style data. So if there's some other &lt;CODE&gt;CFSTR_&lt;/CODE&gt; property that's relevant to your scenario, you can query it off the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; instance in much the same manner! &lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/VirtualFileDataObjectDemo/VirtualFileDataObjectDemo.zip" mce_href="http://cesso.org/Samples/VirtualFileDataObjectDemo/VirtualFileDataObjectDemo.zip"&gt;[Click here to download the complete code for VirtualFileDataObject and the sample application.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And that's pretty much all there is to it! With the addition of &lt;CODE&gt;PreferredDropEffect&lt;/CODE&gt; and &lt;CODE&gt;PerformedDropEffect&lt;/CODE&gt; (and &lt;CODE&gt;PasteSucceeded&lt;/CODE&gt;, though it's not demonstrated above), &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; makes it easy for your application to provide a seamless virtual file drag/drop experience with all the sophisticated nuances users expect from a polished Windows application. &lt;/P&gt;
&lt;P&gt;Enjoy! &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923072" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Technical/default.aspx">Technical</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Creating something from nothing, asynchronously [Developer-friendly virtual file implementation for .NET improved!]</title><link>http://blogs.msdn.com/delay/archive/2009/11/04/creating-something-from-nothing-asynchronously-developer-friendly-virtual-file-implementation-for-net-improved.aspx</link><pubDate>Thu, 05 Nov 2009 07:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9917797</guid><dc:creator>Delay</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/delay/comments/9917797.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9917797</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;Last week &lt;A href="http://blogs.msdn.com/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx"&gt;I posted the code for VirtualFileDataObject, an easy-to-use implementation of virtual files for .NET and WPF&lt;/A&gt;. This code implements the standard &lt;A href="http://msdn.microsoft.com/en-us/library/ms688421(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms688421(VS.85).aspx"&gt;IDataObject COM interface&lt;/A&gt; for drag-and-drop and clipboard operations and is specifically targeted at scenarios where an application wants to allow the user to drag an element to a folder and create a file (or files) dynamically on the drop/paste. The standard .NET APIs for drag-and-drop don't support this scenario, so &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; ended up being a custom implementation of the &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtypes.idataobject.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtypes.idataobject.aspx"&gt;System.Runtime.InteropServices.ComTypes.IDataObject interface&lt;/A&gt;. Fortunately, the specifics aren't too difficult, and a series of posts by &lt;A href="http://blogs.msdn.com/oldnewthing/" mce_href="http://blogs.msdn.com/oldnewthing/"&gt;Raymond Chen&lt;/A&gt; paved the way (in native code). &lt;/P&gt;&lt;IMG alt="VirtualFileDataObjectDemo sample application" src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Demo.png" width=400 height=400 mce_src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Demo.png"&gt; 
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you read my previous post, you may recall there was an issue with the last scenario of the sample: the application became unresponsive while data for the virtual file was downloading from the web. While this unresponsiveness won't be a noticeable for scenarios involving local data, scenarios that create large files or hit the network &lt;STRONG&gt;are&lt;/STRONG&gt; at risk. Well, it's time to find a solution! &lt;/P&gt;
&lt;P&gt;And we don't have to look far: the answer is found in the MSDN documentation for &lt;A href="http://msdn.microsoft.com/en-us/library/bb776905(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb776905(VS.85).aspx"&gt;Transferring Shell Objects with Drag-and-Drop and the Clipboard&lt;/A&gt; under the heading &lt;A href="http://msdn.microsoft.com/en-us/library/bb776904(VS.85).aspx#async" mce_href="http://msdn.microsoft.com/en-us/library/bb776904(VS.85).aspx#async"&gt;Using IAsyncOperation&lt;/A&gt;. As you might expect, we're not the first to notice this behavior; the &lt;A href="http://msdn.microsoft.com/en-us/library/bb776309(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb776309(VS.85).aspx"&gt;IAsyncOperation interface&lt;/A&gt; exists to solve this very problem. So it seems like things ought to be easy - let's just define the interface, implement its five methods (none of which are very complicated), and watch as the sample application stays responsive during the time-consuming download... &lt;/P&gt;
&lt;P&gt;&lt;A href="http://failblog.org/" mce_href="http://failblog.org/"&gt;&lt;STRONG&gt;FAIL&lt;/STRONG&gt;&lt;/A&gt;. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Okay, so that didn't work out quite how we wanted it to. Maybe we defined the interface incorrectly? Maybe we implemented it incorrectly? Or maybe Windows just doesn't support this scenario?? &lt;/P&gt;
&lt;P&gt;No, no, and no. We've done everything right - it's the platform that has betrayed us. &lt;NOBR&gt;:(&lt;/NOBR&gt; Specifically, the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.dragdrop.dodragdrop.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.dragdrop.dodragdrop.aspx"&gt;DragDrop.DoDragDrop method&lt;/A&gt; does something sneaky under the covers: it wraps our respectable &lt;CODE&gt;System.Runtime.InteropServices.ComTypes.IDataObject&lt;/CODE&gt; instance in a &lt;CODE&gt;System.Windows.DataObject&lt;/CODE&gt; wrapper. Because this wrapper object doesn't implement or forward &lt;CODE&gt;IAsyncOperation&lt;/CODE&gt;, it's as if the interface doesn't exist! &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: I have the fortune of working with some of the people who wrote this code in the first place, and I asked why this extra level of indirection was necessary. The answer is that it probably isn't - or at least nobody remembers why it's there or why it couldn't be removed now. So the good news is they'll be looking at changing this behavior in a future release of WPF. The bad news is that the change probably won't happen in time for the upcoming WPF 4 release. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;Be that as it may, it looks like we're going to need to call the COM &lt;A href="http://msdn.microsoft.com/en-us/library/ms678486(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms678486(VS.85).aspx"&gt;DoDragDrop function&lt;/A&gt; directly. Fortunately, there's not much that happens between WPF's &lt;CODE&gt;DragDrop.DoDragDrop&lt;/CODE&gt; and COM's &lt;CODE&gt;DoDragDrop&lt;/CODE&gt;, so there's not much we have to duplicate. That said, we do need to define the &lt;A href="http://msdn.microsoft.com/en-us/library/ms690071(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms690071(VS.85).aspx"&gt;IDropSource interface&lt;/A&gt; and write a custom &lt;CODE&gt;DropSource&lt;/CODE&gt; implementation of its two methods. The nice thing is that both methods are pretty simple and straightforward, so our custom implementation can be private. (And for simplicity's sake, we're not going to bother raising &lt;CODE&gt;DragDrop's&lt;/CODE&gt; &lt;CODE&gt;(Preview)GiveFeedbackEvent&lt;/CODE&gt; or &lt;CODE&gt;(Preview)QueryContinueDragEvent&lt;/CODE&gt; events.) &lt;/P&gt;
&lt;P&gt;Because we've been careful to define the &lt;CODE&gt;VirtualFileDataObject.DoDragDrop&lt;/CODE&gt; replacement method with the same signature as the &lt;CODE&gt;DoDragDrop&lt;/CODE&gt; method it's replacing, updating the sample to use it is trivial. So run the sample again, and - &lt;STRONG&gt;BAM&lt;/STRONG&gt; - no more unresponsive window during the transfer! (For real, this time.) You can switch to the window, resize it, drag it, etc. all during the creation of the virtual file. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But now we've got a bit of a dilemma: if things are happening asynchronously, how can we tell when they're done? The answer lies with the &lt;A href="http://msdn.microsoft.com/en-us/library/bb776312(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb776312(VS.85).aspx"&gt;StartOperation&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/bb776307(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb776307(VS.85).aspx"&gt;EndOperation&lt;/A&gt; methods of the &lt;CODE&gt;IAsyncOperation&lt;/CODE&gt; interface. Per the interface contact, these methods are called at the beginning/end of the asynchronous operation. So if we just add another constructor to the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; class, we can wire things up in the obvious manner: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Initializes a new instance of the VirtualFileDataObject class.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="startAction"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Optional action to run at the start of the data transfer.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="endAction"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Optional action to run at the end of the data transfer.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; VirtualFileDataObject(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Action&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; startAction, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Action&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; endAction)
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Well, almost... The catch is that while &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; now &lt;STRONG&gt;supports&lt;/STRONG&gt; asynchronous mode, there's no guarantee that the drop target will &lt;STRONG&gt;use&lt;/STRONG&gt; it. Additionally, the developer may have specifically set the &lt;CODE&gt;VirtualFileDataObject.IsAsynchronous&lt;/CODE&gt; property to &lt;CODE&gt;false&lt;/CODE&gt; to disable asynchronous mode. And when you're in synchronous mode, there aren't any handy begin/end notifications to rely on... &lt;/P&gt;
&lt;P&gt;So I've added support to &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; for calling the begin/end actions in synchronous mode based on some semi-educated guesses. In my testing, the notifications during synchronous mode behave as identically as possible to those in asynchronous mode. Granted, in some scenarios &lt;CODE&gt;startAction&lt;/CODE&gt; may run a little earlier in synchronous mode than it would have for asynchronous mode - but as far as the typical developer is concerned, &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; offers the same handy behavior for &lt;STRONG&gt;both&lt;/STRONG&gt; modes! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's celebrate by updating the sample to show a simple busy indicator during the download: &lt;/P&gt;&lt;IMG alt="VirtualFileDataObjectDemo sample application" src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Busy.png" width=400 height=400 mce_src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Busy.png"&gt; 
&lt;P&gt;Code-wise, once we've updated the call to &lt;CODE&gt;DoDragDrop&lt;/CODE&gt;: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.DoDragDrop(dragSource, virtualFileDataObject, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DragDropEffects&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Copy);&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Everything else stays the same except for the constructor: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; virtualFileDataObject = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// BeginInvoke ensures UI operations happen on the right thread
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    () =&amp;gt; Dispatcher.BeginInvoke((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Action&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(() =&amp;gt; BusyScreen.Visibility = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Visible)),
    () =&amp;gt; Dispatcher.BeginInvoke((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Action&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(() =&amp;gt; BusyScreen.Visibility = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Visibility&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Collapsed)));
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;CODE&gt;BusyScreen&lt;/CODE&gt; variable above corresponds to a new element in the sample application that provides the simple "Busy..." UI shown above. In real life, we'd probably use MVVM and a &lt;CODE&gt;bool&lt;/CODE&gt; &lt;CODE&gt;IsBusy&lt;/CODE&gt; property on our data model to trigger this, but for a sample application, toggling &lt;CODE&gt;Visibility&lt;/CODE&gt; works fine. Because all the hard work is done by the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; class [you're welcome! &lt;NOBR&gt;:)&lt;/NOBR&gt; ], the application remains unencumbered by complex logic for &lt;STRONG&gt;anything&lt;/STRONG&gt; related to the management of virtual files. &lt;/P&gt;
&lt;P&gt;Which is the way it should be! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/VirtualFileDataObjectDemo/VirtualFileDataObjectDemo.zip" mce_href="http://cesso.org/Samples/VirtualFileDataObjectDemo/VirtualFileDataObjectDemo.zip"&gt;[Click here to download the complete code for VirtualFileDataObject and the sample application.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PS&lt;/STRONG&gt; - I have one more post planned on this topic demonstrating something I haven't touched on yet to help applications coordinate better with the shell. Stay tuned... &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9917797" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Technical/default.aspx">Technical</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category></item><item><title>As the platform evolves, so do the workarounds [Better SetterValueBindingHelper makes Silverlight Setters better-er!]</title><link>http://blogs.msdn.com/delay/archive/2009/11/02/as-the-platform-evolves-so-do-the-workarounds-better-settervaluebindinghelper-makes-silverlight-setters-better-er.aspx</link><pubDate>Mon, 02 Nov 2009 18:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916283</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9916283.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9916283</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;Back in May, I mentioned that Silverlight 2 and 3 don't support putting a &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.data.binding(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.data.binding(VS.95).aspx"&gt;Binding&lt;/A&gt; in the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.setter.value(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.setter.value(VS.95).aspx"&gt;Value&lt;/A&gt; of a &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.setter(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.setter(VS.95).aspx"&gt;Setter&lt;/A&gt;. I explained why this is useful (ex: MVVM, &lt;CODE&gt;TreeView&lt;/CODE&gt; expansion, developer/designer separation, etc.) and &lt;A href="http://blogs.msdn.com/delay/archive/2009/05/07/one-more-platform-difference-more-or-less-tamed-settervaluebindinghelper-makes-silverlight-setters-better.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/05/07/one-more-platform-difference-more-or-less-tamed-settervaluebindinghelper-makes-silverlight-setters-better.aspx"&gt;shared a helper class I wrote to implement the intended functionality on Silverlight&lt;/A&gt;. My workaround supported setters for normal &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty(VS.95).aspx"&gt;DependencyProperty&lt;/A&gt;s as well as attached ones, so it covered all the bases. It worked well on both flavors of Silverlight and a bunch of you went off and used &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; successfully in your own projects. &lt;/P&gt;
&lt;P&gt;The sun was shining, birds were chirping, and all was right with (that part of) the world... &lt;/P&gt;&lt;IMG alt="SetterValueBindingHelperDemo sample" src="http://blogs.msdn.com/blogfiles/delay/SetterValueBindingHelperDemo.png" width=488 height=380 mce_src="http://blogs.msdn.com/blogfiles/delay/SetterValueBindingHelperDemo.png"&gt; 
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now flash forward to a few days ago when I was contacted by fellow Silverlight team members &lt;A href="http://www.sitechno.com/blog/" mce_href="http://www.sitechno.com/blog/"&gt;RJ Boeke&lt;/A&gt; and Vinoo Cherian with a report that certain uses of &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; which worked fine on Silverlight 2 and 3 were likely to break if used in a possible future version of Silverlight that was more consistent with WPF's handling of such things. You can imagine my astonishment and dismay... &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Important aside&lt;/STRONG&gt;: The Silverlight team takes backward compatibility &lt;STRONG&gt;very&lt;/STRONG&gt; seriously, so running any Silverlight 2 or 3 application with &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; on such a future version of Silverlight would continue to work in the expected manner. The Silverlight team makes a concerted effort to ensure that each version of Silverlight is "bug compatible" with previous versions to prevent existing applications from suddenly breaking when a new version of Silverlight comes out. &lt;STRONG&gt;However&lt;/STRONG&gt;, were someone to recompile such an application to target a newer release of Silverlight, that application would no longer be subject to the backwards compatibility quirks and would begin seeing the new (more correct/consistent) platform behavior. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;RJ and Vinoo pointed out that a more WPF-consistent handling of &lt;CODE&gt;Style&lt;/CODE&gt;s would break one of the samples that was part of my original blog post. Specifically, the following example would &lt;STRONG&gt;not&lt;/STRONG&gt; have the first &lt;CODE&gt;Binding&lt;/CODE&gt; applied (note: per convention, code in &lt;EM&gt;italics&lt;/EM&gt; is wrong): &lt;/P&gt;&lt;EM&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Button"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- WPF syntax:
    &amp;lt;Setter Property="Grid.Column" Value="{Binding}"/&amp;gt;
    &amp;lt;Setter Property="Grid.Row" Value="{Binding}"/&amp;gt; --&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="local:SetterValueBindingHelper.PropertyBinding"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;local&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SetterValueBindingHelper
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="System.Windows.Controls.Grid, System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Column"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="local:SetterValueBindingHelper.PropertyBinding"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;local&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SetterValueBindingHelper
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Grid"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Row"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;               &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/EM&gt;
&lt;P&gt;What's important to note is that two &lt;CODE&gt;Setter&lt;/CODE&gt;s are both setting the &lt;STRONG&gt;same&lt;/STRONG&gt; &lt;CODE&gt;Property&lt;/CODE&gt; (&lt;CODE&gt;local:SetterValueBindingHelper.PropertyBinding&lt;/CODE&gt;) and WPF optimizes this scenario to only apply the last &lt;CODE&gt;Value&lt;/CODE&gt; it sees. Clearly, it was time to think about how tweak &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; so it would work with this theoretical future release of Silverlight... &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Tangential aside&lt;/STRONG&gt;: This kind of platform change wouldn't affect just &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; - &lt;STRONG&gt;any&lt;/STRONG&gt; place where multiple &lt;CODE&gt;Setter&lt;/CODE&gt;s targeted the same &lt;CODE&gt;Property&lt;/CODE&gt; would behave differently. But that difference won't matter 99% of the time - &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; is fairly unique in its need that every &lt;CODE&gt;Value&lt;/CODE&gt; be applied. &lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One idea for a fix is to expose something like &lt;CODE&gt;PropertyBinding&lt;U&gt;2&lt;/U&gt;&lt;/CODE&gt; from &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; and treat it just like another &lt;CODE&gt;PropertyBinding&lt;/CODE&gt;. While that would definitely work, how do we know that two properties is enough? What if you need three or four? No, despite its simplicity, this is not the flexible solution we're looking for. &lt;/P&gt;
&lt;P&gt;Taking a step back, what we really want is to somehow provide an arbitrary number of &lt;CODE&gt;Property&lt;/CODE&gt;/&lt;CODE&gt;Binding&lt;/CODE&gt; pairs instead of being limited to just one. And if you read that last sentence and thought &lt;EM&gt;"Collection!"&lt;/EM&gt;, I like the way you think. &lt;NOBR&gt;:)&lt;/NOBR&gt; Specifically, what if the same &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; class we're already using to provide the attached &lt;CODE&gt;DependencyProperty&lt;/CODE&gt; &lt;STRONG&gt;and&lt;/STRONG&gt; the data for it were &lt;STRONG&gt;also&lt;/STRONG&gt; capable of storing a collection of other &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; objects? Yeah, sure, that would work! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So let's lay a few ground rules to help guide us: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Every current use of &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; should continue to be valid after we make our changes. In other words, upgrading should be a simple matter of dropping in the new &lt;CODE&gt;SetterValueBindingHelper.cs&lt;/CODE&gt; file and that's all. &lt;/LI&gt;
&lt;LI&gt;The new &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; syntax should work correctly for the current Silverlight 3 release as well as this mythical future version of Silverlight with the WPF-consistent &lt;CODE&gt;Style&lt;/CODE&gt; changes. &lt;/LI&gt;
&lt;LI&gt;The new collection syntax should be easy to use and easy to understand. &lt;/LI&gt;
&lt;LI&gt;Arbitrary nesting is unnecessary; either someone's using a &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; on its own, or else they're using it as a container for a single, nested layer of &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; children. &lt;/LI&gt;
&lt;LI&gt;We could try to be fancy and let children inherit things from their parent, but it's not actually as useful as it seems. Let's not go there and instead keep everything simple and consistent. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Keeping these guidelines in mind, the resulting changes to &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; give us the following alternate representation of the above XAML which works fine on Silverlight 3 today and will also give the desired effect on a possible future version of Silverlight with the WPF optimization: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Button"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- WPF syntax:
    &amp;lt;Setter Property="Grid.Column" Value="{Binding}"/&amp;gt;
    &amp;lt;Setter Property="Grid.Row" Value="{Binding}"/&amp;gt; --&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="delay:SetterValueBindingHelper.PropertyBinding"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;delay&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;delay&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SetterValueBindingHelper
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="System.Windows.Controls.Grid, System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Column"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;delay&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SetterValueBindingHelper
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Grid"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Row"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                   &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;delay&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter.Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: The two different ways of identifying &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid(VS.95).aspx"&gt;Grid&lt;/A&gt; above are part of the original sample showing that both ways work - in practice, both instances would use the simple "Grid" form. &lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than the namespace change to "delay" (for consistency with my other samples), the only change here is the extra &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt; wrapper you see &lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;highlighted&lt;/SPAN&gt;. Everything else is pretty much the same &lt;STRONG&gt;and&lt;/STRONG&gt; now it works on imaginary versions of Silverlight, too! &lt;NOBR&gt;:)&lt;/NOBR&gt; So if you're working on an app and you find yourself needing &lt;CODE&gt;SetterValueBindingHelper&lt;/CODE&gt;, please use this latest version; you can rest assured that you're future-proof. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/SetterValueBindingHelperDemo/SetterValueBindingHelperDemo.zip" mce_href="http://cesso.org/Samples/SetterValueBindingHelperDemo/SetterValueBindingHelperDemo.zip"&gt;[Click here to download the complete source code for SetterValueBindingHelper and its sample application.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the updated code in its entirety. Please note that I have used a normal (i.e., non-observable) collection, so dynamic updates to the &lt;CODE&gt;Values&lt;/CODE&gt; property are not supported. This was a deliberate decision to minimize complexity. (And besides, I've never heard of anyone modifying the contents of a &lt;CODE&gt;Style&lt;/CODE&gt; dynamically.) &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Class that implements a workaround for a Silverlight XAML parser
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; limitation that prevents the following syntax from working:
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;    &amp;amp;lt;Setter Property="IsSelected" Value="{Binding IsSelected}"/&amp;amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;[&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ContentProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Values"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)]
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Optional type parameter used to specify the type of an attached
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; DependencyProperty as an assembly-qualified name, full name, or
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; short name.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    [&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SuppressMessage&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Microsoft.Naming"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"CA1721:PropertyNamesShouldNotMatchGetMethods"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
        Justification = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Unambiguous in XAML."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)]
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Type { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Property name for the normal/attached DependencyProperty on which
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; to set the Binding.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Property { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Binding to set on the specified property.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Binding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Binding { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Collection of SetterValueBindingHelper instances to apply to the
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; target element.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;remarks&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Used when multiple Bindings need to be applied to the same element.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/remarks&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Collection&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; Values
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Defer creating collection until needed
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == _values)
            {
                _values = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Collection&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt;();
            }
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _values;
        }
    }
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Collection&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; _values;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Gets the value of the PropertyBinding attached DependencyProperty.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="element"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Element for which to get the property.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;returns&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Value of PropertyBinding attached DependencyProperty.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/returns&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    [&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SuppressMessage&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Microsoft.Design"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"CA1011:ConsiderPassingBaseTypesAsParameters"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
        Justification = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"SetBinding is only available on FrameworkElement."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)]
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; GetPropertyBinding(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FrameworkElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == element)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentNullException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"element"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        }
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)element.GetValue(PropertyBindingProperty);
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Sets the value of the PropertyBinding attached DependencyProperty.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="element"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Element on which to set the property.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="value"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Value forPropertyBinding attached DependencyProperty.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    [&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SuppressMessage&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Microsoft.Design"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"CA1011:ConsiderPassingBaseTypesAsParameters"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
        Justification = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"SetBinding is only available on FrameworkElement."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)]
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetPropertyBinding(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FrameworkElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; value)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == element)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentNullException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"element"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        }
        element.SetValue(PropertyBindingProperty, value);
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; PropertyBinding attached DependencyProperty.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;readonly&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; PropertyBindingProperty =
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.RegisterAttached(
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"PropertyBinding"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;typeof&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;),
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;typeof&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;),
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;PropertyMetadata&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, OnPropertyBindingPropertyChanged));

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Change handler for the PropertyBinding attached DependencyProperty.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="d"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Object on which the property was changed.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="e"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Property change arguments.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; OnPropertyBindingPropertyChanged(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; d, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyPropertyChangedEventArgs&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; e)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get/validate parameters
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FrameworkElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)d;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; item = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(e.NewValue);

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == item.Values) || (0 == item.Values.Count))
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// No children; apply the relevant binding
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            ApplyBinding(element, item);
        }
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Apply the bindings of each child
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; child &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; item.Values)
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; != item.Property) || (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; != item.Binding))
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"A SetterValueBindingHelper with Values may not have its Property or Binding set."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                }
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (0 != child.Values.Count)
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Values of a SetterValueBindingHelper may not have Values themselves."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                }
                ApplyBinding(element, child);
            }
        }
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Applies the Binding represented by the SetterValueBindingHelper.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="element"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Element to apply the Binding to.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="item"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;SetterValueBindingHelper representing the Binding.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ApplyBinding(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FrameworkElement&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; element, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SetterValueBindingHelper&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; item)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == item.Property) || (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == item.Binding))
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"SetterValueBindingHelper's Property and Binding must both be set to non-null values."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        }

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get the type on which to set the Binding
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; type = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == item.Type)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// No type specified; setting for the specified element
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            type = element.GetType();
        }
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Try to get the type from the type system
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            type = System.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetType(item.Type);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == type)
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Search for the type in the list of assemblies
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; assembly &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; AssembliesToSearch)
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Match on short or full name
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                    type = assembly.GetTypes()
                        .Where(t =&amp;gt; (t.FullName == item.Type) || (t.Name == item.Type))
                        .FirstOrDefault();
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; != type)
                    {
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Found; done searching
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;break&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
                    }
                }
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == type)
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Unable to find the requested type anywhere
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.CurrentCulture,
                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Unable to access type \"{0}\". Try using an assembly qualified type name."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
                        item.Type));
                }
            }
        }

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Get the DependencyProperty for which to set the Binding
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; property = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; field = type.GetField(item.Property + &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Property"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;BindingFlags&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.FlattenHierarchy | &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;BindingFlags&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Public | &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;BindingFlags&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Static);
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; != field)
        {
            property = field.GetValue(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;as&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DependencyProperty&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
        }
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; == property)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Unable to find the requsted property
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;throw&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ArgumentException&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Format(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;CultureInfo&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.CurrentCulture,
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Unable to access DependencyProperty \"{0}\" on type \"{1}\"."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
                item.Property, type.Name));
        }

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Set the specified Binding on the specified property
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        element.SetBinding(property, item.Binding);
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Returns a stream of assemblies to search for the provided type name.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;IEnumerable&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assembly&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; AssembliesToSearch
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Start with the System.Windows assembly (home of all core controls)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;yield&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;typeof&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Control&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;).Assembly;

            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Fall back by trying each of the assemblies in the Deployment's Parts list
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; part &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Deployment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Current.Parts)
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; streamResourceInfo = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Application&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetResourceStream(
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(part.Source, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UriKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Relative));
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; stream = streamResourceInfo.Stream)
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;yield&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; part.Load(stream);
                }
            }
        }
    }
}
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916283" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category></item><item><title>My new home page, revised [Updated collection of great Silverlight/WPF Data Visualization resources!]</title><link>http://blogs.msdn.com/delay/archive/2009/10/28/my-new-home-page-revised-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx</link><pubDate>Wed, 28 Oct 2009 17:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9914196</guid><dc:creator>Delay</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/delay/comments/9914196.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9914196</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;In the time since sharing &lt;A href="http://blogs.msdn.com/delay/archive/2009/07/19/my-new-home-page-enhanced-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/19/my-new-home-page-enhanced-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx"&gt;my last collection of Silverlight/WPF Charting links&lt;/A&gt;, there have been some great new articles I'd like to highlight. And in case you haven't heard, we published the &lt;A href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514" mce_href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514"&gt;October 09&lt;/A&gt; release of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; last week, so please consider upgrading if you haven't already! &lt;/P&gt;
&lt;P&gt;Here are the latest links (FYI: previously published links are gray): &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Overviews (&lt;A href="http://support.microsoft.com/default.aspx?scid=gp;en-us;WebCastLevels&amp;amp;sd=gn" mce_href="http://support.microsoft.com/default.aspx?scid=gp;en-us;WebCastLevels&amp;amp;sd=gn"&gt;100 level&lt;/A&gt;) &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://timheuer.com/blog/archive/2008/10/28/silverlight-toolkit-released-with-charting-databinding.aspx" mce_href="http://timheuer.com/blog/archive/2008/10/28/silverlight-toolkit-released-with-charting-databinding.aspx"&gt;Silverlight Toolkit Released – More controls!&lt;/A&gt; - &lt;STRONG&gt;Tim Heuer&lt;/STRONG&gt;'s &lt;EM&gt;during the PDC keynote&lt;/EM&gt; overview set the stage for good Charting content. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2008/10/28/Silverlight-Toolkit-_2800_Silverlight-2-Control-Pack_2900_-_2D00_-Charting.aspx" mce_href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2008/10/28/Silverlight-Toolkit-_2800_Silverlight-2-Control-Pack_2900_-_2D00_-Charting.aspx"&gt;Silverlight Toolkit (Silverlight 2 Control Pack) - Charting &lt;/A&gt;- &lt;STRONG&gt;Pete Brown&lt;/STRONG&gt; followed up minutes later with another good overview. (Party trivia: The styles seen in his blog offer a rare glimpse of the pre-release Charting styles.) &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blog.ecofic.com/?p=133" mce_href="http://blog.ecofic.com/?p=133"&gt;Silverlight - Introducing the Chart Control&lt;/A&gt; - &lt;STRONG&gt;Chad Campbell&lt;/STRONG&gt; was also ready with a good "zero-day" overview and code samples. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.hanselman.com/blog/TheWeeklySourceCode36PDCBabySmashAndSilverlightCharting.aspx" mce_href="http://www.hanselman.com/blog/TheWeeklySourceCode36PDCBabySmashAndSilverlightCharting.aspx"&gt;The Weekly Source Code 36 - PDC, BabySmash and Silverlight Charting&lt;/A&gt; - &lt;STRONG&gt;Scott Hanselman&lt;/STRONG&gt;'s post includes a &lt;A href="http://www.babysmash.com/" mce_href="http://www.babysmash.com/"&gt;BabySmash&lt;/A&gt; tie-in and a smidge of flattery. :) &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://silverlight.net/blogs/jesseliberty/archive/2008/11/24/graphing-silverlight-toolkit.aspx" mce_href="http://silverlight.net/blogs/jesseliberty/archive/2008/11/24/graphing-silverlight-toolkit.aspx"&gt;Graphing – Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Jesse Liberty&lt;/STRONG&gt; introduces Charting and covers some of the basics. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://silverlight.net/blogs/jesseliberty/archive/2008/12/17/bubble-chart.aspx" mce_href="http://silverlight.net/blogs/jesseliberty/archive/2008/12/17/bubble-chart.aspx"&gt;Bubble chart&lt;/A&gt; - &lt;STRONG&gt;Jesse Liberty&lt;/STRONG&gt; introduces the BubbleSeries class and describes some interesting use-cases. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.sparklingclient.com/the-bubble-chart-in-the-silverlight-toolkit/" mce_href="http://www.sparklingclient.com/the-bubble-chart-in-the-silverlight-toolkit/"&gt;The Bubble Chart in the Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Sparkling Client&lt;/STRONG&gt; interviews &lt;STRONG&gt;Jesse Liberty&lt;/STRONG&gt; in this podcast discussing the BubbleSeries. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://jeffblankenburg.com/2009/07/day-15-silverlight-charting.aspx" mce_href="http://jeffblankenburg.com/2009/07/day-15-silverlight-charting.aspx"&gt;Day #15: Silverlight Charting&lt;/A&gt; - &lt;STRONG&gt;Jeff Blankenburg&lt;/STRONG&gt; gives a nice overview of Charting and demonstrates how easy it is to switch series types along the way. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Scenarios (200 level) &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.sitechno.com/Blog/ZoomingIntoAChart.aspx" mce_href="http://www.sitechno.com/Blog/ZoomingIntoAChart.aspx"&gt;Zooming into a chart&lt;/A&gt; - &lt;STRONG&gt;Ruurd Boeke&lt;/STRONG&gt; did the "zooming" scenario sample for the &lt;A href="http://silverlight.net/samples/sl2/toolkitcontrolsamples/run/default.html" mce_href="http://silverlight.net/samples/sl2/toolkitcontrolsamples/run/default.html"&gt;live Charting samples page&lt;/A&gt; - here's how he did it. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blog.ecofic.com/?p=155" mce_href="http://blog.ecofic.com/?p=155"&gt;Silverlight - Getting Started with the Chart Control&lt;/A&gt; - &lt;STRONG&gt;Chad Campbell &lt;/STRONG&gt;again - a thorough walkthrough of creating your first chart. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.eggheadcafe.com/tutorials/aspnet/5b0c5717-2817-47a5-bd20-1bbdc0ab1240/silverlight-2-custom-stoc.aspx" mce_href="http://www.eggheadcafe.com/tutorials/aspnet/5b0c5717-2817-47a5-bd20-1bbdc0ab1240/silverlight-2-custom-stoc.aspx"&gt;Silverlight 2 Custom Stock Charts With Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Peter Bromberg&lt;/STRONG&gt; with his own walkthrough - creating a stock chart with plenty of code. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2008/10/31/Styling-the-Charts-in-the-Silverlight-Toolkit.aspx" mce_href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2008/10/31/Styling-the-Charts-in-the-Silverlight-Toolkit.aspx"&gt;Styling the Charts in the Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Pete Brown&lt;/STRONG&gt; again - this time with a good styling overview for designers. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/mehdis/archive/2008/11/11/designer-s-guide-to-styling-silverlight-toolkit-charting-controls.aspx" mce_href="http://blogs.msdn.com/mehdis/archive/2008/11/11/designer-s-guide-to-styling-silverlight-toolkit-charting-controls.aspx"&gt;Designer’s Guide to Styling Silverlight Toolkit Charting Controls&lt;/A&gt; - &lt;STRONG&gt;Mehdi Slaoui Andaloussi&lt;/STRONG&gt; goes over the top with a &lt;A href="http://en.wikipedia.org/wiki/Soup_to_nuts" mce_href="http://en.wikipedia.org/wiki/Soup_to_nuts"&gt;"soup to nuts"&lt;/A&gt; designer-oriented guide to styling &lt;EM&gt;everything&lt;/EM&gt;. It probably helps that Mehdi works on my team and authored the shipping styles for Charting as well. :) &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2008/12/04/Pie-Chart-Styling-in-the-Silverlight-Toolkit-_2D00_-Cross_2D00_Slice-Gradients.aspx" mce_href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2008/12/04/Pie-Chart-Styling-in-the-Silverlight-Toolkit-_2D00_-Cross_2D00_Slice-Gradients.aspx"&gt;Pie Chart Styling in the Silverlight Toolkit - Cross-Slice Gradients&lt;/A&gt; - &lt;STRONG&gt;Pete Brown&lt;/STRONG&gt; takes a proof-of-concept for holistic pie chart styling and uses it to &lt;EM&gt;great&lt;/EM&gt; effect. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://silverlight.net/blogs/jesseliberty/archive/2008/12/18/bubbles-1-chart-three-axes.aspx" mce_href="http://silverlight.net/blogs/jesseliberty/archive/2008/12/18/bubbles-1-chart-three-axes.aspx"&gt;Bubbles – 1 Chart – three Axes&lt;/A&gt; - &lt;STRONG&gt;Jesse Liberty&lt;/STRONG&gt; takes advantage of BubbleSeries to visualize historical data in an interesting way. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://kevindockx.blogspot.com/2008/12/customizing-labels-on-axis-of.html" mce_href="http://kevindockx.blogspot.com/2008/12/customizing-labels-on-axis-of.html"&gt;Customizing the Labels on an Axis of the Silverlight Toolkit Chart&lt;/A&gt; - &lt;STRONG&gt;Kevin Dockx&lt;/STRONG&gt; calls out the AxisLabelStyle property which allows designers to easily customize the labels of an axis. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2009/01/09/Dazzling-Silverlight-Toolkit-Pie-Charts-with-Overlays.aspx" mce_href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2009/01/09/Dazzling-Silverlight-Toolkit-Pie-Charts-with-Overlays.aspx"&gt;Dazzling Silverlight Toolkit Pie Charts with Overlays&lt;/A&gt; - &lt;STRONG&gt;Pete Brown&lt;/STRONG&gt; continues working with pie charts and creates a further level of polish by adding some shiny overlays that make the visuals "pop". &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.jeff.wilcox.name/2008/12/10/charting-rich-tooltips/" mce_href="http://www.jeff.wilcox.name/2008/12/10/charting-rich-tooltips/"&gt;Silverlight Charting: Creating rich data point tooltips&lt;/A&gt; - &lt;STRONG&gt;Jeff Wilcox&lt;/STRONG&gt; shows how he customized the ToolTips of a LineSeries to show a wealth of information relevant information in a very user-friendly manner. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://silverlight.net/blogs/jesseliberty/archive/2009/01/10/pie-chart-and-column-chart-videos-post.aspx" mce_href="http://silverlight.net/blogs/jesseliberty/archive/2009/01/10/pie-chart-and-column-chart-videos-post.aspx"&gt;Pie Chart and Column Chart videos post&lt;/A&gt; - &lt;STRONG&gt;Jesse Liberty&lt;/STRONG&gt; demonstrates the use of PieSeries and ColumnSeries in a set of "How Do I" videos. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://expression.microsoft.com/en-us/dd433476.aspx" mce_href="http://expression.microsoft.com/en-us/dd433476.aspx"&gt;Styling Charts with the Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Pete Brown&lt;/STRONG&gt;'s comprehensive &lt;A href="http://expression.microsoft.com/en-us/default.aspx" mce_href="http://expression.microsoft.com/en-us/default.aspx"&gt;Expression Newsletter&lt;/A&gt; article provides some of the best information available anywhere about Charting styling! &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.codeproject.com/KB/WPF/WPFSLChart.aspx" mce_href="http://www.codeproject.com/KB/WPF/WPFSLChart.aspx"&gt;Styling a Silverlight Chart&lt;/A&gt; - &lt;STRONG&gt;Rudi Grobler&lt;/STRONG&gt; shows how to re-style a LineSeries to look just like the &lt;A href="http://www.google.com/analytics/" mce_href="http://www.google.com/analytics/"&gt;Google Analytics&lt;/A&gt; charts. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://leeontech.wordpress.com/2009/02/25/linechart-with-markers/" mce_href="http://leeontech.wordpress.com/2009/02/25/linechart-with-markers/"&gt;LineChart with Markers&lt;/A&gt; - &lt;STRONG&gt;Lee&lt;/STRONG&gt; demonstrates one way of adding markers (also known as annotations or cursors) to a Chart. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://leeontech.wordpress.com/2009/03/13/showing-and-hiding-series-in-chart/" mce_href="http://leeontech.wordpress.com/2009/03/13/showing-and-hiding-series-in-chart/"&gt;Showing and Hiding Series in chart&lt;/A&gt; - &lt;STRONG&gt;Lee&lt;/STRONG&gt; neatly solves the problem of hiding (and showing) individual Series by clicking on their entries in the Legend. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://geekswithblogs.net/tkokke/archive/2009/04/01/creating-binding-and-styling-a-bubble-chart.aspx" mce_href="http://geekswithblogs.net/tkokke/archive/2009/04/01/creating-binding-and-styling-a-bubble-chart.aspx"&gt;Creating, Binding and Styling a Bubble Chart&lt;/A&gt; - &lt;STRONG&gt;Timmy Kokke&lt;/STRONG&gt; shows off how some of the new Blend 3 features can be used to completely customize the appearance of a BubbleSeries without writing any code at all. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2009/04/09/Custom-Bar-Charts-with-the-Silverlight-Toolkit.aspx" mce_href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2009/04/09/Custom-Bar-Charts-with-the-Silverlight-Toolkit.aspx"&gt;Custom Bar Charts with the Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Pete Brown&lt;/STRONG&gt; discusses how he went about dramatically customizing the appearance of two Chart types to create a very modern, polished look for a demo app. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.eggheadcafe.com/tutorials/aspnet/2d803e3c-081f-437c-8ee6-8584c1f63683/silverlight-3-displaying.aspx" mce_href="http://www.eggheadcafe.com/tutorials/aspnet/2d803e3c-081f-437c-8ee6-8584c1f63683/silverlight-3-displaying.aspx"&gt;Silverlight 3: Displaying and Charting with TwitterCounter&lt;/A&gt; - &lt;STRONG&gt;Peter Bromberg&lt;/STRONG&gt; shows off an application to display Twitter statistics along with a chart of followers over time. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blog.ecofic.com/?p=130" mce_href="http://blog.ecofic.com/?p=130"&gt;Silverlight - Drill Down Charts Walkthrough&lt;/A&gt; - &lt;STRONG&gt;Chad Campbell&lt;/STRONG&gt; gives a great overview of creating "drill-down" charts - in video form! &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Internals (300 level) &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.scottlogic.co.uk/blog/wpf/2009/02/adding-a-location-crosshair-to-silverlight-charts/" mce_href="http://www.scottlogic.co.uk/blog/wpf/2009/02/adding-a-location-crosshair-to-silverlight-charts/"&gt;Adding a Location Crosshair to Silverlight Charts&lt;/A&gt; - &lt;STRONG&gt;Colin Eberhardt&lt;/STRONG&gt; shows how to add crosshairs on top of a Chart to display the coordinates of the mouse pointer. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.scottlogic.co.uk/blog/wpf/2009/03/adding-a-location-crosshair-to-silverlight-charts-again/" mce_href="http://www.scottlogic.co.uk/blog/wpf/2009/03/adding-a-location-crosshair-to-silverlight-charts-again/"&gt;Adding a Location Crosshair to Silverlight charts (again!)&lt;/A&gt; - &lt;STRONG&gt;Colin Eberhardt&lt;/STRONG&gt; updates his crosshairs post to accommodate changes in the March 09 release. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://www.codeproject.com/KB/silverlight/SLTCandlestickChart2.aspx" mce_href="http://www.codeproject.com/KB/silverlight/SLTCandlestickChart2.aspx"&gt;How to create stock charts using the Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Rudi Grobler&lt;/STRONG&gt; shows how to create a custom Series type that's perfect for stock charts (open/high/low/close). &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/351/Silverlight-Charts-Binding-multiple-Series.aspx" mce_href="http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/351/Silverlight-Charts-Binding-multiple-Series.aspx"&gt;Silverlight Charts: Binding multiple Series&lt;/A&gt; - &lt;STRONG&gt;Jeremiah Morrill&lt;/STRONG&gt; shows off an attached behavior that enables binding a Chart to a "collection of collections" to create an arbitrary number of series automatically. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://leeontech.wordpress.com/2009/03/02/interacting-with-charts/" mce_href="http://leeontech.wordpress.com/2009/03/02/interacting-with-charts/"&gt;Interacting with Charts&lt;/A&gt; - &lt;STRONG&gt;Lee&lt;/STRONG&gt; implements a nice interactive range selection behavior to create a friendly "zoom" feature for controlling the Axis range. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://leeontech.wordpress.com/2009/05/27/interacting-with-charts-2/" mce_href="http://leeontech.wordpress.com/2009/05/27/interacting-with-charts-2/"&gt;Interacting with charts-2&lt;/A&gt; - &lt;STRONG&gt;Lee&lt;/STRONG&gt; shows off a proof-of-concept implementation to add an overlay for the plot area with grippers that enable interactive zooming on an axis. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://bea.stollnitz.com/blog/?p=353" mce_href="http://bea.stollnitz.com/blog/?p=353"&gt;How can I add labels to a WPF pie chart?&lt;/A&gt; - &lt;STRONG&gt;Bea Stollnitz&lt;/STRONG&gt; begins her three-part series about adding annotations to a pie chart with an overview. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://bea.stollnitz.com/blog/?p=363" mce_href="http://bea.stollnitz.com/blog/?p=363"&gt;How can I add labels to a WPF pie chart? - Implementation details&lt;/A&gt; - &lt;STRONG&gt;Bea Stollnitz&lt;/STRONG&gt;'s second post explains how she implemented her pie chart annotations on WPF. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://bea.stollnitz.com/blog/?p=366" mce_href="http://bea.stollnitz.com/blog/?p=366"&gt;How can I port the WPF labeled pie chart to Silverlight?&lt;/A&gt; - &lt;STRONG&gt;Bea Stollnitz&lt;/STRONG&gt;'s final post of the trilogy details how she ported the WPF implementation to Silverlight. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://reyntjes.blogspot.com/2009/09/freeing-axes-of-microsoft-toolkit.html" mce_href="http://reyntjes.blogspot.com/2009/09/freeing-axes-of-microsoft-toolkit.html"&gt;Freeing the axes of the Microsoft toolkit charting control &lt;/A&gt;- &lt;STRONG&gt;Robert&lt;/STRONG&gt; provides an in-depth description of how he created a custom axis behavior and used it to produce a nice stacked chart display. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.cplotts.com/2009/10/09/wpf-silverlight-charting-a-logarithmic-axis/" mce_href="http://www.cplotts.com/2009/10/09/wpf-silverlight-charting-a-logarithmic-axis/"&gt;WPF &amp;amp; Silverlight Charting: A Logarithmic Axis&lt;/A&gt; - &lt;STRONG&gt;Cory Plotts&lt;/STRONG&gt; took it upon himself to write - and share - a LogarithmicAxis implementation that should make some of you very happy! &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Team Member posts (Partner level) &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://themechanicalbride.blogspot.com/2008/10/building-observable-model-in.html" mce_href="http://themechanicalbride.blogspot.com/2008/10/building-observable-model-in.html"&gt;Building an Observable Model in Silverlight&lt;/A&gt; - &lt;STRONG&gt;Jafar Husain&lt;/STRONG&gt; gives some deep, technical detail about the observable model that Charting uses to enable its rich dynamic data support. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://themechanicalbride.blogspot.com/2009/03/writing-your-own-silverlight-chart.html" mce_href="http://themechanicalbride.blogspot.com/2009/03/writing-your-own-silverlight-chart.html"&gt;Writing Your Own Silverlight Chart Series (Part 1): Making Designers Happy&lt;/A&gt; - &lt;STRONG&gt;Jafar Husain&lt;/STRONG&gt; provides an overview of what it takes to create a new Series type and some scaffolding for an &lt;A href="http://en.wikipedia.org/wiki/OHLC" mce_href="http://en.wikipedia.org/wiki/OHLC"&gt;OHLC&lt;/A&gt; Series. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://themechanicalbride.blogspot.com/2009/03/writing-your-own-silverlight-chart_25.html" mce_href="http://themechanicalbride.blogspot.com/2009/03/writing-your-own-silverlight-chart_25.html"&gt;Writing Your Own Silverlight Chart Series (Part 2): Implementing the Series&lt;/A&gt; - &lt;STRONG&gt;Jafar Husain&lt;/STRONG&gt; explains all that it takes to completely implement a custom chart type using only the public interfaces! &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/marlat/archive/2009/07/10/treemap-control-comes-to-silverlight-toolkit.aspx" mce_href="http://blogs.msdn.com/marlat/archive/2009/07/10/treemap-control-comes-to-silverlight-toolkit.aspx"&gt;TreeMap control is coming to Silverlight Toolkit&lt;/A&gt; - &lt;STRONG&gt;Marek Latuskiewicz&lt;/STRONG&gt; introduces the new TreeMap control, explains what Interpolators are, and shows how they work. &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/gpde/pages/treemap-released-in-silverlight-toolkit.aspx" mce_href="http://blogs.msdn.com/gpde/pages/treemap-released-in-silverlight-toolkit.aspx"&gt;Treemap released in Silverlight Toolkit &lt;/A&gt;- &lt;STRONG&gt;Gareth Bradshaw&lt;/STRONG&gt; gives a great TreeMap overview that touches on all the common scenarios. &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/marlat/archive/2009/08/06/treemap-in-silverlight-toolkit-how-to-write-your-own-interpolator.aspx" mce_href="http://blogs.msdn.com/marlat/archive/2009/08/06/treemap-in-silverlight-toolkit-how-to-write-your-own-interpolator.aspx"&gt;TreeMap in Silverlight Toolkit: How to write your own interpolator&lt;/A&gt; - &lt;STRONG&gt;Marek Latuskiewicz&lt;/STRONG&gt; explains more about what Interpolators are, how they're actually used by the TreeMap control, and how to write one yourself! &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;My posts (Ego level) &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2008/10/28/announcing-a-free-open-source-charting-solution-for-silverlight-silverlight-toolkit-released-today-at-pdc.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/10/28/announcing-a-free-open-source-charting-solution-for-silverlight-silverlight-toolkit-released-today-at-pdc.aspx"&gt;Announcing a free, open source Charting solution for Silverlight [Silverlight Toolkit released today at PDC!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2008/10/29/click-your-way-to-great-silverlight-charts-live-chartbuilder-sample-and-source-code.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/10/29/click-your-way-to-great-silverlight-charts-live-chartbuilder-sample-and-source-code.aspx"&gt;Click your way to great Silverlight charts [Live ChartBuilder sample and source code!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2008/11/06/improving-chartbuilder-s-cultural-sensitivity-chartbuilder-app-source-updated.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/11/06/improving-chartbuilder-s-cultural-sensitivity-chartbuilder-app-source-updated.aspx"&gt;Improving ChartBuilder's cultural sensitivity [ChartBuilder app/source updated!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2008/12/09/silverlight-charting-gets-a-host-of-improvements-silverlight-toolkit-december-08-release-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/12/09/silverlight-charting-gets-a-host-of-improvements-silverlight-toolkit-december-08-release-now-available.aspx"&gt;Silverlight Charting gets a host of improvements [Silverlight Toolkit December 08 release now available!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2008/12/10/great-silverlight-charts-are-still-just-a-click-away-chartbuilder-sample-and-source-code-updated-for-charting-s-december-08-release.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/12/10/great-silverlight-charts-are-still-just-a-click-away-chartbuilder-sample-and-source-code-updated-for-charting-s-december-08-release.aspx"&gt;Great Silverlight charts are still just a click away [ChartBuilder sample and source code updated for Charting's December 08 release]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2008/12/30/yummier-pies-a-technique-for-more-flexible-gradient-styling-of-silverlight-toolkit-pie-charts.aspx" mce_href="http://blogs.msdn.com/delay/archive/2008/12/30/yummier-pies-a-technique-for-more-flexible-gradient-styling-of-silverlight-toolkit-pie-charts.aspx"&gt;Yummier pies! [A technique for more flexible gradient styling of Silverlight Toolkit pie charts]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/02/04/columns-of-a-different-color-customizing-the-appearance-of-silverlight-charts-with-re-templating-and-mvvm.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/02/04/columns-of-a-different-color-customizing-the-appearance-of-silverlight-charts-with-re-templating-and-mvvm.aspx"&gt;Columns of a different color [Customizing the appearance of Silverlight charts with re-templating and MVVM]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/03/19/silverlight-charting-is-faster-and-better-than-ever-silverlight-toolkit-march-09-release-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/03/19/silverlight-charting-is-faster-and-better-than-ever-silverlight-toolkit-march-09-release-now-available.aspx"&gt;Silverlight Charting is faster and better than ever [Silverlight Toolkit March 09 release now available!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/03/20/silverlight-charting-remains-just-a-click-away-and-runs-on-wpf-too-chartbuilder-sample-and-source-code-updated-for-charting-s-march-09-release.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/03/20/silverlight-charting-remains-just-a-click-away-and-runs-on-wpf-too-chartbuilder-sample-and-source-code-updated-for-charting-s-march-09-release.aspx"&gt;Silverlight Charting remains just a click away - and runs on WPF, too!! [ChartBuilder sample and source code updated for Charting's March 09 release]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/03/25/supporting-the-unsupported-two-fixes-for-the-unofficial-wpf-charting-assembly.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/03/25/supporting-the-unsupported-two-fixes-for-the-unofficial-wpf-charting-assembly.aspx"&gt;Supporting the unsupported [Two fixes for the unofficial WPF Charting assembly!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/03/26/if-they-can-build-it-they-will-come-enabling-anyone-to-compile-wpf-charting-from-the-silverlight-charting-sources.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/03/26/if-they-can-build-it-they-will-come-enabling-anyone-to-compile-wpf-charting-from-the-silverlight-charting-sources.aspx"&gt;If they can build it, they will come... [Enabling anyone to compile WPF Charting from the Silverlight Charting sources!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/04/22/another-round-of-un-support-quick-fix-for-the-unofficial-wpf-charting-assembly.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/04/22/another-round-of-un-support-quick-fix-for-the-unofficial-wpf-charting-assembly.aspx"&gt;Another round of (un)support [Quick fix for the unofficial WPF Charting assembly!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/05/12/pineapple-upside-down-chart-how-to-invert-the-axis-of-a-chart-for-smaller-is-better-scenarios.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/05/12/pineapple-upside-down-chart-how-to-invert-the-axis-of-a-chart-for-smaller-is-better-scenarios.aspx"&gt;Pineapple upside-down chart [How to: Invert the axis of a chart for "smaller is better" scenarios]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/05/19/chart-tweaking-made-easy-how-to-make-four-simple-color-tooltip-changes-with-silverlight-wpf-charting.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/05/19/chart-tweaking-made-easy-how-to-make-four-simple-color-tooltip-changes-with-silverlight-wpf-charting.aspx"&gt;Chart tweaking made easy [How to: Make four simple color/ToolTip changes with Silverlight/WPF Charting]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/06/15/peanut-butter-jelly-time-how-to-create-a-pleasing-visual-effect-with-silverlight-wpf-charting.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/06/15/peanut-butter-jelly-time-how-to-create-a-pleasing-visual-effect-with-silverlight-wpf-charting.aspx"&gt;Peanut butter jelly time [How to: Create a pleasing visual effect with Silverlight/WPF Charting]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/06/25/wpf-charting-it-s-official-june-2009-release-of-the-wpf-toolkit-is-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/06/25/wpf-charting-it-s-official-june-2009-release-of-the-wpf-toolkit-is-now-available.aspx"&gt;WPF Charting: It's official! [June 2009 release of the WPF Toolkit is now available!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/07/10/silverlight-charting-gets-an-update-and-a-treemap-silverlight-toolkit-july-2009-release-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/10/silverlight-charting-gets-an-update-and-a-treemap-silverlight-toolkit-july-2009-release-now-available.aspx"&gt;Silverlight Charting gets an update - and a TreeMap! [Silverlight Toolkit July 2009 release now available!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI style="COLOR: gray"&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/07/16/bringing-the-silverlight-toolkit-s-treemap-to-wpf-silverlight-wpf-data-visualization-development-release-0.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/16/bringing-the-silverlight-toolkit-s-treemap-to-wpf-silverlight-wpf-data-visualization-development-release-0.aspx"&gt;Bringing the Silverlight Toolkit's TreeMap to WPF [Silverlight/WPF Data Visualization Development Release 0]&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/07/27/simple-column-labels-you-can-create-at-home-re-templating-the-silverlight-wpf-data-visualization-columndatapoint-to-add-annotations.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/27/simple-column-labels-you-can-create-at-home-re-templating-the-silverlight-wpf-data-visualization-columndatapoint-to-add-annotations.aspx"&gt;Simple column labels you can create at home! [Re-Templating the Silverlight/WPF Data Visualization ColumnDataPoint to add annotations]&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx"&gt;A preview of upcoming Charting changes [Silverlight/WPF Data Visualization Development Release 1]&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx"&gt;Silverlight (and WPF) Data Visualization classes unsealed [Silverlight Toolkit October 2009 release now available!]&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx"&gt;Two birds, one stone [Silverlight/WPF Data Visualization Development Release 2 and DataVisualizationDemos update]&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Many, many thanks to everyone who's spent time helping others learn how to use Silverlight/WPF Data Visualization! &lt;/P&gt;
&lt;P&gt;PS - If I've missed any good resources, please leave a comment with a link - I'm always happy to find more good stuff! &lt;NOBR&gt;:)&lt;/NOBR&gt; 
&lt;P&gt;&lt;STRONG&gt;PPS - The most recent version of this collection will always be pointed to by &lt;A href="http://cesso.org/r/DVLinks" mce_href="http://cesso.org/r/DVLinks"&gt;http://cesso.org/r/DVLinks&lt;/A&gt;. If you're going to link to this post, please use that URL so you'll always be up to date. &lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9914196" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF+Toolkit/default.aspx">WPF Toolkit</category></item><item><title>Creating something from nothing [Developer-friendly virtual file implementation for .NET!]</title><link>http://blogs.msdn.com/delay/archive/2009/10/26/creating-something-from-nothing-developer-friendly-virtual-file-implementation-for-net.aspx</link><pubDate>Mon, 26 Oct 2009 18:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9913083</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9913083.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9913083</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;Have you ever used one of those programs that lets you drag a UI widget, drop it in a folder, and - &lt;STRONG&gt;poof&lt;/STRONG&gt; - a file that didn't exist magically appears? Me, too - it's cool! But how does it work? Are they really deferring the work of creating that file until it's needed and then creating the file &lt;STRONG&gt;during&lt;/STRONG&gt; the drag-and-drop operation? Yes they are - and now you can, too! &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;If I have seen a little further it is by standing on the shoulders of Giants.&lt;/EM&gt;- &lt;A href="http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants" mce_href="http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants"&gt;Sir Isaac Newton&lt;/A&gt; &lt;/BLOCKQUOTE&gt;
&lt;P&gt;Everything you ever needed to know about drag-and-drop in Windows can probably be found in the MSDN documentation for &lt;A href="http://msdn.microsoft.com/en-us/library/bb776905(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb776905(VS.85).aspx"&gt;Transferring Shell Objects with Drag-and-Drop and the Clipboard&lt;/A&gt;. That documentation is a great resource for specific questions, but because it covers so many topics, it's not necessarily the best way to get an overview. For that, we turn to &lt;A href="http://blogs.msdn.com/oldnewthing/" mce_href="http://blogs.msdn.com/oldnewthing/"&gt;Raymond Chen&lt;/A&gt;'s blog - specifically, a series he did called "What a drag" in March of last year. Raymond's example uses native code exclusively, but don't let that scare you away - his presentation and explanations are always engaging! Please take a moment to read (or at least skim) the following articles, or else the rest of this post might not make much sense: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/oldnewthing/archive/2008/03/11/8080077.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2008/03/11/8080077.aspx"&gt;What a drag: Dragging text&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/oldnewthing/archive/2008/03/12/8080101.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2008/03/12/8080101.aspx"&gt;What a drag: Dragging a Uniform Resource Locator (URL)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/oldnewthing/archive/2008/03/13/8080135.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2008/03/13/8080135.aspx"&gt;What a drag: Dragging a Uniform Resource Locator (URL) and text&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/oldnewthing/archive/2008/03/18/8080183.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2008/03/18/8080183.aspx"&gt;What a drag: Dragging a virtual file (HGLOBAL edition)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/oldnewthing/archive/2008/03/19/8080215.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2008/03/19/8080215.aspx"&gt;What a drag: Dragging a virtual file (IStream edition)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/oldnewthing/archive/2008/03/20/8080229.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2008/03/20/8080229.aspx"&gt;What a drag: Dragging a virtual file (IStorage edition)&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/oldnewthing/archive/2008/03/31/8344798.aspx" mce_href="http://blogs.msdn.com/oldnewthing/archive/2008/03/31/8344798.aspx"&gt;You can drag multiple virtual objects, you know&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Okay, so we know what we want to do and now we know how it's supposed to work! The first thing to consider is whether the WPF platform supports the virtual file scenario. And unfortunately, it doesn't seem to. &lt;NOBR&gt;:(&lt;/NOBR&gt; Specifically, the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.dataobject.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.dataobject.aspx"&gt;DataObject class&lt;/A&gt; is where we'd expect to find such support, but the closest it has is &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.dataobject.setfiledroplist.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.dataobject.setfiledroplist.aspx"&gt;SetFileDropList&lt;/A&gt;. And while that sounds promising, it's really just a list of strings with paths to &lt;STRONG&gt;existing&lt;/STRONG&gt; files. Recall that the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.dragdrop.dodragdrop.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.dragdrop.dodragdrop.aspx"&gt;DragDrop.DoDragDrop method&lt;/A&gt; is synchronous (i.e., does not return until the drag-and-drop operation is complete), and the obvious consequence is that creating a virtual file on the fly isn't practical with this API. Specifically, the bits already need to exist on disk by the time the user starts the drag operation - but you don't know what data they're going to drag until they start! It's a classic &lt;A href="http://en.wikipedia.org/wiki/Catch_22" mce_href="http://en.wikipedia.org/wiki/Catch_22"&gt;Catch-22&lt;/A&gt;... &lt;/P&gt;
&lt;P&gt;The natural next step is to consider whether subclassing &lt;CODE&gt;DataObject&lt;/CODE&gt; would help - but it's &lt;CODE&gt;sealed&lt;/CODE&gt;, so that's a pretty quick dead end. &lt;/P&gt;
&lt;P&gt;Move on to consider whether the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.idataobject.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.idataobject.aspx"&gt;System.Windows.IDataObject interface&lt;/A&gt; used by &lt;CODE&gt;DataObject&lt;/CODE&gt; would be useful. But it seems not; it's pretty much the same API as &lt;CODE&gt;DataObject&lt;/CODE&gt; which we've already dismissed. &lt;/P&gt;
&lt;P&gt;So that leaves us looking at the &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtypes.idataobject.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtypes.idataobject.aspx"&gt;System.Runtime.InteropServices.ComTypes.IDataObject interface&lt;/A&gt; which is a simple managed representation of the actual &lt;A href="http://msdn.microsoft.com/en-us/library/ms688421(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms688421(VS.85).aspx"&gt;IDataObject COM interface&lt;/A&gt; that the shell uses directly. Clearly, anything is possible at this point, so if we can just channel our inner Raymond, we ought to be in business! &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The good news is that I've already done this for you. I've even written a simple WPF application to show how everything fits together: &lt;/P&gt;&lt;IMG alt="VirtualFileDataObjectDemo sample application" src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Demo.png" width=400 height=400 mce_src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Demo.png"&gt; 
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/VirtualFileDataObjectDemo/VirtualFileDataObjectDemo.zip" mce_href="http://cesso.org/Samples/VirtualFileDataObjectDemo/VirtualFileDataObjectDemo.zip"&gt;[Click here to download the complete code for VirtualFileDataObject and the sample application.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've done is write a custom &lt;CODE&gt;IDataObject&lt;/CODE&gt; class called &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; that does all the hard work for you. All you need to do is provide the relevant data, and your users will be dragging-and-dropping virtual files in no time. And what's really neat is that writing the code to support drag-and-drop &lt;STRONG&gt;automatically&lt;/STRONG&gt; gives complete support for the clipboard because the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.clipboard.setdataobject.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.clipboard.setdataobject.aspx"&gt;Clipboard.SetDataObject method&lt;/A&gt; uses the same &lt;CODE&gt;IDataObject&lt;/CODE&gt; interface! &lt;/P&gt;
&lt;P&gt;Let's look at the sample scenarios to understand how &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; is used: &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Text only&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; virtualFileDataObject = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;();

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Provide simple text (in the form of a NULL-terminated ANSI string)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;virtualFileDataObject.SetData(
    (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;short&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetDataFormat(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Text).Id),
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Default.GetBytes(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"This is some sample text\0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;));

DoDragDropOrClipboardSetDataObject(e.ChangedButton, Text, virtualFileDataObject);
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;This is the simplest possible scenario - just to show off that simple things stay simple with &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt;. Here's the signature for the &lt;CODE&gt;SetData&lt;/CODE&gt; method used above: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Provides data for the specified data format (HGLOBAL).
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="dataFormat"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Data format.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="data"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Sequence of data.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetData(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;short&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; dataFormat, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;IEnumerable&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; data)
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Note that it operates in "&lt;CODE&gt;HGLOBAL&lt;/CODE&gt; mode" where all the data is provided at the time of the call. Note also that it doesn't know anything about what the data is, so it's up to the caller to make sure it's in the right format. Specifically, the right format for &lt;CODE&gt;DataFormats.Text&lt;/CODE&gt; is a NULL-terminated ANSI string, so that's what the sample passes in. &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: The &lt;CODE&gt;DoDragDropOrClipboardSetDataObject&lt;/CODE&gt; method used above is a simple helper method for the test application - it calls &lt;CODE&gt;DragDrop.DoDragDrop&lt;/CODE&gt; or &lt;CODE&gt;Clipboard.SetDataObject&lt;/CODE&gt; depending on what the user did. It's not very exciting, so I won't be showing it (or the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; constructor) in the following examples. &lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Text and URL&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Provide simple text and a URL in priority order
// (both in the form of a NULL-terminated ANSI string)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;virtualFileDataObject.SetData(
    (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;short&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetDataFormat(CFSTR_INETURLA).Id),
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Default.GetBytes(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://blogs.msdn.com/delay/\0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;));
virtualFileDataObject.SetData(
    (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;short&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetDataFormat(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Text).Id),
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Default.GetBytes(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://blogs.msdn.com/delay/\0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;));
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Another simple example based on Raymond's discussion of drag-and-drop into Internet Explorer. For our purposes, this example demonstrates that you can set multiple data formats and that formats other than those exposed by WPF's &lt;CODE&gt;DataFormats&lt;/CODE&gt; enumeration are easy to deal with. Per the guidelines, supported formats are provided in order by priority, with higher priority formats coming first. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Virtual file&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Provide a virtual file (generated on demand) containing the letters 'a'-'z'
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;virtualFileDataObject.SetData(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FileDescriptor&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;[]
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FileDescriptor
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    {
        Name = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Alphabet.txt"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
        Length = 26,
        ChangeTimeUtc = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DateTime&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Now.AddDays(-1),
        StreamContents = stream =&amp;gt;
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; contents = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Enumerable&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Range(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;'a'&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, 26).Select(i =&amp;gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;byte&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)i).ToArray();
                stream.Write(contents, 0, contents.Length);
            }
    },
});
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;At last, something juicy! This example creates a virtual file named &lt;CODE&gt;Alphabet.txt&lt;/CODE&gt; that's 26 bytes long and appears to have been written exactly one day ago. The contents of this file aren't generated until they're actually required by the drop target, so there's no wasted effort if the user doesn't start the drag, aborts it, or whatever. When the file's contents are eventually needed, &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; calls the user-provided &lt;CODE&gt;Action&lt;/CODE&gt; (not necessarily a &lt;A href="http://msdn.microsoft.com/en-us/library/bb397687.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb397687.aspx"&gt;lambda expression&lt;/A&gt;, though I've used one here for conciseness) and passes it a write-only &lt;A href="http://msdn.microsoft.com/en-us/library/system.io.stream.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.io.stream.aspx"&gt;Stream&lt;/A&gt; instance for writing the data. The user code writes to this stream as much or as little as necessary, then returns control to &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; in order to complete the operation. &lt;/P&gt;
&lt;P&gt;The file that gets created when you drop/paste this item into a folder looks just like you'd expect. And because &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; supports the length and change time fields, Windows has all the information it needs to help the user resolve possible conflicts: &lt;/P&gt;&lt;IMG alt="Windows conflict dialog" src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Conflict.png" width=466 height=412 mce_src="http://blogs.msdn.com/blogfiles/delay/VirtualFileDataObjectDemo-Conflict.png"&gt; 
&lt;P&gt;Here's the relevant &lt;CODE&gt;SetData&lt;/CODE&gt; method (note that you can provide an arbitrary number of &lt;CODE&gt;FileDescriptor&lt;/CODE&gt; instances, so you can create as many virtual files as you want): &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Provides data for the specified data format (FILEGROUPDESCRIPTOR/FILEDESCRIPTOR)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="fileDescriptors"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Collection of virtual files.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetData(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;IEnumerable&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FileDescriptor&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; fileDescriptors)
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;It makes use of another &lt;CODE&gt;SetData&lt;/CODE&gt; method that's handy for dealing with "&lt;CODE&gt;ISTREAM&lt;/CODE&gt; mode": &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Provides data for the specified data format and index (ISTREAM).
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="dataFormat"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Data format.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="index"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Index of data.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="streamData"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Action generating the data.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;remarks&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Uses Stream instead of IEnumerable(T) because Stream is more likely
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; to be natural for the expected scenarios.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/remarks&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetData(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;short&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; dataFormat, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; index, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Action&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; streamData)
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And accepts data in the following form: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Class representing a virtual file for use by drag/drop or the clipboard.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FileDescriptor
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Gets or sets the name of the file.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Name { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Gets or sets the (optional) length of the file.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UInt64&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;? Length { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Gets or sets the (optional) change time of the file.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DateTime&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;? ChangeTimeUtc { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Gets or sets an Action that returns the contents of the file.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Action&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; StreamContents { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;set&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;; }
}
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Text, URL, and a virtual file!&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Provide a virtual file (downloaded on demand), its URL, and descriptive text
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;virtualFileDataObject.SetData(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FileDescriptor&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;[]
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;VirtualFileDataObject&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;FileDescriptor
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    {
        Name = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"DelaysBlog.xml"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
        StreamContents = stream =&amp;gt;
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; webClient = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;WebClient&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;())
                {
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;var&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; data = webClient.DownloadData(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://blogs.msdn.com/delay/rss.xml"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                    stream.Write(data, 0, data.Length);
                }
            }
    },
});
virtualFileDataObject.SetData(
    (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;short&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetDataFormat(CFSTR_INETURLA).Id),
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Default.GetBytes(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://blogs.msdn.com/delay/rss.xml\0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;));
virtualFileDataObject.SetData(
    (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;short&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetDataFormat(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DataFormats&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Text).Id),
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Default.GetBytes(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"[The RSS feed for Delay's Blog]\0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;));
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Finally, here's a sample that pulls everything together in a nice, fancy package with a bow on top. The text is an informative snippet, the URL is a link to an RSS feed, and the virtual file is the &lt;STRONG&gt;dynamically downloaded&lt;/STRONG&gt; content of that RSS feed! Way cool - it's like there's this big file sitting around that the user can drop anywhere they want - except that it only really exists on the web and it's always up to date whenever you drop it somewhere! &lt;/P&gt;
&lt;P&gt;As you can see, the &lt;CODE&gt;VirtualFileDataObject&lt;/CODE&gt; class makes the whole scenario really easy and approachable - even if you're not an expert on shell interoperability. It's pretty snazzy, I'd say. &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's just one small problem... &lt;/P&gt;
&lt;P&gt;If you tried the drag-and-drop version of the last sample above on a machine with a slow network connection, you probably noticed that the sample application became unresponsive as soon as you dropped the virtual file and didn't recover until the download completed. This is a natural consequence of the &lt;CODE&gt;DoDragDrop&lt;/CODE&gt; method being synchronous and getting called from the UI thread (like it should be). In most scenarios, you probably won't notice this problem because generating the file's data is practically instantaneous. But when there's a delay, unresponsiveness is a possibility. The &lt;STRONG&gt;good&lt;/STRONG&gt; news is that there's an official technique for solving this problem. The &lt;STRONG&gt;bad&lt;/STRONG&gt; news is that it doesn't work for WPF apps. The &lt;STRONG&gt;good&lt;/STRONG&gt; news is that I can show you how to make it work anyway. &lt;/P&gt;
&lt;P&gt;But that's a topic for another blog post - one that I'll write in a week or so... &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9913083" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Technical/default.aspx">Technical</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Two birds, one stone [Silverlight/WPF Data Visualization Development Release 2 and DataVisualizationDemos update]</title><link>http://blogs.msdn.com/delay/archive/2009/10/21/two-birds-one-stone-silverlight-wpf-data-visualization-development-release-2-and-datavisualizationdemos-update.aspx</link><pubDate>Wed, 21 Oct 2009 19:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9910837</guid><dc:creator>Delay</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/delay/comments/9910837.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9910837</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;The &lt;A href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514" mce_href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514"&gt;October 2009 release&lt;/A&gt; of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; came out on Monday and the Data Visualization assembly includes some nice updates. &lt;A href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx"&gt;I discussed the details of the new release&lt;/A&gt; then and promised to revise my samples to run on the new bits. While I anticipated doing things separately, it turned out to be easier to do everything at once. Here goes! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Silverlight/WPF Data Visualization Development Release 2 &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In the grand tradition of &lt;A href="http://blogs.msdn.com/delay/archive/2009/07/16/bringing-the-silverlight-toolkit-s-treemap-to-wpf-silverlight-wpf-data-visualization-development-release-0.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/16/bringing-the-silverlight-toolkit-s-treemap-to-wpf-silverlight-wpf-data-visualization-development-release-0.aspx"&gt;Data Visualization Development Releases&lt;/A&gt;, I've updated things to match the most recently released Toolkit code. In this case, that's the Silverlight Toolkit, so the code in the new Development Release is identical to what just went out with the Silverlight Toolkit. That means there's a bunch of &lt;STRONG&gt;new&lt;/STRONG&gt; code for WPF here! People using Data Visualization on WPF can take advantage of the latest changes by updating to the binaries included with this Development Release or by compiling the corresponding code themselves. The &lt;A href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx"&gt;release notes&lt;/A&gt; detail all the changes; there's nothing to call out here. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/SilverlightWpfDataVisualization/SilverlightWpfDataVisualization.zip" mce_href="http://cesso.org/Samples/SilverlightWpfDataVisualization/SilverlightWpfDataVisualization.zip"&gt;[Click here to download the SilverlightWpfDataVisualization solution including complete source code and pre-compiled binaries for both platforms.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;DataVisualizationDemos Sample Project Updated &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The DataVisualizationDemos application is a collection of all the Data Visualization samples I've posted to my blog. Like the Data Visualization assembly itself, the demo application runs on Silverlight and WPF and shares the same code and XAML across both platforms. Not only is it a convenient way to look at a variety of sample code, it also has links back to the relevant blog posts for more detail about each sample. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://cesso.org/Samples/DataVisualizationDemos/DataVisualizationDemos.zip" mce_href="http://cesso.org/Samples/DataVisualizationDemos/DataVisualizationDemos.zip"&gt;Click here to download the complete source code for the cross-platform DataVisualizationDemos sample application.&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Notes: &lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;New to this release of the DataVisualizationDemos is my &lt;A href="http://blogs.msdn.com/delay/archive/2009/07/27/simple-column-labels-you-can-create-at-home-re-templating-the-silverlight-wpf-data-visualization-columndatapoint-to-add-annotations.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/27/simple-column-labels-you-can-create-at-home-re-templating-the-silverlight-wpf-data-visualization-columndatapoint-to-add-annotations.aspx"&gt;simple Column annotations&lt;/A&gt; sample. &lt;/LI&gt;
&lt;LI&gt;I've added &lt;A href="http://msdn.microsoft.com/en-us/library/dd550721(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd550721(VS.95).aspx"&gt;out-of-browser support&lt;/A&gt; to the Silverlight version of DataVisualizationDemos so users can easily install it and/or run it outside the browser. &lt;/LI&gt;
&lt;LI&gt;Both flavors of DataVisualizationDemos now take advantage of custom icons for a little bit of added flair: &lt;IMG alt="DataVisualizationDemos icon" align=top src="http://blogs.msdn.com/blogfiles/delay/DataVisualizationDemos-32.png" width=32 height=32 mce_src="http://blogs.msdn.com/blogfiles/delay/DataVisualizationDemos-32.png"&gt; &lt;/LI&gt;
&lt;LI&gt;Because this version of the Data Visualization assembly contains a breaking change, the DataVisualizationDemos project can no longer use the assembly that shipped with the WPF Toolkit (or else both platforms wouldn't be able to share the same samples). Therefore, DataVisualizationDemos uses the WPF assembly from Data Visualization Development Release 2. &lt;/LI&gt;
&lt;LI&gt;Which means TreeMap (added after the WPF Toolkit release) can now be part of the WPF version of DataVisualizationDemos! &lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;If you're doing cross-platform development, sometimes you'll come across a control that lives in two different places. When that happens, it's hard to share the same XAML for both platforms - unless you know a trick! My usual technique for this is to declare my own same-named subclass in code (which automatically resolves to the right platform-specific class thanks to the namespace): &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DockPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : System.Windows.Controls.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DockPanel
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;{
}
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And then use my "custom" control (after adding the corresponding XML namespace declaration): &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;local&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;DockPanel&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt; ... /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;That works swell most of the time - except for when the class is sealed like &lt;CODE&gt;Viewbox&lt;/CODE&gt; is on Silverlight... So I came up with a slight tweak of this strategy that solves the problem: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;#if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SILVERLIGHT
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Silverlight's Viewbox is sealed; simulate it with a ContentControl wrapper
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Viewbox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ContentControl
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Viewbox()
        {
            Template = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ControlTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;XamlReader&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Load(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;@"
                &amp;lt;ControlTemplate
                    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                    xmlns:controls=""clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit""&amp;gt;
                    &amp;lt;controls:Viewbox&amp;gt;
                        &amp;lt;ContentPresenter/&amp;gt;
                    &amp;lt;/controls:Viewbox&amp;gt;
                &amp;lt;/ControlTemplate&amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        }
    }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;#else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;    public class Viewbox : System.Windows.Controls.Viewbox
    {
    }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;#endif
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And then just use it the same as above: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;local&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Viewbox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt; ... /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The latest Data Visualization release has some nice improvements - I hope these two updates help people understand the new functionality and make it even easier to upgrade! &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9910837" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF+Toolkit/default.aspx">WPF Toolkit</category></item><item><title>Silverlight (and WPF) Data Visualization classes unsealed [Silverlight Toolkit October 2009 release now available!]</title><link>http://blogs.msdn.com/delay/archive/2009/10/19/silverlight-and-wpf-data-visualization-classes-unsealed-silverlight-toolkit-october-2009-release-now-available.aspx</link><pubDate>Mon, 19 Oct 2009 17:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9909244</guid><dc:creator>Delay</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/delay/comments/9909244.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9909244</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;We've just published the &lt;A href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514" mce_href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514"&gt;October 2009 release&lt;/A&gt; of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; as part of today's &lt;A href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;.NET 4 and Visual Studio 2010's Beta 2 release&lt;/A&gt;! One of the big things we've done with this release of the Toolkit is to add rich support for Visual Studio 2010's &lt;STRONG&gt;vastly improved&lt;/STRONG&gt; Silverlight design-time experience. In fact, the new VS 2010 design-time experience has gotten &lt;STRONG&gt;so&lt;/STRONG&gt; good that some developers have stopped using Blend altogether! &lt;NOBR&gt;:)&lt;/NOBR&gt; I encourage everyone to have a look at the live samples for the latest release of the &lt;A href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" mce_href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html"&gt;Silverlight 3 Toolkit&lt;/A&gt;, download the Toolkit installer, and try for yourself! &lt;/P&gt;
&lt;P&gt;Other big news for this release is the introduction of comprehensive, WPF-compatible drag-and-drop support for Silverlight! Although this support doesn't extend outside the web browser (that would require changes to Silverlight itself), it enables full-fidelity drag-and-drop experiences within the browser using the same API that WPF users are already accustomed to. And if that wasn't enough, there are also a collection of drag-and-drop-friendly "wrapper controls" for common scenarios (ex: &lt;CODE&gt;ListBox&lt;/CODE&gt;, &lt;CODE&gt;TreeView&lt;/CODE&gt;, and &lt;CODE&gt;DataGrid&lt;/CODE&gt;) that make it trivial to add support for drag-and-drop to an existing control. Dragging and dropping within a control (to re-order items) or between controls (to move items around) is now just a few lines of XAML away! (Note: &lt;STRONG&gt;No&lt;/STRONG&gt; code changes necessary!) But wait, there's more: There's also a wrapper for Charting's &lt;CODE&gt;DataPointSeries&lt;/CODE&gt; that enables drag-and-drop into and out of a live &lt;CODE&gt;Chart&lt;/CODE&gt; control! This really needs to be seen to be believed, so please visit the "Drag and Drop" page of the &lt;A href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html" mce_href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html"&gt;public samples&lt;/A&gt; for a great example of this. Then go read &lt;A href="http://themechanicalbride.blogspot.com/2009/08/new-with-silverlight-toolkit-drag-and.html" mce_href="http://themechanicalbride.blogspot.com/2009/08/new-with-silverlight-toolkit-drag-and.html"&gt;Jafar's post about the new drag/drop support&lt;/A&gt; for all the juicy details! &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: The October 09 release of the Silverlight Toolkit includes binaries for Silverlight 3 only. Now that Silverlight 3 has been out for a few months and is fully backward-compatible with all Silverlight 2 applications, we expect that everyone has upgraded from Silverlight 2 and are therefore no longer actively developing the Toolkit for Silverlight 2. Of course, if some of you have a specific need for Silverlight 2 Toolkit bits, previous releases continue to be available to download from CodePlex! &lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the introductory stuff out of the way, let's move on to the details of changes to the Data Visualization assembly and the corresponding improvements to &lt;A href="http://cesso.org/r/DVLinks" mce_href="http://cesso.org/r/DVLinks"&gt;Silverlight and WPF Charting&lt;/A&gt;. My recent post on &lt;A href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx"&gt;Data Visualization Development Release 1&lt;/A&gt; has already discussed most of these changes at length, so I'm just going to include the change descriptions here. For more detail on the motivation behind these changes or their implications for current and future possibilities, please refer back to that post. &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Notable Changes&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Unsealed (i.e., removed the "sealed" modifier from) all core Data Visualization classes.&lt;/STRONG&gt; Although we aren't yet completely settled on the public-facing API for Data Visualization and reserve the right to make breaking changes in the future, these classes are being unsealed now to help simplify a wide variety of user scenarios that are being actively developed and that are cumbersome without the ability to subclass (without needing to create a private build of the assembly solely for the purpose of unsealing these classes). Other changes were kept to a minimum, but a couple of methods have been changed to protected virtual for consistency and/or convenience as well as some tweaks that resulted due to new code analysis warnings due to explicit interface implementations in an unsealed class. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Introduced ISeries interface to Charting as "base interface" for all Series.&lt;/STRONG&gt; This allows users to write &lt;CODE&gt;ItemsControl&lt;/CODE&gt;-based &lt;CODE&gt;Series&lt;/CODE&gt; which will automatically leverage all of the &lt;CODE&gt;ItemsControl&lt;/CODE&gt; infrastructure for creating points, tracking data changes, etc. and also gives us a safe root for a future 3D series hierarchy. As part of this change, some interfaces have been cleaned up a bit (&lt;CODE&gt;IStyleDispenser&lt;/CODE&gt;, &lt;CODE&gt;ISeriesHost&lt;/CODE&gt;) and others have been created (&lt;CODE&gt;IStyleDispenser.StylesChanged&lt;/CODE&gt; event). Also, some public methods with little justification have been removed/made private/moved lower (&lt;CODE&gt;Chart.Refresh&lt;/CODE&gt;, &lt;CODE&gt;Chart.ResetStyles&lt;/CODE&gt;, &lt;CODE&gt;StyleDispenser.ResetStyles&lt;/CODE&gt;) and some vestigial code has been removed (&lt;CODE&gt;ISeriesHost.GlobalSeriesIndexesInvalidated&lt;/CODE&gt;). &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Various usability improvements.&lt;/STRONG&gt; Updated &lt;CODE&gt;Series&lt;/CODE&gt; to look for "LegendItemStyle" in their &lt;CODE&gt;ResourceDictionary&lt;/CODE&gt; for increased customizability. Added &lt;CODE&gt;Owner&lt;/CODE&gt; property to &lt;CODE&gt;LegendItem&lt;/CODE&gt; pointing to owning &lt;CODE&gt;Series&lt;/CODE&gt; instance to simplify &lt;CODE&gt;LegendItem&lt;/CODE&gt;-based user scenarios. Added &lt;CODE&gt;ActualDataPointStyle&lt;/CODE&gt; and &lt;CODE&gt;ActualLegendItemStyle&lt;/CODE&gt; properties and used &lt;CODE&gt;Bindings&lt;/CODE&gt; to automatically propagate changes to the right places. (Aside: This fixes a bug that was reported against the WPF Toolkit &lt;EM&gt;as I was making the change&lt;/EM&gt;!) Moved code so that &lt;CODE&gt;PieSeries&lt;/CODE&gt; now has the &lt;CODE&gt;DataPointStyle&lt;/CODE&gt; property like the other &lt;CODE&gt;Series&lt;/CODE&gt;. Updated &lt;CODE&gt;LegendItem&lt;/CODE&gt; default &lt;CODE&gt;Template&lt;/CODE&gt; to include standard &lt;CODE&gt;TemplateBindings&lt;/CODE&gt; for &lt;CODE&gt;Background&lt;/CODE&gt;/&lt;CODE&gt;BorderBrush&lt;/CODE&gt;/&lt;CODE&gt;BorderThickness&lt;/CODE&gt; for more friendly designer experience. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Breaking Changes&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Renamed Charting's StylePalette to Palette (for clarity) AND changed its type to IEnumerable&amp;lt;ResourceDictionary&amp;gt; (from IEnumerable&amp;lt;Style&amp;gt;) for a significant flexibility boost.&lt;/STRONG&gt; Performed related renamings (many internal/private): &lt;CODE&gt;IStyleDispenser&lt;/CODE&gt;-&amp;gt;&lt;CODE&gt;IResourceDictionaryDispenser&lt;/CODE&gt;, &lt;CODE&gt;StylePalette&lt;/CODE&gt;-&amp;gt;&lt;CODE&gt;ResourceDictionaryCollection&lt;/CODE&gt;, &lt;CODE&gt;StyleDispensedEventArgs&lt;/CODE&gt;-&amp;gt;&lt;CODE&gt;ResourceDictionaryDispensedEventArgs&lt;/CODE&gt;, &lt;CODE&gt;StyleDispenser&lt;/CODE&gt;-&amp;gt;&lt;CODE&gt;ResourceDictionaryDispenser&lt;/CODE&gt;, &lt;CODE&gt;StyleEnumerator&lt;/CODE&gt;-&amp;gt;&lt;CODE&gt;ResourceDictionaryEnumerator&lt;/CODE&gt;. &lt;BR&gt;&lt;BR&gt;Most notably, this change makes it possible to associate MULTIPLE things with a palette entry and enables designers to easily and flexibly customize things like the &lt;CODE&gt;LineSeries&lt;/CODE&gt; &lt;CODE&gt;PolyLineStyle&lt;/CODE&gt; in the &lt;CODE&gt;Palette&lt;/CODE&gt;. Additionally it enables the use of &lt;CODE&gt;DynamicResource&lt;/CODE&gt; (currently only supported by the WPF platform) to let users customize their &lt;CODE&gt;DataPointStyle&lt;/CODE&gt; &lt;EM&gt;without&lt;/EM&gt; inadvertently losing the default/custom Palette colors. (Note: A &lt;STRONG&gt;very&lt;/STRONG&gt; popular request!) Thanks to merged &lt;CODE&gt;ResourceDictionaries&lt;/CODE&gt;, this also enables the addition of arbitrary resources at the &lt;CODE&gt;Palette&lt;/CODE&gt; level (like &lt;CODE&gt;Brushes&lt;/CODE&gt;) which can then be referenced by &lt;CODE&gt;DataPoints&lt;/CODE&gt;, etc.. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Changed return value of Charting's IAxis.GetPlotAreaCoordinate from UnitValue? to UnitValue to better support custom Axis implementations.&lt;/STRONG&gt; Specifically, some numeric axis types (logarithmic axis, for example) don't support all numeric values and need a way to indicate that certain values (ex: &amp;lt;= 0 for logarithmic) are "not supported" for plotting. This was previously done by returning a &lt;CODE&gt;null&lt;/CODE&gt; value, but now the code should return a &lt;CODE&gt;UnitValue&lt;/CODE&gt; with &lt;CODE&gt;Value=double.NaN&lt;/CODE&gt;. Convenience method &lt;CODE&gt;UnitValue.NaN&lt;/CODE&gt; has been added to create such values easily. Because the &lt;CODE&gt;Series&lt;/CODE&gt; implementations already need to handle &lt;CODE&gt;NaN&lt;/CODE&gt; values, this change collapses two different edge cases into one and simplifies the code accordingly. Added code to &lt;CODE&gt;Series&lt;/CODE&gt; to handle this situation by hiding (via &lt;CODE&gt;Visibility=Collapsed&lt;/CODE&gt;) &lt;CODE&gt;DataPoints&lt;/CODE&gt; on coordinates that are not valid. &lt;/P&gt;
&lt;P&gt;One notable consequence of this change is that the &lt;CODE&gt;Visibility&lt;/CODE&gt; of &lt;CODE&gt;DataPoint&lt;/CODE&gt;s is now controlled by the &lt;CODE&gt;Series&lt;/CODE&gt; and will be set to &lt;CODE&gt;Visible&lt;/CODE&gt; or &lt;CODE&gt;Collapsed&lt;/CODE&gt; as necessary. Therefore, any customizations that directly set this property may no longer work, but there are other simple ways of achieving the same effect and this change is not expected to cause any difficulty. For example, the "Sparkline" demo of the samples project was affected by this change because it provided a custom &lt;CODE&gt;DataPointStyle&lt;/CODE&gt; that set &lt;CODE&gt;Visibility&lt;/CODE&gt; to &lt;CODE&gt;Collapsed&lt;/CODE&gt;. The fix is not only trivial, but an improvement: change the &lt;CODE&gt;Style&lt;/CODE&gt; to specify a &lt;CODE&gt;null&lt;/CODE&gt; &lt;CODE&gt;Template&lt;/CODE&gt; instead! &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Other Changes&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Remove unnecessary code.&lt;/STRONG&gt; Moved duplicated &lt;CODE&gt;DependencyProperties&lt;/CODE&gt; &lt;CODE&gt;IRangeAxis&lt;/CODE&gt; &lt;CODE&gt;DependentRangeAxis&lt;/CODE&gt; and &lt;CODE&gt;IAxis&lt;/CODE&gt; &lt;CODE&gt;IndependentAxis&lt;/CODE&gt; from &lt;CODE&gt;ColumnSeries&lt;/CODE&gt; and &lt;CODE&gt;BarSeries&lt;/CODE&gt; into common base class &lt;CODE&gt;ColumnBarBaseSeries&lt;/CODE&gt;. Moved duplicated &lt;CODE&gt;DependencyProperties&lt;/CODE&gt; &lt;CODE&gt;IRangeAxis&lt;/CODE&gt; &lt;CODE&gt;DependentRangeAxis&lt;/CODE&gt; and &lt;CODE&gt;IAxis&lt;/CODE&gt; &lt;CODE&gt;IndependentAxis&lt;/CODE&gt; from &lt;CODE&gt;AreaSeries&lt;/CODE&gt; and &lt;CODE&gt;LineSeries&lt;/CODE&gt; into common base class &lt;CODE&gt;LineAreaBaseSeries&lt;/CODE&gt;. Made similar changes for methods &lt;CODE&gt;OnApplyTemplate&lt;/CODE&gt; and &lt;CODE&gt;UpdateDataPoint&lt;/CODE&gt; and half of &lt;CODE&gt;UpdateShape&lt;/CODE&gt;. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Simplified default Palette Brushes by removing ScaleTransform and TranslateTransform and replacing with RadialBrush.&lt;/STRONG&gt; The on-screen visuals remain the same, but the XAML is considerably smaller and simpler - and should be a bit quicker to render as well! &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Various other small changes.&lt;/STRONG&gt; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of the two breaking changes, only the rename to &lt;CODE&gt;Palette&lt;/CODE&gt; is likely to affect most people. Fortunately, converting existing code/XAML is really quite simple - which you can see as I recycle the example I gave &lt;A href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx"&gt;previously&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;old&lt;/STRONG&gt; way: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Title&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Statistics (Custom Palette)"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart.StylePalette&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;visualizationToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StylePalette&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Control"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Background"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Blue"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Control"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Background"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Green"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Control"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Background"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Red"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;visualizationToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StylePalette&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart.StylePalette&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    ...
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And the &lt;STRONG&gt;new&lt;/STRONG&gt; way (with changes highlighted): &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Title&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Statistics (Custom Palette)"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart.&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;Palette&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;visualizationToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;ResourceDictionaryCollection&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #ff0000"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="DataPointStyle"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Control"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Background"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Blue"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="DataPointStyle"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Control"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Background"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Green"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="DataPointStyle"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Control"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Setter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Property&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Background"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Red"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ResourceDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;visualizationToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;ResourceDictionaryCollection&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart.&lt;SPAN style="BACKGROUND-COLOR: yellow"&gt;Palette&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    ...
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;chartingToolkit&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Chart&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;It's pretty clear that once you've done this once, it'll be easy to do anywhere else your project requires. I explained the motivations for this change previously, so I won't repeat myself here - I just wanted to call out how straightforward the upgrade is expected to be. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clearly, the big news for Data Visualization is the unsealing of the primary charting classes! Because I went into great detail on this &lt;A href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx"&gt;earlier&lt;/A&gt;, I won't spend a lot of time on that here. Instead, I'd like to call out a particularly timely and relevant use of the new subclassing ability: &lt;A href="http://www.cplotts.com/" mce_href="http://www.cplotts.com/"&gt;Cory Plotts'&lt;/A&gt; &lt;A href="http://www.cplotts.com/2009/10/09/wpf-silverlight-charting-a-logarithmic-axis/" mce_href="http://www.cplotts.com/2009/10/09/wpf-silverlight-charting-a-logarithmic-axis/"&gt;LogarithmicAxis implementation for WPF and Silverlight&lt;/A&gt;! What's great about what he's done is that logarithmic axis support is one of our most requested features, and something we haven't had a chance to implement yet. I've always hoped that somebody in the community would be able to step up and share something here, so I was really excited to see Cory's blog post. If you're one of the users who's been waiting for a logarithmic axis, please have a look at Cory's implementation and see if it does what you need! &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: You might be wondering why we haven't gotten to logarithmic axis ourselves... Well, as you may be aware, we've been operating under severe resource constraints from the beginning, and that forces us to try to choose our investments carefully. When we're trying to decide between two features and one of them constitutes a change to the core of the Charting framework while the other is something that derives from an existing class to build on top of the framework, we'll tend to make the core framework change and hope that the community is able to help with the subclassing change. Honestly, this seems like the right balance to me and is a large part of why we're unsealing now even though the Charting APIs aren't completely set in stone. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;Along similar lines, I encourage people who have been wanting to annotate their &lt;CODE&gt;PieSeries&lt;/CODE&gt; charts to have a look at the fantastic work &lt;A href="http://bea.stollnitz.com/blog/" mce_href="http://bea.stollnitz.com/blog/"&gt;Bea Stollnitz&lt;/A&gt; has done: &lt;A href="http://bea.stollnitz.com/blog/?p=353" mce_href="http://bea.stollnitz.com/blog/?p=353"&gt;Part 1&lt;/A&gt;, &lt;A href="http://bea.stollnitz.com/blog/?p=363" mce_href="http://bea.stollnitz.com/blog/?p=363"&gt;Part 2&lt;/A&gt;, &lt;A href="http://bea.stollnitz.com/blog/?p=366" mce_href="http://bea.stollnitz.com/blog/?p=366"&gt;Part 3&lt;/A&gt;. Bea built on top of the sealed Charting hierarchy using some pretty clever tricks and techniques. But now that we've unsealed, it's my hope that she'll be able to take advantage of that to spend more time working on the great features she's adding and less time trying to jump through artificial hoops. &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two other things I'd like to call out here: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I'll post an updated version of my &lt;A href="http://blogs.msdn.com/delay/archive/2009/06/25/wpf-charting-it-s-official-june-2009-release-of-the-wpf-toolkit-is-now-available.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/06/25/wpf-charting-it-s-official-june-2009-release-of-the-wpf-toolkit-is-now-available.aspx"&gt;DataVisualizationDemos sample application&lt;/A&gt; in the next couple of days to make sure people have lots of good Charting examples using the new &lt;CODE&gt;Palette&lt;/CODE&gt; syntax. &lt;/LI&gt;
&lt;LI&gt;I'll post a new &lt;A href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx"&gt;Silverlight/WPF Data Visualization Development Release&lt;/A&gt; shortly after that to give anyone who wants pre-compiled binaries for WPF (or an easy way to compile for both platforms at once) what they need to be successful. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;As always, if you have any questions or feedback, the right places to start are the &lt;A href="http://forums.silverlight.net/forums/35.aspx" mce_href="http://forums.silverlight.net/forums/35.aspx"&gt;Silverlight Discussion Forum&lt;/A&gt; or the &lt;A href="http://wpf.codeplex.com/Thread/List.aspx" mce_href="http://wpf.codeplex.com/Thread/List.aspx"&gt;WPF Discussion List&lt;/A&gt;. Bugs and feature requests can be logged with the &lt;A href="http://silverlight.codeplex.com/WorkItem/List.aspx" mce_href="http://silverlight.codeplex.com/WorkItem/List.aspx"&gt;Silverlight Issue Tracker&lt;/A&gt; or the &lt;A href="http://wpf.codeplex.com/WorkItem/List.aspx" mce_href="http://wpf.codeplex.com/WorkItem/List.aspx"&gt;WPF Issue Tracker&lt;/A&gt;. Please raise issues that are clearly unique to one platform or the other in the obvious place. But for general questions and things that are common to both platforms, the Silverlight forum/list is probably a better place because there's more context and history there. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thanks very much for your interest in Silverlight and WPF Data Visualization - I hope you like the improvements!&lt;/STRONG&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9909244" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/delay/archive/tags/Silverlight+Toolkit/default.aspx">Silverlight Toolkit</category><category domain="http://blogs.msdn.com/delay/archive/tags/WPF+Toolkit/default.aspx">WPF Toolkit</category></item><item><title>Brevity is the soul of wit [A free, easy, custom URL shortening solution for ASP.NET!]</title><link>http://blogs.msdn.com/delay/archive/2009/10/16/brevity-is-the-soul-of-wit-a-free-easy-custom-url-shortening-solution-for-asp-net.aspx</link><pubDate>Fri, 16 Oct 2009 07:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9908006</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9908006.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9908006</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;I tend to write pretty long blog post titles. &lt;/P&gt;
&lt;P&gt;There, I said it. &lt;/P&gt;
&lt;P&gt;That's the first step, right? Admitting the problem? Except I don't usually think it's a problem... &lt;NOBR&gt;:)&lt;/NOBR&gt; Nobody's going to type post URLs, anyway - long ones are really only an issue in one scenario: &lt;A href="http://twitter.com/" mce_href="http://twitter.com/"&gt;Twitter&lt;/A&gt;. And there are already plenty of solutions for &lt;A href="http://en.wikipedia.org/wiki/URL_shortening" mce_href="http://en.wikipedia.org/wiki/URL_shortening"&gt;URL shortening&lt;/A&gt;, so why does the world need &lt;STRONG&gt;another&lt;/STRONG&gt; one? &lt;/P&gt;
&lt;P&gt;It probably doesn't. But I wanted one anyway. In particular, I wanted something ridiculously simple to manage that I had complete control over and that didn't depend on how my web site host configured their server. I wanted to be sure I could use human-readable aliases and never need to worry about namespace collisions (a problem with existing services because all the good names have been taken). Besides, I don't see the point in relying on someone else (or some other web site) to do something I can do for myself pretty easily. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So as long as I'm writing my own URL shortener, I might as well give it a special power or something, right? Well, one thing that seemed pretty useful (to me &lt;STRONG&gt;and&lt;/STRONG&gt; you) was an easy way to list all the supported aliases. Therefore, when you navigate to the &lt;A href="http://cesso.org/r/" mce_href="http://cesso.org/r/"&gt;root of the redirect namespace on my web site&lt;/A&gt;, that's just what you'll get: &lt;/P&gt;&lt;IMG alt="Custom URL shortener in action" src="http://blogs.msdn.com/blogfiles/delay/CustomUrlShortener.png" width=651 height=238 mce_src="http://blogs.msdn.com/blogfiles/delay/CustomUrlShortener.png"&gt; 
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, when I want to point to a blog or sample of mine, instead of linking to it like this: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/delay/archive/2009/07/19/my-new-home-page-enhanced-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx" mce_href="http://blogs.msdn.com/delay/archive/2009/07/19/my-new-home-page-enhanced-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx"&gt;http://blogs.msdn.com/delay/archive/2009/07/19/my-new-home-page-enhanced-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I can link to it like this: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://cesso.org/r/DVLinks" mce_href="http://cesso.org/r/DVLinks"&gt;http://cesso.org/r/DVLinks&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;What's more, because these redirects are of the &lt;A href="http://en.wikipedia.org/wiki/URL_redirection#HTTP_status_codes_3xx" mce_href="http://en.wikipedia.org/wiki/URL_redirection#HTTP_status_codes_3xx"&gt;302/Found variety&lt;/A&gt;, I can update where they go when new content becomes available without having to change any existing content. This is something I've wanted for my links post(s) ever since I posted the first version! Problem solved: from now on, the &lt;CODE&gt;DVLinks&lt;/CODE&gt; alias will always take you to my most recent post of Data Visualization links. &lt;/P&gt;
&lt;P&gt;Some of the aliases above use &lt;CODE&gt;MixedCase&lt;/CODE&gt; and some use &lt;CODE&gt;ALLCAPS&lt;/CODE&gt; - there's actually meaning behind that. When I create an alias I intend to be widely useful and expect to use more than once, I'll use mixed case like I did with &lt;CODE&gt;DVLinks&lt;/CODE&gt;. But when I'm creating an alias just so I can post it to Twitter, I'll use all caps like I did for &lt;CODE&gt;TWITTER&lt;/CODE&gt;. This way, it's easy to browse my list of aliases and pick out the particularly interesting ones. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the complete code for the &lt;A href="http://msdn.microsoft.com/en-us/library/system.web.ihttpmodule.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.web.ihttpmodule.aspx"&gt;IHttpModule&lt;/A&gt;-based URL shortener I wrote last night. It's standard ASP.NET and doesn't use any .NET 3.5 features, so it should work fine on pretty much any ASP.NET server. &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UrlShortener&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;IHttpModule
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; The prefix (directory/namespace) for all redirect requests.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;const&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; RedirectPrefix = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"~/r/"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Maintains a mapping from alias to Uri for all redirect entries.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;IDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt; _aliases =
         &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SortedDictionary&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;&amp;gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;StringComparer&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.OrdinalIgnoreCase);

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Initializes the IHttpModule instance.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="context"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;HttpApplication instance.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Init(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HttpApplication&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; context)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Populate the alias mappings
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        AddAlias(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"ChartBuilder"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://cesso.org/Samples/ChartBuilder/"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        AddAlias(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"DVLinks"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,      &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://blogs.msdn.com/delay/archive/2009/07/19/my-new-home-page-enhanced-updated-collection-of-great-silverlight-wpf-data-visualization-resources.aspx"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        AddAlias(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"SLHash"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,       &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://cesso.org/Samples/ComputeFileHashes/"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
        AddAlias(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"TWITTER"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,      &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"http://blogs.msdn.com/delay/archive/2009/10/13/if-all-my-friends-jumped-off-a-bridge-apparently-i-would-too-just-created-a-twitter-account-davidans.aspx"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);

        context.BeginRequest += &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;EventHandler&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(HttpApplication_BeginRequest);
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Adds an alias/Uri pair and validates it.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="alias"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Alias to add.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="uri"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Uri to associate with the alias.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; AddAlias(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; alias, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; uri)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Validate the URI when adding it
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        _aliases.Add(alias, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(uri, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;UriKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Absolute));
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Handles the HttpApplication's BeginRequest event.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="source"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;HttpApplication source.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;param name="e"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Event arguments.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/param&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; HttpApplication_BeginRequest(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; source, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; e)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Check if the request is a redirect attempt
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HttpApplication&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; context = (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HttpApplication&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)source;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; requestPath = context.Request.AppRelativeCurrentExecutionFilePath;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (requestPath.StartsWith(RedirectPrefix, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;StringComparison&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.OrdinalIgnoreCase))
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Extract the alias
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; alias = requestPath.Substring(RedirectPrefix.Length);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (_aliases.ContainsKey(alias))
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Known alias; redirect the user there
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                context.Response.Redirect(_aliases[alias].ToString());
            }
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;else
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Invalid alias; write a simple list of all known aliases
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; writer = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriter&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(context.Response.Output, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;""&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;))
                {
                    writer.RenderBeginTag(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriterTag&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Html);
                    writer.RenderBeginTag(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriterTag&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Head);
                    writer.RenderBeginTag(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriterTag&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Title);
                    writer.Write(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Supported Aliases"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                    writer.RenderBeginTag(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriterTag&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Body);
                    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; key &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _aliases.Keys)
                    {
                        writer.AddAttribute(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriterAttribute&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Href, _aliases[key].ToString());
                        writer.RenderBeginTag(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;HtmlTextWriterTag&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.A);
                        writer.Write(key);
                        writer.RenderEndTag();
                        writer.WriteBreak();
                        writer.WriteLine();
                    }
                    writer.RenderEndTag();
                    writer.RenderEndTag();
                }
                context.Response.End();
            }
        }
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Disposes of resources.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #808080"&gt;&amp;lt;/summary&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Dispose()
    {
    }
}
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;To enable this URL shortener for &lt;A href="http://en.wikipedia.org/wiki/Internet_Information_Services" mce_href="http://en.wikipedia.org/wiki/Internet_Information_Services"&gt;IIS 7&lt;/A&gt;, just save the code above to a .CS file, put that file in the &lt;CODE&gt;App_Code&lt;/CODE&gt; directory at the root of your web site, and register it in &lt;CODE&gt;web.config&lt;/CODE&gt; with something like the following: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;xml&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;1.0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;?&amp;gt;
&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;configuration&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;system.webServer&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;modules&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;add&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;name&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;UrlShortener&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;UrlShortener&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;modules&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;system.webServer&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;configuration&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;(For IIS 6, you'll need to change &lt;CODE&gt;system.webServer&lt;/CODE&gt; to &lt;CODE&gt;system.web&lt;/CODE&gt; and &lt;CODE&gt;modules&lt;/CODE&gt; to &lt;CODE&gt;httpModules&lt;/CODE&gt; - otherwise it's just the same.)&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9908006" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/Technical/default.aspx">Technical</category></item></channel></rss>