<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Silverlight</title>
        <link>http://geekswithblogs.net/lbugnion/category/6670.aspx</link>
        <description>Microsoft Silverlight (ex WPF/E)</description>
        <language>en-US</language>
        <copyright>Laurent Bugnion</copyright>
        <managingEditor>laurent@galasoft.ch</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <creativeCommons:license>http://creativecommons.org/licenses/by/3.0/</creativeCommons:license>
        <item>
            <title>Silverlight 2 beta 2 is live!</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/06/07/silverlight-2-beta-2-is-live.aspx</link>
            <description>&lt;p&gt;Here we go, Silverlight 2 beta 2 can be downloaded and installed! I had the chance to take part to an "insiders" program at Microsoft, and to play with SL2 b2 for a couple of weeks, and it's a good one. You should switch to b2 as soon as you can!&lt;/p&gt; &lt;p&gt;There are obviously incompatibilities between b1 and b2, but much, much less than between the alpha version and b1. We're getting there!!&lt;/p&gt; &lt;p&gt;Silverlight 2 beta 2 will be used to build applications related to the Beijing olympics, so it's going to be a real nature test for that version. As for the final release.... it's still very much hush hush, so let's leave it for now :)&lt;/p&gt; &lt;p&gt;The best place to start is &lt;a href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx"&gt;ScottGu's blog&lt;/a&gt;. As usual, Scott describes the new features at length, and has links to all the places where you can download the good stuff.&lt;/p&gt; &lt;p&gt;Note that there is also a new version of Blend 2.5 which can be installed next to a "normal" Expression Blend V2. There is supposed to be a new version of Deep Zoom Composer too, but the download seems to be down currently.&lt;/p&gt; &lt;p&gt;Enjoy!!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122688"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122688" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/122688.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/06/07/silverlight-2-beta-2-is-live.aspx</guid>
            <pubDate>Sat, 07 Jun 2008 06:23:40 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/122688.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/06/07/silverlight-2-beta-2-is-live.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/122688.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/122688.aspx</trackback:ping>
        </item>
        <item>
            <title>A short break</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/05/31/a-short-break.aspx</link>
            <description>&lt;p class="gslb_rsbPParagraph"&gt;I am going to take a short break of blogging for a couple of months. The reason is simple: I have been working on a book about Silverlight 2 since September last year, and we are in a phase now where I need to concentrate on that exclusively, and put other activities aside. I might post the occasional article from time to time, but until mid-Summer, it's going to be write write write. &lt;/p&gt; &lt;p class="gslb_rsbPParagraph"&gt;Stay posted for news about the book coming up, and don't delete me from your feeds, it's really only temporary :) &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122512"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122512" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/122512.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/05/31/a-short-break.aspx</guid>
            <pubDate>Sat, 31 May 2008 11:34:38 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/122512.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/05/31/a-short-break.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/122512.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/122512.aspx</trackback:ping>
        </item>
        <item>
            <title>WPF talk this Thursday: "Ultra Rich Interactive Applications"</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/05/27/wpf-talk-this-thursday-ultra-rich-interactive-applications.aspx</link>
            <description>&lt;p class="gslb_rsbPParagraph"&gt;
I have been in very much stress lately and hardly had time to post, but I don't forget you, dear readers...
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Anyway, this Thursday, I will be talking in a RIA conference organized by the &lt;a href="http://www.internet-briefing.ch/RiaKonferenz" target="_blank"&gt;Internet Briefing group&lt;/a&gt; here in Zurich, in the World Trade Center. My talk is titled &lt;span style="font-weight:bold;"&gt;"Ultra Rich Interactive Applications with WPF"&lt;/span&gt; and subtitled &lt;span style="font-weight:bold;"&gt;"When Silverlight is not enough..."&lt;/span&gt;. I think it's going to be an interesting talk (but obviously I am partial) about the major differences between WPF and Silverlight, and the added richness that WPF provides. I am a big fan of Silverlight, but I have to admit that it's nice going back to the amazing power of WPF sometimes, without having to worry about "is that feature even implemented in Silverlight"?
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The talk takes place between 16:30 and 17:30 in the World Trade Center, Leutschenbachstrasse 95, 8050 Zürich. Hoping to see some of you there, maybe!
&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122405"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122405" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/122405.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/05/27/wpf-talk-this-thursday-ultra-rich-interactive-applications.aspx</guid>
            <pubDate>Tue, 27 May 2008 12:47:23 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/122405.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/05/27/wpf-talk-this-thursday-ultra-rich-interactive-applications.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/122405.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/122405.aspx</trackback:ping>
        </item>
        <item>
            <title>Silverlight: User Controls with events</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/04/26/silverlight-user-controls-with-events.aspx</link>
            <description>&lt;div class="gslb_rsbDivFrame"&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
This article is for Silverlight 2 beta 1
&lt;/p&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivFrame"&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Update: &lt;a href="http://blogs.ugidotnet.org/ccavalli/Default.aspx" target="_blank"&gt;Corrado Cavalli&lt;/a&gt; translated &lt;a href="#20080426215151download"&gt;the example&lt;/a&gt; in VB.NET. Thanks Corrado!!
&lt;/p&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Apparently, one reader had issues declaring events for the &lt;a href="http://blog.galasoft.ch/archive/2008/04/16/silverlight-packing-user-controls-in-separate-assemblies.aspx" target="_blank"&gt;User Control example&lt;/a&gt; that I posted earlier this week.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
He is programming in VB and unfortunately I don't have a lot of experience with VB.NET, so I first created a working example with C#, and my good friend and fellow MVP Corrado Cavalli translated the example in VB.NET (&lt;a href="#20080426215151download"&gt;see below&lt;/a&gt;).
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The big difference between WPF and Silverlight regarding events is that Silverlight doesn't support Routed Events (yet?). To be precise, some events are routed (all input events like MouseLeftButtonDown, KeyDown, etc...
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Instead of declaring RoutedEvents in our User Control, we have to resort to standard .NET events then. From a user point of view, it doesn't make a very big difference in the subscribing, but of course these events will not tunnel nor bubble (for a summary of RoutedEvents, bubbling and tunneling in WPF, &lt;a href="http://msdn2.microsoft.com/en-us/library/ms742806.aspx" target="_blank"&gt;read this&lt;/a&gt;).
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The sample here declares a User Control called LeftRightButton, with two buttons, a LeftButton and a RightButton. it also declares two events, a LeftClick and a RightClick. When the RightButton gets clicked, the UserControls catch this event and raises a RightClick event. The same happens with the LeftButton and the LeftClick event.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Declaring new events for any class requires a Handler declaration (a delegate), and then the event declaration itself.
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;delegate&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; &lt;span class="type"&gt;ClickHandler&lt;/span&gt;(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, &lt;span class="type"&gt;EventArgs&lt;/span&gt; e);
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; &lt;span class="type"&gt;ClickHandler&lt;/span&gt; RightClick;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; &lt;span class="type"&gt;ClickHandler&lt;/span&gt; LeftClick;
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The next step is to catch the internal click events, and to raise the corresponding "external" event. Note that in this simplified example, I just re-route the RoutedEventArg for the event. Often, you need to declare your own class inheriting EventArgs, for example to pass additional parameters to the event subscriber.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
So if the XAML LeftButton is declared as:
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LeftButton"&lt;/span&gt;
        &lt;span class="attr"&gt;Click&lt;/span&gt;&lt;span class="kwrd"&gt;="LeftButton_Click"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
