<?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 : WPF</title><link>http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx</link><description>Tags: WPF</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><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>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>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>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>Give your computer insomnia [Free tool and source code to temporarily prevent a machine from going to sleep!]</title><link>http://blogs.msdn.com/delay/archive/2009/09/30/give-your-computer-insomnia-free-tool-and-source-code-to-temporarily-prevent-a-machine-from-going-to-sleep.aspx</link><pubDate>Thu, 01 Oct 2009 06:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9901642</guid><dc:creator>Delay</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/delay/comments/9901642.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9901642</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;The default power settings for Windows are set up so a computer will go to sleep after 15 to 30 minutes of inactivity (i.e., no mouse or keyboard input). This is great because a computer that's not being used doesn't need to be running at full power. By letting an idle machine enter sleep mode, the user benefits from a significant reduction in electricity use, heat generation, component wear, etc.. And because sleep mode preserves the state of everything in memory, it's quick to enter, quick to exit, and doesn't affect the user's work-flow. All the same applications continue running, windows stay open and where they were, etc.. So sleep mode is a &lt;EM&gt;Good Thing&lt;/EM&gt; and I'm a fan. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;However&lt;/STRONG&gt;, sometimes a computer is busy even though someone isn't actively using the mouse and keyboard; common examples include playing a movie, burning a DVD, streaming music, etc.. In these cases, you don't want the machine to go to sleep because you're using it - even though you're not &lt;STRONG&gt;actually&lt;/STRONG&gt; using it! So most media players and disc burners tell Windows not to go to sleep while they're running. In fact, there's a dedicated API for exactly this purpose: the &lt;A href="http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx"&gt;SetThreadExecutionState Win32 Function&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;But what about those times when the computer is busy doing something and the relevant program doesn't suppress the default sleep behavior? For example, it might be downloading a large file, re-encoding a music collection, backing up the hard drive, or hashing the entire contents of the disk. You don't want the machine to go to sleep &lt;STRONG&gt;for now&lt;/STRONG&gt;, but are otherwise happy with the default sleep behavior. Unfortunately, the easiest way I know of to temporarily suppress sleeping is to go to Control Panel, open the Power Options page, change the power plan settings, commit them - and then remember to undo everything once the task is finished. It's not hard; but it's kind of annoying... &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So here's a better way: &lt;/P&gt;&lt;IMG alt="Insomnia application" src="http://blogs.msdn.com/blogfiles/delay/Insomnia.png" width=310 height=210 mce_src="http://blogs.msdn.com/blogfiles/delay/Insomnia.png"&gt; 
&lt;P&gt;Insomnia is a simple WPF application that calls the &lt;CODE&gt;SetThreadExecutionState&lt;/CODE&gt; API to disable sleep mode for as long as it's running. (Note that the display can still power off during this time - it's just sleep for the &lt;STRONG&gt;computer&lt;/STRONG&gt; that's blocked.) Closing the Insomnia window immediately restores whatever sleep mode was in effect before it was run. &lt;EM&gt;It couldn't be easier!&lt;/EM&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/Insomnia/Insomnia.zip" mce_href="http://cesso.org/Samples/Insomnia/Insomnia.zip"&gt;[Click here to download the Insomnia application 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;&lt;STRONG&gt;Notes&lt;/STRONG&gt;: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Insomnia basically boils down to a single function call - but to a function that's a Win32 API and is not part of the .NET Framework. This is where a very powerful feature saves the day: &lt;A href="http://msdn.microsoft.com/en-us/library/sd10k43k.aspx" mce_href="http://msdn.microsoft.com/en-us/library/sd10k43k.aspx"&gt;Platform Invoke&lt;/A&gt;. For those who aren't familiar with it, P/Invoke (as it's called) lets a managed application call into the APIs exposed by a native DLL. All it takes is a dash of the &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx"&gt;DllImport&lt;/A&gt; attribute and a little bit of translation from the Win32 types to their managed counterparts. The MSDN documentation goes into lots of detail here, and I encourage interested parties to go there. &lt;/LI&gt;
&lt;LI&gt;One popular resource for P/Invoke assistance is &lt;A href="http://pinvoke.net/" mce_href="http://pinvoke.net/"&gt;PInvoke.net&lt;/A&gt;, where you can find managed definitions for hundreds of native APIs. But I usually just end up creating my own - if nothing else, it's a good learning exercise. &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/LI&gt;
&lt;LI&gt;The Insomnia window has its &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.window.topmost.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.window.topmost.aspx"&gt;Topmost&lt;/A&gt; property set to &lt;CODE&gt;True&lt;/CODE&gt; so it's always visible and people will be less likely to accidentally leave their computers sleep-less. Other than taking up a small bit of screen space and memory, Insomnia consumes no system resources, so it won't get in the way of whatever else is running. &lt;/LI&gt;
&lt;LI&gt;It is considered polite to leave things the way you found them, so Insomnia makes an extra call to &lt;CODE&gt;SetThreadExecutionState&lt;/CODE&gt; when it's closed in order to restore things to how they were. However, this is really more for show than anything else, because the execution state is clearly per-thread and Insomnia's thread is about to die anyway. &lt;/LI&gt;
&lt;LI&gt;I did a quick web search for similar tools before I wrote Insomnia and there are a few out there. Most of what I found was for Linux and Mac for some reason, but I'm sure Insomnia isn't the first of its kind for Windows. However, that doesn't stop it from being a nice introduction to P/Invoke - and besides, I'm always happier running my own code! &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;Finally, here's the implementation: &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;partial&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;Window1&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; : &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Window
&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;uint&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; m_previousExecutionState;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Window1()
    {
        InitializeComponent();

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Set new state to prevent system sleep (note: still allows screen saver)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        m_previousExecutionState = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NativeMethods&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.SetThreadExecutionState(
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NativeMethods&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.ES_CONTINUOUS | &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NativeMethods&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.ES_SYSTEM_REQUIRED);
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (0 == m_previousExecutionState)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MessageBox&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Show(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Call to SetThreadExecutionState failed unexpectedly."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;,
                Title, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MessageBoxButton&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.OK, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MessageBoxImage&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Error);
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// No way to recover; fail gracefully
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            Close();
        }
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;override&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; OnClosed(System.&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: #0000ff"&gt;base&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.OnClosed(e);

        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Restore previous state
&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 == &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NativeMethods&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.SetThreadExecutionState(m_previousExecutionState))
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// No way to recover; already exiting
&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; Hyperlink_RequestNavigate(&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;RequestNavigateEventArgs&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; e)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Start an instance of the NavigateUri (in a browser window)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Process&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Start(((&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Hyperlink&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;)sender).NavigateUri.ToString());
    }
}

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;internal&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;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;NativeMethods
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Import SetThreadExecutionState Win32 API and necessary flags
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;    [&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DllImport&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;"kernel32.dll"&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;extern&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;uint&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetThreadExecutionState(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;uint&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; esFlags);
    &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;const&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;uint&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ES_CONTINUOUS = 0x80000000;
    &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;const&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;uint&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ES_SYSTEM_REQUIRED = 0x00000001;
}
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9901642" 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>If it walks like a duck and talks like a duck, it must be a ... TreeGrid! [A simple, XAML-only TreeGrid UI for WPF]</title><link>http://blogs.msdn.com/delay/archive/2009/09/23/if-it-walks-like-a-duck-and-talks-like-a-duck-it-must-be-a-treegrid-a-simple-xaml-only-treegrid-ui-for-wpf.aspx</link><pubDate>Thu, 24 Sep 2009 08:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9898803</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9898803.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9898803</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;If you've done much work with WPF or Silverlight, chances are you already know what a &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.treeview.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.treeview.aspx"&gt;TreeView&lt;/A&gt; is and what a &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid(VS.100).aspx"&gt;DataGrid&lt;/A&gt; is. You know that a &lt;CODE&gt;TreeView&lt;/CODE&gt; is good for showing hierarchical data and a &lt;CODE&gt;DataGrid&lt;/CODE&gt; is good for showing tabular data. But you may not know about their hybrid love child, the &lt;CODE&gt;TreeGrid&lt;/CODE&gt; - and that's what this post is about. &lt;/P&gt;
&lt;P&gt;Sometimes you've got data that's basically tabular in nature, yet also has a hierarchical aspect, and you'd like to leverage that to give people control over the level of detail they're seeing. Most commonly, you'll see a &lt;CODE&gt;TreeGrid&lt;/CODE&gt; used when the tabular data can be nicely summarized (or "rolled up") into hierarchical groupings. For example, a list of people's name and address would &lt;STRONG&gt;not&lt;/STRONG&gt; make a good &lt;CODE&gt;TreeGrid&lt;/CODE&gt;, because there's no natural grouping that makes sense (you can't combine addresses). However, a list of people's company and salary &lt;STRONG&gt;might&lt;/STRONG&gt; make a good &lt;CODE&gt;TreeGrid&lt;/CODE&gt; because it's natural to group by job and the aggregated salary information could be informative (either as an average or as a sum). &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: You might wonder if &lt;A href="http://timheuer.com/blog/archive/2009/04/08/grouping-in-silverlight-datagrid.aspx" mce_href="http://timheuer.com/blog/archive/2009/04/08/grouping-in-silverlight-datagrid.aspx"&gt;DataGrid's native support for grouping&lt;/A&gt; would be useful here. In my experience, &lt;CODE&gt;DataGrid&lt;/CODE&gt;s don't tend to summarize the grouped data like we want - but if you have examples to the contrary, I'd love to see them. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;So with all this talk about &lt;CODE&gt;TreeGrid&lt;/CODE&gt;, you might expect to find one in the Silverlight or WPF framework, or perhaps as part of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; or &lt;A href="http://wpf.codeplex.com/" mce_href="http://wpf.codeplex.com/"&gt;WPF Toolkit&lt;/A&gt;. But you won't - it's just not used frequently enough to have made it to the big leagues yet. The good news is that a bit of &lt;A href="http://www.bing.com/search?q=TreeGrid+and+%28WPF+or+Silverlight%29&amp;amp;form=QBRE&amp;amp;qs=n" mce_href="http://www.bing.com/search?q=TreeGrid+and+%28WPF+or+Silverlight%29&amp;amp;form=QBRE&amp;amp;qs=n"&gt;web&lt;/A&gt; &lt;A href="http://www.google.com/search?hl=en&amp;amp;q=TreeGrid+and+%28WPF+or+Silverlight%29&amp;amp;aq=f&amp;amp;oq=&amp;amp;aqi=" mce_href="http://www.google.com/search?hl=en&amp;amp;q=TreeGrid+and+%28WPF+or+Silverlight%29&amp;amp;aq=f&amp;amp;oq=&amp;amp;aqi="&gt;searching&lt;/A&gt; will turn up some third-party &lt;CODE&gt;TreeGrid&lt;/CODE&gt; options that definitely seem worth evaluating. But because I'm cheap and a show-off - and occasionally fall victim to a little &lt;A href="http://en.wikipedia.org/wiki/Not_Invented_Here" mce_href="http://en.wikipedia.org/wiki/Not_Invented_Here"&gt;NIH&lt;/A&gt; - I decided to craft a &lt;CODE&gt;TreeGrid&lt;/CODE&gt;-like experience using only the WPF &lt;CODE&gt;TreeView&lt;/CODE&gt; control, a couple of &lt;CODE&gt;Grid&lt;/CODE&gt;s, and some XAML. &lt;/P&gt;
&lt;P&gt;That's right - &lt;STRONG&gt;no&lt;/STRONG&gt; code, just XAML! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's how my SimpleTreeGridUX sample looks with some data I made up about the schedule of a fictional developer: &lt;/P&gt;&lt;IMG alt="SimpleTreeGridUX sample" src="http://blogs.msdn.com/blogfiles/delay/SimpleTreeGridUX.png" width=380 height=339 mce_src="http://blogs.msdn.com/blogfiles/delay/SimpleTreeGridUX.png"&gt; 
&lt;P&gt;And here's the complete XAML: &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- TreeGrid "Control" --&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BorderBrush&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Black"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BorderThickness&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="1"&amp;gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Resources --&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;Border.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; 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;="TextBlockStyle"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlock&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;            &lt;/SPAN&gt;&lt;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;="Margin"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="3 0 3 0"/&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; 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;="TextBlockBoldStyle"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TargetType&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlock&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BasedOn&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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;="FontWeight"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Value&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Bold"/&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;Border.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;!-- Content --&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;Grid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Grid.IsSharedSizeScope&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;Grid.RowDefinitions&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;RowDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Auto"/&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;RowDefinition&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;Grid.RowDefinitions&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;!-- Column headers --&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;TreeViewItem&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Grid.Row&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BorderThickness&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="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;TreeViewItem.Header&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;Grid&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;Grid.ColumnDefinitions&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Task"/&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;                        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;&amp;lt;!-- Placeholders for two columns of ToggleButton --&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Toggle"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Toggle"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Duration"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Notes"/&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;Grid.ColumnDefinitions&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Task"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockBoldStyle&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;!-- Empty TreeViewItem to measure the size of its ToggleButton into the "Toggle" group--&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;TreeViewItem&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Padding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="0"/&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="3"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Duration"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockBoldStyle&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="4"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Text&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Notes"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockBoldStyle&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;Grid&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;TreeViewItem.Header&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;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: #008000"&gt;&amp;lt;!-- Data rows --&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;TreeView&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Grid.Row&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="1"&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: #ff0000"&gt; SubItems&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BorderBrush&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Gray"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; BorderThickness&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="0 1 0 0"&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;TreeView.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: #008000"&gt;&amp;lt;!-- Level 0 template leaves space for 2 child "Toggle" levels --&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;HierarchicalDataTemplate&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: #ff0000"&gt; SubItems&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;Grid&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;Grid.ColumnDefinitions&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Task"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Toggle"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Toggle"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Duration"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Notes"/&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;Grid.ColumnDefinitions&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="0"&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; Task&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="3"&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; Duration&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="4"&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; Notes&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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;Grid&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;!-- Level 1 template leaves space for 1 child "Toggle" level --&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;HierarchicalDataTemplate.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;HierarchicalDataTemplate&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: #ff0000"&gt; SubItems&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;Grid&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;Grid.ColumnDefinitions&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Task"/&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;ColumnDefinition&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Toggle"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Duration"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Notes"/&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;Grid.ColumnDefinitions&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="0"&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; Task&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="3"&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; Duration&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="4"&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; Notes&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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;Grid&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;!-- Level 2 template has no children --&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;HierarchicalDataTemplate.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;HierarchicalDataTemplate&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: #ff0000"&gt; SubItems&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;Grid&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;Grid.ColumnDefinitions&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Task"/&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;ColumnDefinition&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;ColumnDefinition&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Duration"/&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;ColumnDefinition&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; SharedSizeGroup&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Notes"/&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;Grid.ColumnDefinitions&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="0"&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; Task&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="3"&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; Duration&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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; Grid.Column&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="4"&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; Notes&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;}"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; Style&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="{&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;StaticResource&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt; TextBlockStyle&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;Grid&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;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;HierarchicalDataTemplate.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;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;HierarchicalDataTemplate.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;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;TreeView.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;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;Grid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Border&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&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;There are two "tricks" I use to get &lt;CODE&gt;DataGrid&lt;/CODE&gt;-like behavior from a &lt;CODE&gt;TreeView&lt;/CODE&gt;. The first is the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.issharedsizescope.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.issharedsizescope.aspx"&gt;Grid.IsSharedSizeScope&lt;/A&gt; attached &lt;CODE&gt;DependencyProperty&lt;/CODE&gt; and its partner-in-crime &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.definitionbase.sharedsizegroup.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.definitionbase.sharedsizegroup.aspx"&gt;DefinitionBase.SharedSizeGroup&lt;/A&gt;. (Both available only on WPF for now.) By setting &lt;CODE&gt;IsSharedSizeScope&lt;/CODE&gt; on a parent element and &lt;CODE&gt;SharedSizeGroup&lt;/CODE&gt; on some of the column/row definitions of &lt;CODE&gt;Grid&lt;/CODE&gt;s within it, it's possible to "link" the sizes of cells across different &lt;CODE&gt;Grid&lt;/CODE&gt;s. In the scenario above, that sharing takes place across the separate &lt;CODE&gt;Grid&lt;/CODE&gt;s of the column headers and each &lt;CODE&gt;TreeViewItem&lt;/CODE&gt; row of data. In this manner, same-width columns are created for the "Task", "Duration", and "Notes" fields so they all line up properly. Except that they wouldn't actually line up if it weren't for... &lt;/LI&gt;
&lt;LI&gt;The "Toggle" shared size group which is used to offset &lt;CODE&gt;TreeViewItem&lt;/CODE&gt; children to take into account the indent that &lt;CODE&gt;TreeViewItem&lt;/CODE&gt; parents automatically impose on them. The following diagram of the default &lt;CODE&gt;TreeViewItem&lt;/CODE&gt; layout should help explain what I mean: 
&lt;TABLE style="BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BACKGROUND-COLOR: white; MARGIN: 10px; BORDER-TOP: black 1px solid; BORDER-RIGHT: black 1px solid" cellSpacing=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: cyan; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; PADDING-TOP: 4px"&gt;◊&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: lime; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; PADDING-TOP: 4px"&gt;Header&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD style="BORDER-LEFT: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: orange; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 1px; PADDING-TOP: 4px"&gt;Children&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;You see, each collection of children is offset to the right by exactly the width of the &lt;CODE&gt;TreeViewItem&lt;/CODE&gt;'s toggle element. So if all we did was make each column's cells the same width, things wouldn't actually line up because of this offset showing up in different amounts everywhere: 
&lt;TABLE style="BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BACKGROUND-COLOR: white; MARGIN: 10px; BORDER-TOP: black 1px solid; BORDER-RIGHT: black 1px solid" cellSpacing=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: cyan; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; PADDING-TOP: 4px"&gt;◊&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: lime; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; PADDING-TOP: 4px"&gt;Header&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD style="BORDER-LEFT: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: orange; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 1px; PADDING-TOP: 4px"&gt;
&lt;TABLE style="BORDER-BOTTOM: black 1px solid; BORDER-LEFT: black 1px solid; BACKGROUND-COLOR: white; BORDER-TOP: black 1px solid; BORDER-RIGHT: black 1px solid" cellSpacing=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: cyan; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; PADDING-TOP: 4px"&gt;◊&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: lime; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; PADDING-TOP: 4px"&gt;Header&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD style="BORDER-LEFT: 1px solid; PADDING-BOTTOM: 4px; BORDER-RIGHT-WIDTH: 1px; BACKGROUND-COLOR: orange; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; BORDER-TOP-WIDTH: 1px; BORDER-BOTTOM-WIDTH: 1px; PADDING-TOP: 4px"&gt;Children&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;So what I've done is add a special shared size group with exactly the same width as the toggle (this is what the empty &lt;CODE&gt;TreeViewItem&lt;/CODE&gt; in the header section of the XAML is for). Having done that, the "Toggle" size group can be used to simulate the width of the actual toggle anywhere it's needed. Therefore, I'm able to insert the appropriate counter-offset for each level of the tree - and everything lines up beautifully! &lt;/LI&gt;
&lt;LI&gt;You've probably noticed that there's an unfortunate amount of XAML duplication above - each of the three &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;s are very nearly identical. In fact, the &lt;STRONG&gt;only&lt;/STRONG&gt; difference among them is whether the second and third &lt;CODE&gt;ColumnDefinition&lt;/CODE&gt; have the &lt;CODE&gt;SharedSizeGroup&lt;/CODE&gt; property or not. Now, I strive to stay as &lt;A href="http://en.wikipedia.org/wiki/DRY" mce_href="http://en.wikipedia.org/wiki/DRY"&gt;DRY&lt;/A&gt; as the next guy, and I tried to come up with a way to collapse the three templates into one. But while I could do so quite easily using a bit of code, I couldn't come up with a nice way that was pure XAML. 
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: Converting the template contents to a &lt;CODE&gt;UserControl&lt;/CODE&gt; gets close, but there's still the problem of toggling that property based on external input. And while it would definitely be possible to decorate the (view) model with information about each element's level, I considered that to be "cheating" for the purposes of this exercise. &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/BLOCKQUOTE&gt;&lt;/LI&gt;&lt;/UL&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/SimpleTreeGridUX/SimpleTreeGridUX.zip" mce_href="http://cesso.org/Samples/SimpleTreeGridUX/SimpleTreeGridUX.zip"&gt;[Click here to download the complete source code for the SimpleTreeGridUX sample.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just in case it's not really obvious by now, what I describe here is &lt;STRONG&gt;not&lt;/STRONG&gt; a true &lt;CODE&gt;TreeGrid&lt;/CODE&gt; control! While I'll suggest that it &lt;STRONG&gt;looks&lt;/STRONG&gt; like a real &lt;CODE&gt;TreeGrid&lt;/CODE&gt;, behaves mostly like one, and is probably good enough for many scenarios, I'm also the first to acknowledge it's not a &lt;STRONG&gt;true&lt;/STRONG&gt; &lt;CODE&gt;TreeGrid&lt;/CODE&gt;. A true &lt;CODE&gt;TreeGrid&lt;/CODE&gt; would probably have an extensive API for managing columns and rows, allow sorting and arbitrary nesting, and end up with an object model pretty similar to &lt;CODE&gt;DataGrid&lt;/CODE&gt;'s. So if you came here looking for a proper &lt;CODE&gt;TreeGrid&lt;/CODE&gt; control, I'm sorry to disappoint you - but if you came here hoping to learn more about solving real-world problems with WPF, I hope this has been educational! &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9898803" 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></item><item><title>I get by with a little help from my friends [PieSeries annotations trilogy complete!]</title><link>http://blogs.msdn.com/delay/archive/2009/09/21/i-get-by-with-a-little-help-from-my-friends-pieseries-annotations-trilogy-complete.aspx</link><pubDate>Mon, 21 Sep 2009 10:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9897448</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9897448.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9897448</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;Friend and fellow Charting fan &lt;A href="http://bea.stollnitz.com/blog/" mce_href="http://bea.stollnitz.com/blog/"&gt;Bea Stollnitz&lt;/A&gt; has just completed a 3-post series describing how to add annotations to pie charts created by the Data Visualization package that's part of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; and &lt;A href="http://wpf.codeplex.com/" mce_href="http://wpf.codeplex.com/"&gt;WPF Toolkit&lt;/A&gt;. Because annotations are a feature that we'd love to implement ourselves (but haven't had time for yet), I'm delighted that someone in the community has taken this task on - and shared the experience for the benefit of others! &lt;/P&gt;
&lt;P&gt;Here are direct links to Bea's posts: &lt;/P&gt;
&lt;OL&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;/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;/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;/LI&gt;&lt;/OL&gt;
&lt;P&gt;My thanks go out to Bea for sharing her time and expertise here - I hope others find this as cool as I do! :) &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 note that while a number of WPF-to-Silverlight incompatibilities are identified in the third post, &lt;STRONG&gt;none&lt;/STRONG&gt; of them come from the Data Visualization assembly. We've specifically spent a good bit of effort to make the Silverlight and WPF code/XAML experience identical for Data Visualization; it's the success of projects like this one that are the reason and reward! &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PPS&lt;/STRONG&gt; - In the next release of the Data Visualization assembly (&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;which you can preview now!&lt;/A&gt;), the core Charting classes will no longer be sealed and some of the inconvenience mentioned in the second post should go away. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PPPS&lt;/STRONG&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;Here's my own take on a quick-and-easy way to add simple annotations to ColumnSeries.&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PPPPS&lt;/STRONG&gt; - If you're looking for more information about the Silverlight/WPF Data Visualization assembly, &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;I've collected a bunch of links from across the web - including all of my own introductions and notes&lt;/A&gt;. &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9897448" 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>A preview of upcoming Charting changes [Silverlight/WPF Data Visualization Development Release 1]</title><link>http://blogs.msdn.com/delay/archive/2009/09/13/a-preview-of-upcoming-charting-changes-silverlight-wpf-data-visualization-development-release-1.aspx</link><pubDate>Mon, 14 Sep 2009 09:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9894842</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9894842.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9894842</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;It was about two months ago that I posted about &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;Silverlight/WPF Data Visualization Development Release 0&lt;/A&gt;. At the time, I explained how I was hoping to do occasional, out-of-band releases of the Data Visualization assembly that's part of the &lt;A href="http://silverlight.codeplex.com/" mce_href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/A&gt; and &lt;A href="http://wpf.codeplex.com/" mce_href="http://wpf.codeplex.com/"&gt;WPF Toolkit&lt;/A&gt; in order to give people an early glimpse of upcoming changes and maybe get a bit of feedback along the way. &lt;/P&gt;
&lt;P&gt;It's that time again... &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Announcing &lt;STRONG&gt;Silverlight/WPF Data Visualization Development Release 1&lt;/STRONG&gt;! &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As usual, there have been plenty of distractions these past weeks to keep us, um..., distracted - but we've still managed to make some significant architectural tweaks that I think people are going to appreciate. Maybe a little less so in the short term because there are a couple of breaking changes, but definitely in the long term because these changes enable some very interesting scenarios and should do a lot to make it easier to develop with the Data Visualization framework. &lt;/P&gt;
&lt;P&gt;Please bear in mind that this is just a development release, so it hasn't gone through the same level of scrutiny that our official releases get. Therefore, there may be some behavioral anomalies - and if there are, I apologize in advance. So if you &lt;STRONG&gt;do&lt;/STRONG&gt; find an issue, please contact me (by leaving a comment below or by clicking the &lt;A href="http://blogs.msdn.com/delay/contact.aspx" mce_href="http://blogs.msdn.com/delay/contact.aspx"&gt;Email&lt;/A&gt; link on my blog) as I'd love to fix whatever I can before the next official release! &lt;/P&gt;
&lt;P&gt;Because I'm trying to keep the cost of doing Development Releases down, I'm not doing my usual long-winded write up of new features. Instead, I'm going to include the notable changeset descriptions from our source control system along with a few brief notes. If that isn't enough detail to get you excited, then you're probably not the target audience for these Development Releases. &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;Notable Changes (from the check-in comments)&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Unseal (i.e., remove the "sealed" modifier) from all Data Visualization classes that were previously sealed. 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;/BLOCKQUOTE&gt;
&lt;P&gt;While this is the most controversial change, I think it's the right thing for us to do now. The concern is that people will take our unsealing as encouragement to go off and subclass everything - and then be disappointed/frustrated when they need to change their code after we make some subsequent breaking change to the API. And I sympathize with this concern - so &lt;STRONG&gt;if you're worried about this happening to you, just pretend everything's still sealed for now&lt;/STRONG&gt;. The official indication that the API has stabilized will be when the classes in the Data Visualization assembly change &lt;A href="http://silverlight.codeplex.com/Wiki/View.aspx?title=Quality%20Bands" mce_href="http://silverlight.codeplex.com/Wiki/View.aspx?title=Quality%20Bands"&gt;quality bands&lt;/A&gt; from &lt;CODE&gt;Preview&lt;/CODE&gt; (their current band) to &lt;CODE&gt;Stable&lt;/CODE&gt;. That's not happening yet, so please be aware that there's a certain amount of risk when making the decision to build on the current API. &lt;/P&gt;
&lt;P&gt;That said, I'm of the opinion that we have little to lose with this because the decision is entirely in the customers' hands. If you don't want the risk, don't take it. But if you're doing something cool with Charting and wish you could subclass to avoid a bunch of additional effort, then this change is for you. &lt;NOBR&gt;:)&lt;/NOBR&gt; For instance, &lt;A href="http://bea.stollnitz.com/blog/?p=363" mce_href="http://bea.stollnitz.com/blog/?p=363"&gt;Bea Stollnitz is doing some cool stuff with adding annotations to PieSeries&lt;/A&gt; - and she's basically called us out in that post for making her task harder because our classes are sealed. Well, discouraging folks from using the Data Visualization assembly is the &lt;STRONG&gt;last&lt;/STRONG&gt; thing I'm trying to do - so we're unsealing now to help make the platform as friendly as possible. &lt;/P&gt;
&lt;P&gt;And while you're busy taking advantage of the new ability to subclass, I fully expect there will be places we haven't exposed all the extensibility points people want. When that happens, &lt;STRONG&gt;please let me know&lt;/STRONG&gt;, and we'll look into addressing that oversight in a future release. Think of it as the "You scratch our backs, we'll scratch yours" model of software development... &lt;NOBR&gt;:)&lt;/NOBR&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Introduce ISeries interface to Charting as "base interface" for all Series. This will allow users to write ItemsControl-based Series which will automatically leverage all of the ItemsControl 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 (IStyleDispenser, ISeriesHost) and others have been created (IStyleDispenser.StylesChanged event). Also, some public methods with little justification have been removed/made private/moved lower (Chart.Refresh, Chart.ResetStyles, StyleDispenser.ResetStyles) and some vestigial code has been removed (ISeriesHost.GlobalSeriesIndexesInvalidated). Aside from adjusting for renamed/deleted functionality, all tests continue to pass as-is. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;There are two pretty big wins from this change - so go back and re-read that paragraph if you weren't paying attention. We've prototyped &lt;STRONG&gt;both&lt;/STRONG&gt; an &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.aspx"&gt;ItemsControl&lt;/A&gt;-based &lt;CODE&gt;PieSeries&lt;/CODE&gt; and a (WPF-only) &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.controls.viewport3d.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.controls.viewport3d.aspx"&gt;Viewport3D&lt;/A&gt;-based &lt;CODE&gt;PieSeries&lt;/CODE&gt; and the results are very promising! Simply by changing our base &lt;CODE&gt;Series&lt;/CODE&gt; contract from a class to an interface, we give people with simple needs the ability to leverage the existing &lt;CODE&gt;ItemsControl&lt;/CODE&gt; framework and significantly decrease the amount of code they need to understand and interact with. (&lt;STRONG&gt;Aside&lt;/STRONG&gt;: There have even been suggestions to change our existing series over to use this model!) And the benefits for 3D are also compelling - though further off in the future due to a variety of open issues and unanswered questions. I'm not going to dwell on the implications of this change more right now, but there are obviously some cool possibilities that I'd love to see folks start to explore. (&lt;EM&gt;Hint, hint, friends of Charting...&lt;/EM&gt;) &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Rename Charting's StylePalette to Palette (for clarity) AND change its type to IEnumerable&amp;lt;ResourceDictionary&amp;gt; (from IEnumerable&amp;lt;Style&amp;gt;) for a significant flexibility boost. Perform related renamings (many internal/private): IStyleDispenser-&amp;gt;IResourceDictionaryDispenser, StylePalette-&amp;gt;ResourceDictionaryCollection, StyleDispensedEventArgs-&amp;gt;ResourceDictionaryDispensedEventArgs, StyleDispenser-&amp;gt;ResourceDictionaryDispenser, StyleEnumerator-&amp;gt;ResourceDictionaryEnumerator. Modify all code, comments, tests, samples, themes, etc. accordingly. &lt;BR&gt;&lt;BR&gt;Most notably, this change gives us the ability to associate MULTIPLE things with a palette entry and enables designers to easily and flexibly customize things like LineSeries PolyLineStyle in the Palette. Additionally it enables the use of DynamicResource (currently only supported by the WPF platform) to let users customize their DataPointStyle *without* inadvertently losing the default/custom Palette colors. Due to merged ResourceDictionaries, this also enables the addition of arbitrary resources at the Palette level (like Brushes) which can be referenced by DataPoints, etc.. &lt;BR&gt;&lt;BR&gt;Also: Simplify default Background Brushes by removing ScaleTransform and TranslateTransform and replacing with RadialBrush properties, and more... &lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is going to be the most painful change for existing users of Data Visualization - sorry! If you've ever customized a &lt;CODE&gt;StylePalette&lt;/CODE&gt;, your XAML is going to need to change. However, the opportunities this change opens up seem sufficiently compelling that we've decided to make it now (while we still have the freedom to do so). The good news is that the migration is really quite simple - and once you've seen it done once, you can mindlessly apply the change everywhere it's needed. &lt;/P&gt;
&lt;P&gt;To prove it, here's a sample of the "old" way from &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;my original Charting Introduction post&lt;/A&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;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 here's that same XAML converted to the "new" way of doing things (I've highlighted the changes): &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;Yes, the new syntax is a little bit longer, no doubt about that - but the ability to associate multiple resources with a single palette entry addresses some very tricky problems we've been avoiding till now. And the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.dynamicresourceextension.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.dynamicresourceextension.aspx"&gt;DynamicResource&lt;/A&gt; benefits for WPF address the single biggest complaint people have had with &lt;CODE&gt;StylePalette&lt;/CODE&gt;: &lt;EM&gt;Why should I have to redefine the entire color palette when all I want to do is provide a new template?&lt;/EM&gt; This is a really powerful shift, and something I'll probably spend more time showing off in a future blog post. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Update Series to look for "LegendItemStyle" in their ResourceDictionary for increased customizability. Add Owner property to LegendItem pointing to owning series to simplify LegendItem-based user scenarios. Add ActualDataPointStyle and ActualLegendItemStyle properties and use Bindings to automatically propagate changes to the right places. (Aside: This fixes a bug that was reported against the WPF Toolkit *as I was making this change*!) Move code so that PieSeries now has the DataPointStyle property like the other Series. Update LegendItem default Template to include standard TemplateBindings for Background/BorderBrush/BorderThickness for more friendly designer experience. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hey, look, we're &lt;STRONG&gt;already&lt;/STRONG&gt; making use of the new &lt;CODE&gt;ResourceDictionaryCollection&lt;/CODE&gt;! &lt;NOBR&gt;:)&lt;/NOBR&gt; The other two big improvements here are the comprehensive use of bindings for the DataPointStyle property that fixes an issue a few customers have bumped into (it's confusing unless you know exactly what's going on) and the addition of &lt;CODE&gt;DataPointStyle&lt;/CODE&gt; to &lt;CODE&gt;PieSeries&lt;/CODE&gt; which is like the &lt;CODE&gt;DynamicResource&lt;/CODE&gt; change in that it should do a lot to simplify things on the WPF platform. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;Move unnecessarily duplicated DependencyProperties IRangeAxis DependentRangeAxis and IAxis IndependentAxis from ColumnSeries and BarSeries into common base class ColumnBarBaseSeries. Move unnecessarily duplicated DependencyProperties IRangeAxis DependentRangeAxis and IAxis IndependentAxis from AreaSeries and LineSeries into common base class LineAreaBaseSeries. Same for methods OnApplyTemplate and UpdateDataPoint and half of UpdateShape. Also remove an unnecessary override from CategoryAxis. No functional impact. &lt;/BLOCKQUOTE&gt;
&lt;P&gt;Less code, same features, no functional impact - 'nuff said. &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/SilverlightWpfDataVisualization/SilverlightWpfDataVisualization.zip" mce_href="http://cesso.org/Samples/SilverlightWpfDataVisualization/SilverlightWpfDataVisualization.zip"&gt;[Please click here to download the complete SilverlightWpfDataVisualization solution (includes all 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;Release Notes&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;When you add a project reference to the Data Visualization assembly on WPF, you also need to add a reference to &lt;CODE&gt;WPFToolkit.dll&lt;/CODE&gt; or you'll get weird runtime errors because the Visual State Manager (VSM) isn't available. &lt;/LI&gt;
&lt;LI&gt;The file structure of the ZIP archive remains the same (&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;see my previous post for details&lt;/A&gt;). &lt;/LI&gt;
&lt;LI&gt;Design-time assemblies are not part of the Development Releases because I don't expect the target audience to need them and because they add additional complexity. &lt;/LI&gt;
&lt;LI&gt;I haven't updated 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 application&lt;/A&gt; for this unofficial release. &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So there you have it: the second Silverlight/WPF Data Visualization Development Release in a nutshell. Though, in many ways, this is really the &lt;STRONG&gt;first&lt;/STRONG&gt; release because the previous release didn't showcase upcoming changes like this one does (it mainly set the stage for future releases). I said before that these Development Releases are an experiment - so please let me know if you find them useful or if you'd all rather just wait for an official release and find out what's changed then. I'm hopeful that early access to the new code will be helpful to our early adopters and that we'll be able to incorporate their feedback to deliver an even more compelling, more reliable official release. &lt;/P&gt;
&lt;P&gt;So this is me trying to do my part; the ball is in &lt;STRONG&gt;your&lt;/STRONG&gt; court now, Charting fans. &lt;EM&gt;So, what's it going to be then, eh?&lt;/EM&gt; &lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9894842" 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>Get out of the way with the tray ["Minimize to tray" sample implementation for WPF]</title><link>http://blogs.msdn.com/delay/archive/2009/08/31/get-out-of-the-way-with-the-tray-minimize-to-tray-sample-implementation-for-wpf.aspx</link><pubDate>Tue, 01 Sep 2009 08:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9889700</guid><dc:creator>Delay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/delay/comments/9889700.aspx</comments><wfw:commentRss>http://blogs.msdn.com/delay/commentrss.aspx?PostID=9889700</wfw:commentRss><description>&lt;DIV class=delay&gt;
&lt;P&gt;"Minimize to tray" is a feature in some applications where minimizing the application removes its taskbar button and replaces it with a (much smaller) notification area icon. Clicking that notification icon restores the application's window - just like clicking its taskbar button would have done. &lt;/P&gt;
&lt;P&gt;Well, I was considering using this functionality in a project I'm working on, so I looked to see what my options were. This feature didn't seem to be directly supported by WPF, so I searched the web a bit. What I found after a minute or two of searching was plenty of questions about how to implement this, a few suggestions, and not a lot else. So I figured I'd put something together myself and post it to my blog... &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the sample application I'm about minimize - note the (boring) green square of an application icon: &lt;/P&gt;&lt;IMG alt="About to minimize" src="http://blogs.msdn.com/blogfiles/delay/MinimizeToTrayDemo-Minimize.png" width=300 height=300 mce_src="http://blogs.msdn.com/blogfiles/delay/MinimizeToTrayDemo-Minimize.png"&gt; 
&lt;P&gt;And here's what things look like &lt;STRONG&gt;just after&lt;/STRONG&gt; the application is minimized to the tray: &lt;/P&gt;&lt;IMG alt="Notify balloon" src="http://blogs.msdn.com/blogfiles/delay/MinimizeToTrayDemo-Balloon.png" width=265 height=92 mce_src="http://blogs.msdn.com/blogfiles/delay/MinimizeToTrayDemo-Balloon.png"&gt; 
&lt;P&gt;Aside from just looking cool, that notification bubble serves an important purpose: it helps to draw the user's attention to the new icon in the notification area and calls out the application's custom minimize behavior. (To avoid being annoying, the bubble is only shown the first time the application is minimized each time it's run.) This is a nice convenience on most versions of Windows, but is pretty much &lt;STRONG&gt;necessary&lt;/STRONG&gt; due to the new &lt;A href="http://msdn.microsoft.com/en-us/library/aa511448.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa511448.aspx"&gt;Windows 7 behavior of hiding notification area icons as quickly as possible&lt;/A&gt;. Without a helpful indication like this bubble, users might "lose" the application when it minimizes to the tray. &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: I understand why the Windows 7 team introduced this new behavior and I think it's perfectly reasonable. However, it has implications for this scenario, so it's good to think twice (or thrice!) about choosing to use "minimize to tray" in your application. The document I link to above has lots more guidance on the proper use of notification icons - interested parties are encouraged to review it! &lt;/BLOCKQUOTE&gt;
&lt;P&gt;After Windows 7 hides the notification icon for the application, it can be accessed via the "Show hidden icons" popup. Clicking on the hidden notification icon restores the application just like you'd expect: &lt;/P&gt;&lt;IMG alt="Hidden by Windows 7" src="http://blogs.msdn.com/blogfiles/delay/MinimizeToTrayDemo-Hidden.png" width=295 height=186 mce_src="http://blogs.msdn.com/blogfiles/delay/MinimizeToTrayDemo-Hidden.png"&gt; 
&lt;BLOCKQUOTE&gt;&lt;STRONG&gt;Aside&lt;/STRONG&gt;: If you really dislike the new hiding behavior, it's easy to disable - just click the "Customize..." link (shown in the image above) and you'll be presented with a window that lets you disable this behavior for specific applications - or disable it for &lt;STRONG&gt;all&lt;/STRONG&gt; of them with a single checkbox. &lt;/BLOCKQUOTE&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;I've implemented this functionality in a static &lt;CODE&gt;MinimizeToTray&lt;/CODE&gt; class with a single &lt;CODE&gt;Enable&lt;/CODE&gt; method that's super-easy to use. Just add a call to it in your &lt;CODE&gt;Window&lt;/CODE&gt;'s constructor and you're done: &lt;PRE&gt;&lt;SPAN style="COLOR: #000000"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Enable "minimize to tray" behavior for this Window
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MinimizeToTray&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Enable(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/LI&gt;
&lt;LI&gt;WPF doesn't natively offer notify icon support, but there's nothing stopping us from using the &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx"&gt;NotifyIcon&lt;/A&gt; implementation that's part of WinForms! That's what &lt;CODE&gt;MinimizeToTray&lt;/CODE&gt; does, so it's important to note that you'll need to change your project to add references to the &lt;CODE&gt;System.Drawing&lt;/CODE&gt; and &lt;CODE&gt;System.Windows.Forms&lt;/CODE&gt; .NET assemblies. (FYI, they're both part of the .NET Framework and are already present in the &lt;A href="http://en.wikipedia.org/wiki/Global_Assembly_Cache" mce_href="http://en.wikipedia.org/wiki/Global_Assembly_Cache"&gt;GAC&lt;/A&gt; (and &lt;A href="http://en.wikipedia.org/wiki/Common_Intermediate_Language#Native_image_generator_compilation" mce_href="http://en.wikipedia.org/wiki/Common_Intermediate_Language#Native_image_generator_compilation"&gt;NGEN&lt;/A&gt;-ed), so you don't need to worry about distributing them with your application.) &lt;/LI&gt;
&lt;LI&gt;But it's also important to note that I've written my code such that &lt;CODE&gt;MinimizeToTray&lt;/CODE&gt; doesn't cause &lt;STRONG&gt;either&lt;/STRONG&gt; of these assemblies get loaded until the user first minimizes the application. This means neither assembly will impact the startup time of your application! (You can verify this by running the sample application, attaching the debugger, checking the module list to see that neither assembly is present, minimizing the application, and then noting that both assemblies just got loaded.) &lt;/LI&gt;
&lt;LI&gt;I only use the most basic notify icon functionality in this sample, so the WinForms implementation is more than adequate for my needs. However, if you're looking for true WPF-style notification icon support, &lt;A href="http://www.hardcodet.net/projects/wpf-notifyicon" mce_href="http://www.hardcodet.net/projects/wpf-notifyicon"&gt;this implementation by Philipp Sumi&lt;/A&gt; looks quite promising (though I haven't tried it myself). &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a final favor, I'll ask that people please use "minimize to tray" wisely - just because you &lt;STRONG&gt;can&lt;/STRONG&gt; minimize your application to the tray doesn't mean you &lt;STRONG&gt;should&lt;/STRONG&gt;. &lt;NOBR&gt;:)&lt;/NOBR&gt; Minimizing to the tray is something that's only meaningful for a limited set of scenarios - but if you find yourself in one of them, I hope &lt;CODE&gt;MinimizeToTray&lt;/CODE&gt; is helpful! &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/MinimizeToTrayDemo/MinimizeToTrayDemo.zip" mce_href="http://cesso.org/Samples/MinimizeToTrayDemo/MinimizeToTrayDemo.zip"&gt;[Click here to download the sample application and complete source code for &lt;CODE&gt;MinimizeToTray&lt;/CODE&gt;.]&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is quite straightforward - here it is in its entirety: &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 implementing support for "minimize to tray" functionality.
&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;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;MinimizeToTray
&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; Enables "minimize to tray" behavior for the specified Window.
&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="window"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Window to enable the behavior for.&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;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; Enable(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Window&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; window)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// No need to track this instance; its event handlers will keep it alive
&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;MinimizeToTrayInstance&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(window);
    }

    &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; Class implementing "minimize to tray" functionality for a Window 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: #0000ff"&gt;private&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;MinimizeToTrayInstance