then we have:
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;void&lt;/span&gt; RaiseLeftClick(&lt;span class="type"&gt;RoutedEventArgs&lt;/span&gt; e)
{
  &lt;span class="kwrd"&gt;if&lt;/span&gt; (LeftClick != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
  {
    LeftClick(&lt;span class="kwrd"&gt;this&lt;/span&gt;, e);
  }
}
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Note how we check if the event is null before we raise it. If no one subscribed to the event, LeftClick will be null, and there is a risk for a NullReferenceException to be thrown.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Then only thing that we need to do now is catch the internal click event, and raise the corresponding RightClick or LeftClick event.
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LeftButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, &lt;span class="type"&gt;RoutedEventArgs&lt;/span&gt; e)
{
  RaiseLeftClick(e);
}
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The User Control raising these events is located in an external assembly &lt;a href="http://blog.galasoft.ch/archive/2008/04/16/silverlight-packing-user-controls-in-separate-assemblies.aspx" target="_blank"&gt;as shown here&lt;/a&gt;. I use 4 instances of the User Control in a Silverlight application. This way, we demonstrate how to raise new events, how to catch them in another assembly, and how to handle them.
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;controls:LeftRightButton&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="ButtonTopLeft"&lt;/span&gt;
                          &lt;span class="attr"&gt;RightClick&lt;/span&gt;&lt;span class="kwrd"&gt;="LeftRightButtonButton_RightClick"&lt;/span&gt;
                          &lt;span class="attr"&gt;LeftClick&lt;/span&gt;&lt;span class="kwrd"&gt;="LeftRightButtonButton_LeftClick"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LeftRightButtonButton_LeftClick(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, &lt;span class="type"&gt;EventArgs&lt;/span&gt; e)
{
  LastEventControlNameTextBlock.Text = (sender &lt;span class="kwrd"&gt;as&lt;/span&gt; &lt;span class="type"&gt;LeftRightButton&lt;/span&gt;).Name;
  LastEventEventNameTextBlock.Text = &lt;span class="str"&gt;"LeftClick"&lt;/span&gt;;
}
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008042601.png" alt="4 user controls with events" title="4 user controls with events" /&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
&lt;a id="20080426215151download"&gt;&lt;/a&gt;The source code in C# &lt;a href="http://blog.galasoft.ch/mydotnet/articles/resources/article-2008042601/GalaSoft.SL.PackingUserControlWithEvents.zip" target="_blank"&gt;can be downloaded here&lt;/a&gt;.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The source code in VB.NET (translated by &lt;a href="http://blogs.ugidotnet.org/ccavalli/Default.aspx" target="_blank"&gt;Corrado Cavalli&lt;/a&gt;) &lt;a href="http://blog.galasoft.ch/mydotnet/articles/resources/article-2008042601/GalaSoft.SL.PackingUserControlWithEventsVB.zip" target="_blank"&gt;can be downloaded here&lt;/a&gt;.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
&lt;a href="http://www.galasoft.ch" target="_new" atomicselection="true"&gt;&lt;img alt="http://www.galasoft.ch" src="http://www.galasoft.ch/images/counter-blog-all.png" /&gt;&lt;/a&gt;
&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121671"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121671" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/121671.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/04/26/silverlight-user-controls-with-events.aspx</guid>
            <pubDate>Sat, 26 Apr 2008 19:59:55 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/121671.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/04/26/silverlight-user-controls-with-events.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/121671.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/121671.aspx</trackback:ping>
        </item>
        <item>
            <title>Silverlight: Running standalone full trust applications</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/04/24/silverlight-running-standalone-full-trust-applications.aspx</link>
            <description>&lt;div class="gslb_rsbDivTitle"&gt;
Introduction
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
I guess that it's time to write about it, after making a few people curious at the MVP summit in Seattle. &lt;a href="http://www.galasoft.ch/mydotnet/articles/article-2008042301.html" target="_blank"&gt;This article&lt;/a&gt; is to be taken as a proof of concept, and (I hope) as a way to "motivate" Microsoft to integrate this ability into Silverlight.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
As soon as I started playing with Silverlight, I saw the great potential that this technology has. As a RIA technology, it provides extended functionality over the web. As a WPF subset, it allows me to leverage the knowledge I already acquired in the past, and to reuse it for web applications. This in itself makes Silverlight a technology I *have to* learn.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
But what if... what if we could use Silverlight to run lightweight .NET applications in standalone mode? A little like Adobe AIR is offering, but with the power of .NET instead of ActionScript. Imagine a small application, running on a small framework, installed in typically 10 seconds.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
I posted &lt;a href="http://www.galasoft.ch/mydotnet/articles/article-2008042301.html" target="_blank"&gt;an article on my site&lt;/a&gt; explaining the thought process and giving information about standalone Silverlight applications, their promises and their limitations. For those of you too impatient to read the full article :) you can download a demo and the source code directly from here.
&lt;/p&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
The demo
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
To install the demo, follow the steps:
&lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
Download &lt;a href="http://blog.galasoft.ch/mydotnet/GalaSoft.SL.TestHta/V1.0.0/StandaloneSilverlightApplication.zip" target="_blank"&gt;the Zip file&lt;/a&gt;.
&lt;/li&gt;
&lt;li&gt;
Extract the Zip file to a folder on your hard drive.
&lt;/li&gt;
&lt;li&gt;
On Windows: double-click the file "Start.hta".
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
This starts the MSHTA host, and displays the Silverlight application.
&lt;/p&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008042201.png" alt="Silverlight application in MSHTA" title="Silverlight application in MSHTA" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt;
Silverlight application in MSHTA
&lt;/div&gt;
&lt;/div&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
Enter a directory path in the first textbox, and then click on "Get list of files". This displays the corresponding list in the listbox.
&lt;/li&gt;
&lt;li&gt;
Select a file. Its name is displayed in the second textbox.
&lt;/li&gt;
&lt;li&gt;
You can now modify the file name and press on "Rename".
&lt;/li&gt;
&lt;li&gt;
Enter any file path in the last textbox and press "Does file exist?". A corresponding message is displayed in the status bar.
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
This last functionality is also available in Mozilla-based browsers, for example Firefox. You can try it by setting Firefox to be your default browser, and then double-clicking the file "index.html" located in the same folder as "index.hta". This starts the application in "file" mode, and you get the same permissions. The other functionalities "Get list of files" and "Rename" are &lt;span style="font-weight:bold;"&gt;not implemented in Firefox&lt;/span&gt; and will raise an error.
&lt;/p&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008042202.png" alt="Silverlight application in Firefox" title="Silverlight application in Firefox" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt;
Silverlight application in Firefox
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Source code
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
As usual, the &lt;a href="http://blog.galasoft.ch/mydotnet/GalaSoft.SL.TestHta/V1.0.0/GalaSoft.SL.TestHta.zip" target="_blank"&gt;source code&lt;/a&gt; is available for download. It contains the following projects:
&lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
GalaSoft.SL.TestHta: This is the Silverlight application you want to run. It contains an "index.html" file, which should be the start page if you run the application in "F5" or "Ctrl-F5" mode in Studio. Visual Studio runs the HTML file in file mode, so you get a chance to debug the Silverlight code, but unfortunately it is not possible to debug the JavaScript code. When you build the project, a "index.hta" file is automatically created. This is exactly the same as "index.html", but with a different extension. Double-clicking this file in Windows Explorer will start the MSHTA host.
&lt;/li&gt;
&lt;li&gt;
GalaSoft.SL.IO: This is a library defining a new DirectoryInfo and FileInfo classes. These classes mimic the actual System.IO.DirectoryInfo and System.IO.FileInfo classes. They use the class "GalaSoft.SL.IO.ScriptFacade" to channel the full-trust calls to the script code contained in the file "script\gslb.filesystemexplorer.js".
&lt;/li&gt;
&lt;li&gt;
GalaSoft.SL.IO.Test: A Unit Test application for GalaSoft.SL.IO. Written using the Silverlight Unit Test framework and accessing JavaScript as &lt;a href="http://blog.galasoft.ch/archive/2008/04/05/silverlight-unit-testing-and-javascript.aspx" target="_blank"&gt;described here&lt;/a&gt;. I use this to unit test all my IO classes and methods, including the corresponding JavaScript file.
&lt;br /&gt;Note: The console application "GalaSoft.SL.IO.Test.Prepare" must be executed before the unit test is run.
&lt;/li&gt;
&lt;li&gt;
GalaSoft.SL.IO.Test.Prepare: This console application is needed to create a few directories and files in the local drive in order to unit test the library GalaSoft.SL.IO. It requires write-permission to the folder c:\temp. Unfortunately, I don't think that Mock frameworks exist for JavaScript yet.
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
In normal use, the project GalaSoft.SL.TestHta should be chosen as startup project, and its file "index.html" as startup page. You can modify the application code. If you change the HTML code, the changes will automatically be copied to "index.hta" when you build the application.
&lt;/p&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008042001.png" alt="Components involved in a standalone Silverlight application" title="Components involved in a standalone Silverlight application" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt;
Components involved in a standalone Silverlight application
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
&lt;a href="http://www.galasoft.ch" target="_new" atomicselection="true"&gt;&lt;img alt="http://www.galasoft.ch" src="http://www.galasoft.ch/images/counter-blog-all.png" /&gt;&lt;/a&gt;
&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121607"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121607" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/121607.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/04/24/silverlight-running-standalone-full-trust-applications.aspx</guid>
            <pubDate>Thu, 24 Apr 2008 12:09:29 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/121607.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/04/24/silverlight-running-standalone-full-trust-applications.aspx#feedback</comments>
            <slash:comments>9</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/121607.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/121607.aspx</trackback:ping>
        </item>
        <item>
            <title>Silverlight: Packing user controls in separate assemblies</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/04/16/silverlight-packing-user-controls-in-separate-assemblies.aspx</link>
            <description>&lt;div class="gslb_rsbDivFrame"&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
This article is for Silverlight 2 beta 1
&lt;/p&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
There is a common misconception that User Controls in Silverlight must be placed in the assembly from which they are referenced. However, this is not true, you can have user controls in an assembly and use them from another assembly. This is not a direct process, however, so let's see how to proceed:
&lt;/p&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Preparing the control
&lt;/div&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
Create a new Silverlight 2 application in Visual Studio. In this example, we'll name this application "UserControlsPacking". For this first application, you can choose to generate a test web application, or to use a basic HTML test page.
&lt;/li&gt;
&lt;li&gt;
In the same solution, create another Silverlight application. Let's name it "UserControlsPacking.Controls". Choose the "Generate a HTML test page" option, to avoid creating unnecessary test projects.
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
In the moment, Silverlight 2 beta 1 has only 2 project templates available: "Silverlight Application" and "Silverlight Class Library". Ideally, we would need a "Silverlight User Control Library", just like there is a "WPF User Control Library" for WPF. This option is not available however, so we will "misuse" an Application template to pack our user controls.
&lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
In the application named "UserControlsPacking.Controls", delete the following files: App.xaml, App.xaml.cs, Page.xaml, Page.xaml.cs.
&lt;/li&gt;
&lt;li&gt;
Right-click on the "UserControlsPacking.Controls" project in the Solution explorer, and select "Add / New Item...".
&lt;/li&gt;
&lt;li&gt;
Under "Silverlight", select the "Silverlight User Control" item template.
&lt;/li&gt;
&lt;li&gt;
Implement the new user control, for example by opening the XAML file in Blend, and adding some code.
&lt;br /&gt;Note: You should probably delete the "Width" and "Height" property as the very first thing you do in your XAML. Studio fix-codes these properties automatically, but let's be frank, noone wants this in a control.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Using the User Control in Studio
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
After implementing the user control, now it's time to use it. First we must add a reference to the "UserControlsPacking.Controls" project in the main application project.
&lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
Right-click on the "UserControlsPacking" project and choose "Add Reference...".
&lt;/li&gt;
&lt;li&gt;
In the tab "Projects", select the "UserControlsPacking.Controls" project and click OK.
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
From this moment on, you can use the User Control in the main project. You can either add the User Control in Blend (see below) or in XAML.
&lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
In Studio, open the file "Page.xaml".
&lt;/li&gt;
&lt;li&gt;
You need to add a reference to the namespace containing the new UserControl. This gets added as an XML prefix in the UserControl tag.
&lt;br /&gt;(Note: Studio assists you there: Simply type "xmlns:control=" and Intellisense will propose you a list of all the XML namespaces, including those located in referenced assemblies).
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="GalaSoft.SL.UserControlsPacking.Page"&lt;/span&gt;
             &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/client/2007"&lt;/span&gt;
             &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;
             &lt;span class="attr"&gt;xmlns:controls&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:GalaSoft.SL.UserControlsPacking.Controls;assembly=GalaSoft.SL.UserControlsPacking.Controls"&lt;/span&gt;
             &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="400"&lt;/span&gt;
             &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