&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;Window&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _window;
        &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;NotifyIcon&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _notifyIcon;
        &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;bool&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _balloonShown;

        &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 MinimizeToTrayInstance 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="window"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Window instance to attach 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: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; MinimizeToTrayInstance(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Window&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; window)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Debug&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Assert(window != &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: #a31515"&gt;"window parameter is null."&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
            _window = window;
            _window.StateChanged += &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;(HandleStateChanged);
        }

        &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 Window's StateChanged 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="sender"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Event 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; HandleStateChanged(&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;EventArgs&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; e)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (_notifyIcon == &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: #008000"&gt;// Initialize NotifyIcon instance "on demand"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                _notifyIcon = &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;NotifyIcon&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;();
                _notifyIcon.Icon = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Icon&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.ExtractAssociatedIcon(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Assembly&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.GetEntryAssembly().Location);
                _notifyIcon.MouseClick += &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;MouseEventHandler&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;(HandleNotifyIconOrBalloonClicked);
                _notifyIcon.BalloonTipClicked += &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;(HandleNotifyIconOrBalloonClicked);
            }
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Update copy of Window Title in case it has changed
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            _notifyIcon.Text = _window.Title;

            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Show/hide Window and NotifyIcon
&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; minimized = (_window.WindowState == &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;WindowState&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Minimized);
            _window.ShowInTaskbar = !minimized;
            _notifyIcon.Visible = minimized;
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; (minimized &amp;amp;&amp;amp; !_balloonShown)
            {
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// If this is the first time minimizing to the tray, show the user what happened
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;                _notifyIcon.ShowBalloonTip(1000, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;null&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;, _window.Title, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ToolTipIcon&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.None);
                _balloonShown = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;true&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; Handles a click on the notify icon or its balloon.
&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="sender"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;Event 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; HandleNotifyIconOrBalloonClicked(&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;EventArgs&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; e)
        {
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;// Restore the Window
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;            _window.WindowState = &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;WindowState&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;.Normal;
        }
    }
}
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9889700" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/delay/archive/tags/WPF/default.aspx">WPF</category></item></channel></rss>