Once this is done, you can use the control in the XAML code, for example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt;
      &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="White"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=".5*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=".5*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="Magenta"&lt;/span&gt;
          &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="2"&lt;/span&gt;
          &lt;span class="attr"&gt;Padding&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;FontSize&lt;/span&gt;&lt;span class="kwrd"&gt;="15"&lt;/span&gt;
                 &lt;span class="attr"&gt;FontWeight&lt;/span&gt;&lt;span class="kwrd"&gt;="Bold"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Billing:&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;controls:AddressControl&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="Magenta"&lt;/span&gt;
          &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="2"&lt;/span&gt;
          &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;
          &lt;span class="attr"&gt;Padding&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;FontSize&lt;/span&gt;&lt;span class="kwrd"&gt;="15"&lt;/span&gt;
                 &lt;span class="attr"&gt;FontWeight&lt;/span&gt;&lt;span class="kwrd"&gt;="Bold"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Shipping:&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;controls:AddressControl&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Using the control in Blend
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Like you would expect, you can also find the User Control in Blend's asset library, even though it is located in an external assembly. To find the control, simply open the asset library (that's the last button down in the Toolbox bar). Then click on the tab "Custom Controls". You should be able to see your user control in the list. Note however that the control sometimes doesn't show up immediately. Make sure that you saved your whole solution in Visual Studio, make sure that you built everything, and try to open the asset library a few times to update the list.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Note that Blend takes care of adding the necessary namespaces to the XAML, so you don't need to worry what we did in the first code snippet above.
&lt;/p&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008041502.png" alt="Adding a user control in Blend" title="Adding a user control in Blend" /&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008041501.png" alt="2 instances of the same User Control" title="2 instances of the same User Control" /&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Resources
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
You can download a &lt;a href="http://www.galasoft.ch/mydotnet/articles/resources/article-2008041501/GalaSoft.SL.UserControlsPacking.zip" target="_blank"&gt;sample application demonstrating this&lt;/a&gt;. Simply open the SLN file in Studio 2008.
&lt;/p&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Conclusion
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
User controls are often presented as a way to encapsulate parts of the UI, and much less as a way to reuse UI elements in different projects. This is often what Custom Controls are used for.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
However, User Controls are a bit easier to understand. While the "lookless-ness" of a CustomControl is bigger than of a UserControl, while the "canonic" way of creating reuseable controls is to rather use CustomControls, I find myself using UserControls time and time again. It's good to know that you can actually use UserControls very much in the same way that you can use CustomControls. HTH!
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
&lt;a href="http://www.galasoft.ch" target="_new" atomicselection="true"&gt;&lt;img alt="http://www.galasoft.ch" src="http://www.galasoft.ch/images/counter-blog-all.png" /&gt;&lt;/a&gt;
&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121283"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121283" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/121283.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/04/16/silverlight-packing-user-controls-in-separate-assemblies.aspx</guid>
            <pubDate>Wed, 16 Apr 2008 12:49:34 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/121283.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/04/16/silverlight-packing-user-controls-in-separate-assemblies.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/121283.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/121283.aspx</trackback:ping>
        </item>
        <item>
            <title>De WPF Integratio (About WPF Integration)</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/04/11/de-wpf-integratio-about-wpf-integration.aspx</link>
            <description>&lt;div class="gslb_rsbDivTitle"&gt; Introduction &lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt; I've been posting a lot about Silverlight lately, but hey, here is a WPF post, and about WPF integration, no less. &lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Note&lt;/span&gt;: To fully understand this article, you should have a basic understanding of WPF, styles and templates, triggers, etc... &lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt; In my current project at work, I act as WPF Integrator. I am that dude who sits between the designers and the developers, and tries to avoid that they fight too much. Or something. Sometimes it works, sometimes it doesn't, you know how it is with kids. They need their freedom. But I digress. &lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt; One important task of a WPF Integrator is (drum roll) WPF integration. For us, this operation usually occurs when we have a design iteration. The way we create application components is (roughly) the following: &lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
    &lt;li&gt; The Developer creates the component in Visual Studio. The component is composed of a main assembly (EXE or DLL), containing "functional XAML" and source code (code-behind), and a "Skins" DLL containing XAML resource dictionaries. &lt;br /&gt;
    (Note: Because we don't want any source code into the "Skins" DLL, and to avoid circular references, we actually have a 3rd assembly called "Converters". As the name shows, this assembly contains the converters (and other helper classes) that are referenced from the Skins DLL). &lt;/li&gt;
    &lt;li&gt; Together with the WPF Integrator, they create a "raw" UI. That means a basic layout made of "functional XAML", according to the wireframes created by our user experience engineers. &lt;br /&gt;
    (Note: "functional XAML" is the XAML code that is not strictly doing look&amp;amp;feel. For example, a Button tag is functional XAML, while the style and template it uses are "design XAML"). &lt;/li&gt;
    &lt;li&gt; The WPF Integrator prepares the Skins DLL by exporting all styles to it (using Blend). We follow certain guidelines in naming all the components (styles, templates, DLL names, etc...) and also in the structure of the styles and templates (see below). &lt;/li&gt;
    &lt;li&gt; The Developers start what they do best, Developing. Meanwhile, the Designer do what they do best (let me hear you:) Designing! This is the Design iteration I was referring to before. &lt;br /&gt;
    (Note: The Developer *only* works in the main assembly. The Designer *only* works in the Skins assembly. &lt;/li&gt;
    &lt;li&gt; If the Designer needs to change something in the main assembly, they contact the WPF Integrator to coordinate. &lt;/li&gt;
    &lt;li&gt; Similarly, if the Developer needs to change something in the Skins DLL, they contact the WPF Integrator to coordinate. &lt;/li&gt;
    &lt;li&gt; When a set of features are complete, the Developers' and Designers' work is &lt;span style="font-weight: bold;"&gt;integrated&lt;/span&gt; and tested. &lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt; Typically, we integrate the design to the application during design workshops, where a couple of Designers and Developers (and the WPF Integrator) sit together and work together, pretty much in an Extreme Programming spirit. These workshops are very intense and interesting, and usually allow fast progress in the application's look&amp;amp;feel. &lt;/p&gt;
&lt;div class="gslb_rsbDivTitle"&gt; Conventions, file structure, naming &lt;/div&gt;
&lt;ul class="gslb_rsbList"&gt;
    &lt;li&gt; A control refers to a Style which in turn refers to a Template (this is to facilitate the designers' job in Blend). &lt;/li&gt;
    &lt;li&gt; A control does *not* set its template directly, but always through a style. &lt;/li&gt;
    &lt;li&gt; If triggers are needed in the main assembly, the local style refers to a "BasedOn" style located in the Skins DLL. &lt;/li&gt;
    &lt;li&gt; A Style key is named like the control it refers to, suffixed with "Style". For example "MySpecificButtonStyle" or "ListBoxStyle" (for all ListBoxes), etc... &lt;/li&gt;
    &lt;li&gt; A Template key is named like the control it refers to, suffixed with "Template". For example "MySpecificButtonTemplate" or "ListBoxTemplate" (for all ListBoxes), etc... &lt;br /&gt;
    (note: We use the "Template" suffix for ControlTemplate and DataTemplate). &lt;/li&gt;
    &lt;li&gt; The skin resources for a given control are stored in a resource dictionary file with the "Skin" suffix. For example, the control "MyUserControl"'s resource dictionary is named "MyUserControlSkin.xaml". &lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt; These guidelines help the designers to understand which Style and Template belong to which control. Note that Blend makes that task easier by allowing to navigate from the main assembly to the Skins assembly with a succession of clicks. &lt;/p&gt;
&lt;div class="gslb_rsbDivTitle"&gt; Typical Designer workflow &lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt; The very first task a designer must do when he gets the code is to understand its structure. This is where the conventions mentioned above help. Typically, they work this way: &lt;br /&gt;
(Note: You can download &lt;a target="_blank" href="http://www.galasoft.ch/mydotnet/articles/resources/article-2008031901/WpfTests.BestPractices.zip"&gt;a sample application&lt;/a&gt; here, open the SLN file in Blend, and then open the main window (Window1.xaml)) &lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
    &lt;li&gt; Open the application's main window in Blend and check the logical tree. &lt;/li&gt;
    &lt;li&gt; If a user control is found, right-click on it and choose "Edit control" (fig 1). This opens the User Control XAML file in Blend. &lt;br /&gt;
    (Of course, this fails if the User Control's source code is not available). &lt;/li&gt;
    &lt;li&gt; For any control they want to skin, select the control, and then choose the menu "Object / Style" (fig 2 and 3). &lt;/li&gt;
    &lt;li&gt; At this point, the style chosen can be local (for example if the Developer need to use a Trigger, etc. See listing 1). The Designers are trained to check the name of the file in which they are currently located (in Blend). If the file is named without a "Skin" suffix (for example MyPlugIn.xaml), they may not edit it. In that case, they look for a BasedOn style (fig 4). If they are currently located in a file with a "Skin" suffic (for example "MyPlugInSkin.xaml", then they may edit it (fig 5). &lt;/li&gt;
    &lt;li&gt; Once in the Style, they can select the context menu "Edit Control Parts (Template) / Edit Template". This opens the Control Template in Blend, where they can rework to look&amp;amp;feel of the control completely (including triggers, animations, etc...) &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="gslb_rsbDivImage"&gt; &lt;img title="Figure 1: Edit control" alt="Figure 1: Edit control" src="http://www.galasoft.ch/blogs-all/2008041001.png" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt; Figure 1: Edit control &lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt; &lt;img title="Figure 2: Selecting a control" alt="Figure 2: Selecting a control" src="http://www.galasoft.ch/blogs-all/2008041002.png" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt; Figure 2: Selecting a control &lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt; &lt;img title="Figure 3: Edit style" alt="Figure 3: Edit style" src="http://www.galasoft.ch/blogs-all/2008041003.png" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt; Figure 3: Edit style &lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="GO"&lt;/span&gt;
        &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;
        &lt;span class="attr"&gt;Click&lt;/span&gt;&lt;span class="kwrd"&gt;="GoButton_Click"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button.Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="Button"&lt;/span&gt;
           &lt;span class="attr"&gt;BasedOn&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource RoundButtonStyle}"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="IsEnabled"&lt;/span&gt;
              &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style.Triggers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTrigger&lt;/span&gt; &lt;span class="attr"&gt;Binding&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding ElementName=DirectoryNameTextBox,
                                       Path=Text}"&lt;/span&gt;
                 &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="{x:Static sys:String.Empty}"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="IsEnabled"&lt;/span&gt;
                  &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="False"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTrigger&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style.Triggers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button.Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivLegend"&gt;
Listing 1: Local style using a Trigger, Based On a skin style
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt; &lt;img title="Figure 4: Edit " based-on=" style" alt="Figure 4: Edit " src="http://www.galasoft.ch/blogs-all/2008041004.png" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt; Figure 4: Edit "based-on" style &lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt; &lt;img title="Figure 5: Editing the style in the Skin file" alt="Figure 5: Editing the style in the Skin file" src="http://www.galasoft.ch/blogs-all/2008041005.png" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt; Figure 5: Editing the style in the Skin file &lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt; Note: Here we see the advantage of setting the "Template" property in the Style instead of directly in the control: The Designer can see the "shape" of the control already in Blend, without having to rebuild. &lt;/p&gt;
&lt;div class="gslb_rsbDivImage"&gt; &lt;img title="Figure 6: Editing the template in the Skin file" alt="Figure 6: Editing the template in the Skin file" src="http://www.galasoft.ch/blogs-all/2008041006.png" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt; Figure 6: Editing the template in the Skin file &lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivTitle"&gt; The importance of Blend &lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt; This workflow would fail miserably without Blend. It can never be repeated often enough: &lt;span style="font-weight: bold;"&gt;You should keep your application Blendable!&lt;/span&gt; (as long as possible). Blend will fail to represent the UI in some circumstances. For example, if your application connects to a COM based component, this is something that Blend cannot handle. Similarly, if your application uses any kind of network service to get data, Blend won't be able to represent this data. This is where the MVVM (Model - View - ViewModel pattern comes handy: By enforcing a data-driven UI, you give the developer the possibility to create "design-time" data, i.e. data which is only used when the application runs in Blend (or in the Visual Studio WPF designer). I could talk about that for hours, and this jumps the scope of this post, but you can read more info about MVVM here: &lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
    &lt;li&gt; &lt;a target="_blank" href="http://blogs.msdn.com/johngossman/"&gt;John Gossman&lt;/a&gt;'s blog. &lt;/li&gt;
    &lt;li&gt; &lt;a target="_blank" href="http://blogs.msdn.com/dancre/archive/2006/10/11/datamodel-view-viewmodel-pattern-series.aspx"&gt;Dan Crevier&lt;/a&gt;'s blog. &lt;/li&gt;
    &lt;li&gt; Josh Smith's &lt;a target="_blank" href="http://www.codeproject.com/KB/WPF/MVCtoUnitTestinWPF.aspx"&gt;excellent article&lt;/a&gt; at CodeProject &lt;/li&gt;
    &lt;li&gt; Dr WPF's new Software Architecture Pattern: &lt;a target="_blank" href="http://www.drwpf.com/blog/Home/tabid/36/EntryID/27/Default.aspx"&gt;M-V-poo&lt;/a&gt;. &lt;/li&gt;
    &lt;li&gt; My presentation at TechDays 2008 in Basel (&lt;a target="_blank" href="http://www.galasoft.ch/mydotnet/articles/resources/article-2008031901/SiemensGoesWPF.zip"&gt;slides&lt;/a&gt;, &lt;a target="_blank" href="http://www.galasoft.ch/mydotnet/articles/resources/article-2008031901/WpfTests.BestPractices.zip"&gt;source code&lt;/a&gt;). &lt;/li&gt;
    &lt;li&gt; And many more places on the web... &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="gslb_rsbDivTitle"&gt; Using WinMerge as an integration tool &lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt; During these integration phases, I use &lt;a target="_blank" href="http://winmerge.org/"&gt;WinMerge&lt;/a&gt; a lot. The reasons for using this merging tool are multiple: &lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
    &lt;li&gt; It is probably the best merging tool currently available for Windows (if someone disagrees, don't hesitate to comment below!!). &lt;/li&gt;
    &lt;li&gt; Our Designers don't work in our source control infrastructure. They get a copy of the code, refactored as a standalone application. This allows them to test the application easily without having to install a whole networking system (our application is following a Service Oriented Architecture). The aplication they get features a test mode, allowing them to simulate certain conditions (again, see my &lt;a target="_blank" href="http://www.galasoft.ch/mydotnet/articles/resources/article-2008031901/SiemensGoesWPF.zip"&gt;TechDays talk&lt;/a&gt; and the &lt;a target="_blank" href="http://www.galasoft.ch/mydotnet/articles/resources/article-2008031901/WpfTests.BestPractices.zip"&gt;source code&lt;/a&gt; for details). Because they work disconnected from the source control, a merging operation is needed. &lt;/li&gt;
    &lt;li&gt; The merging steps give me a good occasion to review the Designers and Developers work, and to understand it. This is an additional step towards code consistency and code quality (4 eyes review principle). &lt;/li&gt;
&lt;/ul&gt;
&lt;p class="gslb_rsbPParagraph"&gt; WinMerge is simply amazing, a must-use tool for a WPF Integrator (at least if you work according to a similar workflow as we do). It is free (amazing, when you see the quality of this tool), was clearly developed by people who needed such a tool and decided to create it (according to the "eat your dog food" idea), and can even be integrated into your favourite source control framework (yes, even ClearCase, which we are forced to use). You can compare folders, binary files, text files with a very clear user interface. All merging operations can be performed using the keyboard only, which is extremely ergonomic. Honestly, I love that tool. &lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt; By the way, I didn't mention it yet, but you can also edit both files you are comparing in WinMerge, and save both of them. &lt;/p&gt;
&lt;div class="gslb_rsbDivImage"&gt; &lt;img title="WinMerge, merging tool" alt="WinMerge, merging tool" src="http://www.galasoft.ch/blogs-all/2008040901.png" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt; WinMerge, merging tool &lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivTitle"&gt; Conclusion &lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt; Much has been written about the Designer-Developer workflow, the WPF Integrator role, the MVVM (or MV*) pattern, etc... In our project, we have the chance to use these principles in a real life situation. I can honestly say, I rarely had so much fun developing software ever. The only thing I can think of that made (almost) as much fun was the big ASP.NET project I worked on prior to this one. The Integrator role is a great place to be.&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt; (Note: I also file this under Silverlight because WinMerge is also very useful for Silverlight integration, even though the Style and Template system is not as rich as in WPF yet). &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121193"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121193" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/121193.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/04/11/de-wpf-integratio-about-wpf-integration.aspx</guid>
            <pubDate>Fri, 11 Apr 2008 20:38:56 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/121193.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/04/11/de-wpf-integratio-about-wpf-integration.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/121193.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/121193.aspx</trackback:ping>
        </item>
        <item>
            <title>Silverlight unit testing and JavaScript</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/04/05/silverlight-unit-testing-and-javascript.aspx</link>
            <description>&lt;p class="gslb_rsbPParagraph"&gt;I am currently writing a Silverlight class library which I want to use in a project, and decided to try Test Driven Development for this class. This is a really nice way to work, and the Silverlight development team made this very easy by providing a unit test framework easy to integrate into Visual Studio 2008. &lt;/p&gt; &lt;p class="gslb_rsbPParagraph"&gt;(Note: You cannot simply use the built-in unit test framework, because a non-Silverlight application cannot reference a Silverlight class library). &lt;/p&gt; &lt;p class="gslb_rsbPParagraph"&gt;To find information about where to download and how to install the Silverlight unit test framework, check &lt;a href="http://www.jeff.wilcox.name/2008/03/07/silverlight-unit-testing/" target="_blank"&gt;this post&lt;/a&gt;. &lt;/p&gt; &lt;div class="gslb_rsbDivTitle"&gt;Communicating with JavaScript &lt;/div&gt; &lt;p class="gslb_rsbPParagraph"&gt;The only issue with the Silverlight unit test application is that it uses a default HTML test page to instantiate the Silverlight control. If your class library contains one or more JavaScript code files that it interacts with, the test will fail, because the JavaScript file cannot be found. Thankfully, this is quite easy to change: &lt;/p&gt; &lt;ul class="gslb_rsbList"&gt; &lt;li&gt;Start by creating the Silverlight class library that you want to work on.  &lt;/li&gt;&lt;li&gt;In the same solution, in VS2008, create a Silverlight unit test application. &lt;br /&gt;(note: Typically I name this test application [MyClassLibrary].Test where [MyClassLibrary] is the name of the class library you want to test).  &lt;/li&gt;&lt;li&gt;In the test application, add a reference to the Silverlight class library that you want to test.  &lt;/li&gt;&lt;li&gt;Do not add any test at this time!  &lt;/li&gt;&lt;li&gt;Right-click on the Silverlight test application and select "Set as Start-Up Project".  &lt;/li&gt;&lt;li&gt;Run the application. Don't worry about the test result so far.  &lt;/li&gt;&lt;li&gt;In the web browser, select the menu "View source":  &lt;/li&gt;&lt;li&gt;Copy the whole HTML code.  &lt;/li&gt;&lt;li&gt;In Visual Studio, right-click on the Silverlight test application and choose "Add / New Item...".  &lt;/li&gt;&lt;li&gt;Select a HTML page, rename it "index.html".  &lt;/li&gt;&lt;li&gt;Select the whole HTML code in index.html and replace it with the HTML code you have in the clipboard.  &lt;/li&gt;&lt;li&gt;Modify the Silverlight control's "source" attribute to prepend the "ClientBin" folder. &lt;/li&gt;&lt;/ul&gt; &lt;p class="gslb_rsbPParagraph"&gt;This step is needed because of the placement of the generated TestPage.html. This page is generated inside the ClientBin folder, as well as the XAP file. Since our index.html is located outside of the ClientBin folder, we need to update the "source" attribute. This is a one-time only operation &lt;/p&gt; &lt;ul class="gslb_rsbList"&gt; &lt;li&gt;From the Silverlight class library, drag and drop the JavaScript code file that your class library will interact with. A copy gets added to the test application.  &lt;/li&gt;&lt;li&gt;In the file "index.html", add a reference to that JavaScript file in the HEAD section.  &lt;/li&gt;&lt;li&gt;Right click on "index.html" and select "Set as Start Page". &lt;/li&gt;&lt;/ul&gt; &lt;p class="gslb_rsbPParagraph"&gt;That's it! Now you can write a few tests involving classes from your class library. The JavaScript interaction is working, because the JavaScript file your class communicates with is found in the same folder as index.html. &lt;/p&gt; &lt;p class="gslb_rsbPParagraph"&gt;There are a few caveats though: &lt;/p&gt; &lt;ul class="gslb_rsbList"&gt; &lt;li&gt;If you modify the JavaScript code file, you must remember to &lt;span style="font-weight: bold"&gt;udpdate the copy&lt;/span&gt; located in the test application too!  &lt;/li&gt;&lt;li&gt;You cannot debug the JavaScript code, because the test application is a Silverlight application, and if you run the debugger, it will attach to the Silverlight code only, not to the JavaScript code. &lt;/li&gt;&lt;/ul&gt; &lt;p class="gslb_rsbPParagraph"&gt;To illustrate this, I published &lt;a href="http://www.galasoft.ch/mydotnet/articles/resources/article-2008050501/GalaSoft.SL.MyClassLibrary.zip" target="_blank"&gt;a very basic Silverlight class library with JavaScript interaction and unit test application&lt;/a&gt;. You must install the Silverlight unit test framework first! &lt;/p&gt; &lt;div class="gslb_rsbDivFrame"&gt; &lt;p class="gslb_rsbPParagraph"&gt;Important: After you download the test code, make sure that you set "GalaSoft.SL.MyClassLibrary.Test" as startup project, and "index.html" as start page!! &lt;/p&gt;&lt;/div&gt; &lt;div class="gslb_rsbDivImage"&gt;&lt;img title="Successful unit test" alt="Successful unit test" src="http://www.galasoft.ch/blogs-all/2008040501.png" /&gt; &lt;/div&gt; &lt;div class="gslb_rsbDivImage"&gt;&lt;img title="File structure" alt="File structure" src="http://www.galasoft.ch/blogs-all/2008040502.png" /&gt; &lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121062"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121062" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/121062.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/04/05/silverlight-unit-testing-and-javascript.aspx</guid>
            <pubDate>Sat, 05 Apr 2008 15:49:31 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/121062.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/04/05/silverlight-unit-testing-and-javascript.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/121062.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/121062.aspx</trackback:ping>
        </item>
        <item>
            <title>Silverlight Bug: Transforms and OpacityMask</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/04/04/silverlight-bug-transforms-and-opacitymask.aspx</link>
            <description>&lt;div class="gslb_rsbDivTitle"&gt;
Introduction
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
In WPF, one of the best know effects is the "reflection" effect, where a scene reflects itself dynamically. It's a very cool feature, because it's really easy to realize, and it allows to reflect images, but also videos or other User Interface scenes. The key to this is to use a VisualBrush. Silverlight is not exactly as powerful as WPF, and doesn't have VisualBrush, but it has ImageBrush and VideoBrush, both of them allowing cool media reflection effects (these brushes can also be used for other things!).
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The key to making a reflection is placing a picture (or a video), and underneath it, an element (typically a Border). Then, you set the background of this element (Border.Background) to an ImageBrush (or a VideoBrush) pointing to the source that you want to reflect. To make the reflection look more lifelike, however, you want to skew it (because the surface you reflect is forming an angle with the reflecting element); also, you typically use an OpacityMask and make it look as if the reflection was progressively disappearing on a non-perfect surface. Life is not perfect, people, so a perfect reflection doesn't look lifelike.
&lt;/p&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
The issue
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
However, when creating such an effect, I noticed an issue &lt;span style="font-weight:bold;"&gt;causing skewed elements with an OpacityMask to disappear completely&lt;/span&gt;. The following code shows the problem:
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="200"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="100"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="Red"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border.OpacityMask&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;LinearGradientBrush&lt;/span&gt; &lt;span class="attr"&gt;EndPoint&lt;/span&gt;&lt;span class="kwrd"&gt;="0,1"&lt;/span&gt; &lt;span class="attr"&gt;StartPoint&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;GradientStop&lt;/span&gt; &lt;span class="attr"&gt;Color&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFFFFFFF"&lt;/span&gt; &lt;span class="attr"&gt;Offset&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;GradientStop&lt;/span&gt; &lt;span class="attr"&gt;Color&lt;/span&gt;&lt;span class="kwrd"&gt;="#00FFFFFF"&lt;/span&gt; &lt;span class="attr"&gt;Offset&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;LinearGradientBrush&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border.OpacityMask&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border.RenderTransform&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SkewTransform&lt;/span&gt; &lt;span class="attr"&gt;AngleX&lt;/span&gt;&lt;span class="kwrd"&gt;="30"&lt;/span&gt; &lt;span class="attr"&gt;AngleY&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border.RenderTransform&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008040401.png" alt="Skewed Border, OpacityMask, Silverlight" title="Skewed Border, OpacityMask, Silverlight" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt;
Skewed Border, OpacityMask, Silverlight
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivImage"&gt;
&lt;img src="http://www.galasoft.ch/blogs-all/2008040402.png" alt="Skewed Border, OpacityMask, WPF" title="Skewed Border, OpacityMask, WPF" /&gt;
&lt;div class="gslb_rsbDivLegend"&gt;
Skewed Border, OpacityMask, WPF
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Notes
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Here are a couple of notes about this:
&lt;/p&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
I simplified the code as much as possible to display the issue. Obviously this is not a reflection anymore, but I stumbled upon the issue when creating a reflection.
&lt;/li&gt;
&lt;li&gt;
The issue is visible in Blend and also if you run the application.
&lt;/li&gt;
&lt;li&gt;
This issue is not limited to Borders. It also occurs if you replace the Border with a Grid, for example.
&lt;/li&gt;
&lt;li&gt;
The issue also occurs with other Transforms. Replacing the SkewTransform with a RotateTransform will reproduce the issue.
&lt;/li&gt;
&lt;li&gt;
If you don't transform the element, the issue does not occur.
&lt;/li&gt;
&lt;li&gt;
If you remove the OpacityMask, the problem does not occur.
&lt;/li&gt;
&lt;li&gt;
If you give a Width and a Height to the element, the problem does not occur.
&lt;/li&gt;
&lt;li&gt;
The same code in WPF runs correctly.
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121036"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121036" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/121036.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/04/04/silverlight-bug-transforms-and-opacitymask.aspx</guid>
            <pubDate>Fri, 04 Apr 2008 14:00:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/121036.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/04/04/silverlight-bug-transforms-and-opacitymask.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/121036.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/121036.aspx</trackback:ping>
        </item>
        <item>
            <title>Silverlight 2 beta 1: ScrollViewer with auto-layout crashes both IE and FF</title>
            <link>http://geekswithblogs.net/lbugnion/archive/2008/03/31/silverlight-2-beta-1-scrollviewer-with-auto-layout-crashes-both-ie.aspx</link>
            <description>&lt;div class="gslb_rsbDivFrame"&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
&lt;span style="font-weight:bold;"&gt;Update 2&lt;/span&gt;: The Silverlight team at Microsoft was able to reproduce the bug, and it has been entered in the bug database. Thanks all for your precious help!!
&lt;/p&gt;
&lt;/div&gt;
&lt;div class="gslb_rsbDivFrame"&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
&lt;span style="font-weight:bold;"&gt;Update&lt;/span&gt;: Apparently this bug is not consistently reproducible. If you get the bug, please enter a comment with your &lt;span style="font-weight:bold;"&gt;system information&lt;/span&gt;. I was able to reproduce on a number of machines and OS, but on some other PCs it works just fine.
&lt;/p&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Here is an interesting one:
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="GalaSoft.SL.ScrollViewerNoCrash.Page"&lt;/span&gt;
             &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/client/2007"&lt;/span&gt;
             &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;
             &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt;
        &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="Green"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;
                  &lt;span class="attr"&gt;HorizontalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt;
                  &lt;span class="attr"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Disabled"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;
                  &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="150"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="10,5,10,5"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFA9A899"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="2,2,2,2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Image&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="pic1.png"&lt;/span&gt;
                 &lt;span class="attr"&gt;Stretch&lt;/span&gt;&lt;span class="kwrd"&gt;="Fill"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="10,5,10,5"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFA9A899"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="2,2,2,2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Image&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="pic2.jpg"&lt;/span&gt;
                 &lt;span class="attr"&gt;Stretch&lt;/span&gt;&lt;span class="kwrd"&gt;="Fill"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
The code above crashes both Internet Explorer and Firefox (on Windows) when you resize the browser window to let the horizontal scrollbar appear in the scrollviewer. I didn't test other platforms.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
On the other hand, the following code works:
&lt;/p&gt;
&lt;div class="gslb_rsbDivCodeSection"&gt;
&lt;div class="gslb_rsbDivCode" style="white-space: pre; font-family: Monospace;"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="GalaSoft.SL.ScrollViewerCrash.Page"&lt;/span&gt;
             &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/client/2007"&lt;/span&gt;
             &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;
             &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt;
        &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="Red"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="*"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowDefinition&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="150"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;
                  &lt;span class="attr"&gt;HorizontalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt;
                  &lt;span class="attr"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Disabled"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="10,5,10,5"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFA9A899"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="2,2,2,2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Image&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="pic1.png"&lt;/span&gt;
                 &lt;span class="attr"&gt;Stretch&lt;/span&gt;&lt;span class="kwrd"&gt;="Fill"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="10,5,10,5"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFA9A899"&lt;/span&gt;
                &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="2,2,2,2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Image&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="pic2.jpg"&lt;/span&gt;
                 &lt;span class="attr"&gt;Stretch&lt;/span&gt;&lt;span class="kwrd"&gt;="Fill"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Did you spot the difference? The first Grid (the one that crashes) has the second row's height set to 150, while the ScrollViewer and its children are all set to Auto. In the second one (the one that works), the Grid is set to Auto, while the StackPanel inside the ScrollViewer has its Height set to 150. The workaround is good enough for now, but I hope it'll get corrected because I like to layout my grids and then let the auto layout take care of the rest.
&lt;/p&gt;
&lt;p class="gslb_rsbPParagraph"&gt;
Note that both versions work fine in WPF.
&lt;/p&gt;
&lt;div class="gslb_rsbDivTitle"&gt;
Resources
&lt;/div&gt;
&lt;ul class="gslb_rsbList"&gt;
&lt;li&gt;
&lt;a href="http://www.galasoft.ch/mydotnet/articles/GalaSoft.SL.ScrollViewerCrash/index.html" target="_blank"&gt;Test&lt;/a&gt; the crash and non-crash case.
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.galasoft.ch/mydotnet/articles/GalaSoft.SL.ScrollViewerCrash/GalaSoft.SL.ScrollViewerCrash.zip" target="_blank"&gt;Download&lt;/a&gt; the source code.
&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120899"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120899" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/lbugnion/aggbug/120899.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Laurent Bugnion</dc:creator>
            <guid>http://geekswithblogs.net/lbugnion/archive/2008/03/31/silverlight-2-beta-1-scrollviewer-with-auto-layout-crashes-both-ie.aspx</guid>
            <pubDate>Mon, 31 Mar 2008 20:58:46 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/lbugnion/comments/120899.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/lbugnion/archive/2008/03/31/silverlight-2-beta-1-scrollviewer-with-auto-layout-crashes-both-ie.aspx#feedback</comments>
            <slash:comments>11</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/lbugnion/comments/commentRss/120899.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/lbugnion/services/trackbacks/120899.aspx</trackback:ping>
        </item>
    </channel>
</rss>