<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>r2 musings - rants, raves, and research (mostly on .NET topics) from rik robinson - Silverlight</title>
    <link>http://www.r2musings.com/</link>
    <description>rants, raves, and research (mostly on .NET topics) from rik robinson</description>
    <language>en-us</language>
    <copyright>Rik Robinson</copyright>
    <lastBuildDate>Fri, 06 Feb 2009 02:15:10 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>r2@r2musings.com</managingEditor>
    <webMaster>r2@r2musings.com</webMaster>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=fde23620-55e9-427b-b2fd-f95ab209fcee</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,fde23620-55e9-427b-b2fd-f95ab209fcee.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,fde23620-55e9-427b-b2fd-f95ab209fcee.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fde23620-55e9-427b-b2fd-f95ab209fcee</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you've used the the Silverlight 2 DataGrid, you've no doubt seen this:
</p>
        <p>
          <a href="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid01.jpg">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="195" alt="silverlightDatagrid01" src="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid01_thumb.jpg" width="330" border="0" />
          </a>
        </p>
        <p>
I really hate when this happens!  I've seen several forum discussions where folks
were looking to get rid of this nastiness, so I know I'm not the only one losing sleep
over it.  I haven't come across a solution in anything I've seen and so now that
I have one, I thought I'd share it.  
</p>
        <p>
I ran into this a few weeks back and tried most of the obvious things with defining
the DataGridColumns myself rather than auto-generating them.  In these defined
DataGridColumns, I tried setting the Width of the last column to "*" just like you
would a standard Grid.ColumnDefinition if you wanted to have it take up the remainder
of the space.  This did nothing more than invite my buddy, AG_E_PARSER_BAD_PROPERTY,
to show up...again.  It appears that star-sizing isn't yet implemented for DataGridColumn
derivatives.  
</p>
        <p>
This morning I was finally able to grab a few minutes to dive into DataGrid and find
out what I could do about this.  I decided to create an ExtendedDataGrid and
add a LastColumnFill DependencyProperty similar to way the DockPanel has a LastChildFill.
Most of the work is happening in this method which is called if the LastColumnFill
is true:
</p>
        <p>
private void AdjustLastColumnWidth(Size finalSize) 
<br />
{ 
<br />
    // get the Vertical ScrollBar 
<br />
    ScrollBar scrollBar = this.GetTemplateChild("VerticalScrollbar")
as ScrollBar; 
</p>
        <p>
    // compute the width to allow for the scrollbar based on it's visibility. 
<br />
    double scrollBarWidthAllowance = (scrollBar != null &amp;&amp;
scrollBar.Visibility == Visibility.Visible) ? scrollBar.ActualWidth + 2 : 2; 
</p>
        <p>
    // compute the width of all the columns excluding the last one 
<br />
    var widthOfAllButLastColumn = this.Columns 
<br />
                  
.TakeWhile(c =&gt; c != Columns.Last() &amp;&amp; 
<br />
                                           
c.Visibility == Visibility.Visible) 
<br />
                  
.Sum(c =&gt; c.ActualWidth); 
</p>
        <p>
     // set the last column width     
<br />
     this.Columns.Last().Width = new DataGridLength(finalSize.Width
- widthOfAllButLastColumn - scrollBarWidthAllowance); 
<br />
}
</p>
        <p>
This is the result:
</p>
        <p>
          <a href="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid02.jpg">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="199" alt="silverlightDatagrid02" src="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid02_thumb.jpg" width="331" border="0" />
          </a>
        </p>
        <p>
Much better!  The <a href="http://silverlight.r2musings.com/LastColumnFillDataGrid/" target="_blank">live
demo</a> shows it with and without a vertical scrollbar.  Note that it also handles
auto-generated DataGridColumns if that's your thang.
</p>
        <p>
Here's the <a href="http://silverlight.r2musings.com/LastColumnFillDataGrid/" target="_blank">live
demo</a>.
</p>
        <p>
Here's the <a href="http://www.r2musings.com/downloads/LastColumnFillDataGrid.zip" target="_blank">code</a>.
</p>
        <img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=fde23620-55e9-427b-b2fd-f95ab209fcee" />
      </body>
      <title>Silverlight UI Rant #1 - DataGrid Last Column Fill</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,fde23620-55e9-427b-b2fd-f95ab209fcee.aspx</guid>
      <link>http://www.r2musings.com/2009/02/06/SilverlightUIRant1DataGridLastColumnFill.aspx</link>
      <pubDate>Fri, 06 Feb 2009 02:15:10 GMT</pubDate>
      <description>&lt;p&gt;
If you've used the the Silverlight 2 DataGrid, you've no doubt seen this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid01.jpg"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=195 alt=silverlightDatagrid01 src="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid01_thumb.jpg" width=330 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I really hate when this happens!&amp;nbsp; I've seen several forum discussions where folks
were looking to get rid of this nastiness, so I know I'm not the only one losing sleep
over it.&amp;nbsp; I haven't come across a solution in anything I've seen and so now that
I have one, I thought I'd share it.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
I ran into this a few weeks back and tried most of the obvious things with defining
the DataGridColumns myself rather than auto-generating them.&amp;nbsp; In these defined
DataGridColumns, I tried setting the Width of the last column to "*" just like you
would a standard Grid.ColumnDefinition if you wanted to have it take up the remainder
of the space.&amp;nbsp; This did nothing more than invite my buddy, AG_E_PARSER_BAD_PROPERTY,
to show up...again.&amp;nbsp; It appears that star-sizing isn't yet implemented for DataGridColumn
derivatives.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
This morning I was finally able to grab a few minutes to dive into DataGrid and find
out what I could do about this.&amp;nbsp; I decided to create an ExtendedDataGrid and
add a LastColumnFill DependencyProperty similar to way the DockPanel has a LastChildFill.
Most of the work is happening in this method which is called if the LastColumnFill
is true:
&lt;/p&gt;
&lt;p&gt;
private void AdjustLastColumnWidth(Size finalSize) 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // get the Vertical ScrollBar 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ScrollBar scrollBar = this.GetTemplateChild("VerticalScrollbar")
as ScrollBar; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // compute the width to allow for the scrollbar based on it's visibility. 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; double scrollBarWidthAllowance = (scrollBar != null &amp;amp;&amp;amp;
scrollBar.Visibility == Visibility.Visible) ? scrollBar.ActualWidth + 2 : 2; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // compute the width of all the columns excluding the last one 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var widthOfAllButLastColumn = this.Columns 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.TakeWhile(c =&amp;gt; c != Columns.Last() &amp;amp;&amp;amp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
c.Visibility == Visibility.Visible) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.Sum(c =&amp;gt; c.ActualWidth); 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set the last column width&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Columns.Last().Width = new DataGridLength(finalSize.Width
- widthOfAllButLastColumn - scrollBarWidthAllowance); 
&lt;br&gt;
}
&lt;/p&gt;
&lt;p&gt;
This is the result:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid02.jpg"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=199 alt=silverlightDatagrid02 src="http://www.r2musings.com/images/blogged/AnotherAnnoyingUIRant1_113D2/silverlightDatagrid02_thumb.jpg" width=331 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Much better!&amp;nbsp; The &lt;a href="http://silverlight.r2musings.com/LastColumnFillDataGrid/" target=_blank&gt;live
demo&lt;/a&gt; shows it with and without a vertical scrollbar.&amp;nbsp; Note that it also handles
auto-generated DataGridColumns if that's your thang.
&lt;/p&gt;
&lt;p&gt;
Here's the &lt;a href="http://silverlight.r2musings.com/LastColumnFillDataGrid/" target=_blank&gt;live
demo&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Here's the &lt;a href="http://www.r2musings.com/downloads/LastColumnFillDataGrid.zip" target=_blank&gt;code&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=fde23620-55e9-427b-b2fd-f95ab209fcee" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,fde23620-55e9-427b-b2fd-f95ab209fcee.aspx</comments>
      <category>Silverlight</category>
      <category>Silverlight 2</category>
      <category>UI and Usability</category>
      <category>UI Rant</category>
    </item>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=a36342be-7563-4f95-b9c7-2944df682fad</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,a36342be-7563-4f95-b9c7-2944df682fad.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,a36342be-7563-4f95-b9c7-2944df682fad.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a36342be-7563-4f95-b9c7-2944df682fad</wfw:commentRss>
      <title>HtmlPage.PopupWindow vs. HtmlWindow.Navigate</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,a36342be-7563-4f95-b9c7-2944df682fad.aspx</guid>
      <link>http://www.r2musings.com/2009/02/04/HtmlPagePopupWindowVsHtmlWindowNavigate.aspx</link>
      <pubDate>Wed, 04 Feb 2009 04:15:15 GMT</pubDate>
      <description>&lt;p&gt;
I was recently looking at various ways of launching an external window from inside
a &lt;a href="silverlight.net" target=_blank&gt;Silverlight 2&lt;/a&gt; application.&amp;nbsp; Dusting
off your javascript brain cell, you'll recall that to open a popup dialog in "the
old days", we'd use &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open()&lt;/a&gt;.&amp;nbsp;
I knew about the &lt;a href="http://msdn.microsoft.com/en-us/library/cc645076(VS.95).aspx" target=_blank&gt;HtmlBridge&lt;/a&gt; available
in &lt;a href="http://silverlight.net" target=_blank&gt;Silverlight 2&lt;/a&gt; and I had used
it for several other nifty interactions between my managed code and the DOM.&amp;nbsp;
So, I went looking for an equivalent to &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open()&lt;/a&gt; and
came across the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpage.popupwindow(VS.95).aspx" target=_blank&gt;HtmlPage.PopupWindow&lt;/a&gt;()
method.&amp;nbsp; If you'll recall the javascript &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open()&lt;/a&gt; method
is defined as such:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
window.open( [&lt;em&gt;sURL&lt;/em&gt;] [, &lt;em&gt;sName&lt;/em&gt;] [, &lt;em&gt;sFeatures&lt;/em&gt;]);
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The HtmlPage.PopupWindow() is defined as: 
&lt;/p&gt;
&lt;dl&gt;
&lt;blockquote&gt; 
&lt;p&gt;
HtmlPage.PopupWindow(string navigateToUri, string target, HtmlPopupWindowOptions options); 
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/dl&gt;
&lt;p&gt;
Perfect!&amp;nbsp; ...or so I thought.&amp;nbsp; I fully expected that if I called &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpage.popupwindow(VS.95).aspx" target=_blank&gt;PopupWindow&lt;/a&gt;()
like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
HtmlPopupWindowOptions options = new HtmlPopupWindowOptions() 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Directories = false, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Location = false, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Menubar = false, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Status = false, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Toolbar = false, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }; 
&lt;br&gt;
HtmlPage.PopupWindow(new Uri("&lt;a href="http://www.wintellect.com" )?&gt;http://www.wintellect.com&lt;/a&gt;,
"_blank", options);
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
..that I'd get a new browser window with the default width/height on the monitor that
the launching browser is on. 
&lt;/p&gt;
&lt;p&gt;
After all, if I called &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open()&lt;/a&gt; with
equivalent arguments as follows that's what would happen:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
string features = String.Format("directories=no,location=no,menubar=no,status=no,toolbar=no"); 
&lt;br&gt;
HtmlPage.Window.Navigate(new Uri("&lt;a href="http://www.r2musings.com" )?&gt;http://www.r2musings.com&lt;/a&gt;,
"_blank", features);&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Instead, I get a small window that launches on Monitor 1.&amp;nbsp; I do my main work
on my Monitor 2 and I kept waiting for my popup window only to realize that it was
on the other monitor.&amp;nbsp; I really hate applications that do this! 
&lt;/p&gt;
&lt;p&gt;
Looking into Reflector, the issue seems to be that if options is passed as null in
the last parameter of &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpage.popupwindow(VS.95).aspx" target=_blank&gt;PopupWindow&lt;/a&gt;(),
the call is simply forwarded to &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open().&lt;/a&gt;&amp;nbsp;
But, if you pass an instance of &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpopupwindowoptions(VS.95).aspx" target=_blank&gt;HtmlPopupWindowOptions&lt;/a&gt; (even
with no properties set) to &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpage.popupwindow(VS.95).aspx" target=_blank&gt;PopupWindow&lt;/a&gt;(),
the ToFeaturesString() that gets called to convert this strongly-typed version of
the features to the string that is needed for &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open()&lt;/a&gt; is
also changing the height/width/top/left of the popup window.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Looking over the documentation...yes, I'm male and sometimes do that *after* nothing
else works. ....anyway, there it is in the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpage.popupwindow(VS.95).aspx" target=_blank&gt;remarks
of HtmlPage.PopupWindow()&lt;/a&gt;.&amp;nbsp; All the ugly details and the admission that my
popup would be altered.&amp;nbsp; Documented or not, it's not acceptable to my client
and I'm not putting my name on anything that launches a browser on the wrong monitor!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
That's when I decided to have another look at &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlwindow.navigate(VS.95).aspx" target=_blank&gt;HtmlWindow.Navigate()&lt;/a&gt; which
seems to more accurately mirror the behavior that I would expect out of something
that purports to wrap &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open().&lt;/a&gt;&amp;nbsp;
Going this route, we lose the strong typing of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpopupwindowoptions(VS.95).aspx" target=_blank&gt;HtmlPopupWindowOptions&lt;/a&gt;,
but in exchange we get exactly what we are expecting when calling &lt;a href="http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx" target=_blank&gt;window.open().&lt;/a&gt;&amp;nbsp;
The call using &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlwindow.navigate(VS.95).aspx" target=_blank&gt;HtmlWindow.Navigate()&lt;/a&gt; looks
like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; string features = "directories=no,location=no,menubar=no,status=no,toolbar=no"; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; HtmlPage.Window.Navigate(new Uri("&lt;a href="http://www.r2musings.com" )?&gt;http://www.r2musings.com&lt;/a&gt;,
"_blank", features);&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This will fire a new window on the correct monitor and will honor the default settings
for width/height/top/left.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Here's the &lt;a href="http://www.r2musings.com/downloads/launchexternalwindow.zip" target=_blank&gt;code&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Here's a &lt;a href="http://silverlight.r2musings.com/launchexternalwindow" target=_blank&gt;live
sample&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=a36342be-7563-4f95-b9c7-2944df682fad" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,a36342be-7563-4f95-b9c7-2944df682fad.aspx</comments>
      <category>Silverlight</category>
      <category>Silverlight 2</category>
    </item>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=1fee07d0-9ab9-4010-ac35-36551e9cf0e3</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,1fee07d0-9ab9-4010-ac35-36551e9cf0e3.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,1fee07d0-9ab9-4010-ac35-36551e9cf0e3.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1fee07d0-9ab9-4010-ac35-36551e9cf0e3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Earlier this month, I <a href="http://www.wintellect.com/CS/blogs/rrobinson/archive/2009/01/12/silverlight-2-scroller.aspx" target="_blank">blogged</a> about
a <a href="http://silverlight.net" target="_blank">Silverlight</a> 2 Scroller control
that I had labored over for the better part of a weekend.  The entire time I
was working on this Scroller, I had this small, dirty feeling that what I had created
was somehow <strong>way</strong> more than what I needed to accomplish my end goal. 
But, time was short, it got the job done and I figured that I could always revisit
it at some point.   
</p>
        <p>
Fast forward a few days as I was reading <a href="http://wildermuth.com/" target="_blank">Shawn
Wildermuth's blog</a> and I come across <a href="http://wildermuth.com/2009/01/18/Fun_with_ItemsControl" target="_blank">his
post</a> on the <a href="http://silverlight.net" target="_blank">Silverlight</a> ItemsControl
and realized what that dirty feeling was all about.  I was exactly the guy he
was talking about that was trying to bastardize the <a href="http://silverlight.net" target="_blank">Silverlight</a> ListBox
into something else...namely the ItemsControl.  So, I revisited the Scroller
and was able to remove about 50% or more of the code and still achieve my goal. 
No custom ListBox, etc.  
</p>
        <p>
I think it's part of most any process, really.  As you work on making something
better you tend to keep adding and adding more code until you reach a saturation point
where you need to step back and just start removing things.  
</p>
        <p>
It made me think of so many guitarists in the 80's that just kept adding and adding
notes and playing faster and faster until the music just became guitar masturbation
instead of anything musical.  (These guys wouldn't have known a whole note if
it hit them in the face). On the other hand, you take someone like <a href="http://en.wikipedia.org/wiki/David_Gilmour" target="_blank">David
Gilmour</a> that can play one note and absolutely convey way more than the shred monsters
could ever muster.  It's all part of the learning process.  There's a curve
graphed somewhere (I'm sure) that shows the guitarist's ascension to knowing when
NOT to play.
</p>
        <p>
So, who is <a href="http://en.wikipedia.org/wiki/Yngwie_Malmsteen" target="_blank">Yngwie
Malmsteen</a> and what does he have to do with this post?  You can find out more
than you ever wanted to know about Yngwie <a href="http://en.wikipedia.org/wiki/Yngwie_Malmsteen" target="_blank">here</a>. 
Yngwie was the <a href="http://www.5min.com/Video/Yngwie-Malmsteen---insane-speed-playing-10238" target="_blank">poster
boy</a> for never quite knowing when to stop adding notes and he flashed before my
eyes when I looked back and my original Scroller code.  Anyway, thanks <a href="http://wildermuth.com/" target="_blank">Shawn</a> for
saving me from that fate.  
</p>
        <p>
The updated code is <a href="http://www.r2musings.com/downloads/SilverlightScrollerWithItemsControl.zip" target="_blank">here</a>. 
Here is the <a href="http://silverlight.r2musings.com/SilverlightScroller/default.htm" target="_blank">live
demo.</a></p>
        <p>
I'll leave the original code <a href="http://www.r2musings.com/downloads/SilverlightScroller.zip" target="_blank">here</a> in
case you want to get it and make fun of me.  
</p>
        <img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=1fee07d0-9ab9-4010-ac35-36551e9cf0e3" />
      </body>
      <title>Yngwie Malmsteen syndrome (Silverlight 2 Scroller revisited)</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,1fee07d0-9ab9-4010-ac35-36551e9cf0e3.aspx</guid>
      <link>http://www.r2musings.com/2009/01/22/YngwieMalmsteenSyndromeSilverlight2ScrollerRevisited.aspx</link>
      <pubDate>Thu, 22 Jan 2009 18:39:29 GMT</pubDate>
      <description>&lt;p&gt;
Earlier this month, I &lt;a href="http://www.wintellect.com/CS/blogs/rrobinson/archive/2009/01/12/silverlight-2-scroller.aspx" target=_blank&gt;blogged&lt;/a&gt; about
a &lt;a href="http://silverlight.net" target=_blank&gt;Silverlight&lt;/a&gt; 2 Scroller control
that I had labored over for the better part of a weekend.&amp;nbsp; The entire time I
was working on this Scroller, I had this small, dirty feeling that what I had created
was somehow &lt;strong&gt;way&lt;/strong&gt; more than what I needed to accomplish my end goal.&amp;nbsp;
But, time was short, it got the job done and I figured that I could always revisit
it at some point.&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Fast forward a few days as I was reading &lt;a href="http://wildermuth.com/" target=_blank&gt;Shawn
Wildermuth's blog&lt;/a&gt; and I come across &lt;a href="http://wildermuth.com/2009/01/18/Fun_with_ItemsControl" target=_blank&gt;his
post&lt;/a&gt; on the &lt;a href="http://silverlight.net" target=_blank&gt;Silverlight&lt;/a&gt; ItemsControl
and realized what that dirty feeling was all about.&amp;nbsp; I was exactly the guy he
was talking about that was trying to bastardize the &lt;a href="http://silverlight.net" target=_blank&gt;Silverlight&lt;/a&gt; ListBox
into something else...namely the ItemsControl.&amp;nbsp; So, I revisited the Scroller
and was able to remove about 50% or more of the code and still achieve my goal.&amp;nbsp;
No custom ListBox, etc.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
I think it's part of most any process, really.&amp;nbsp; As you work on making something
better you tend to keep adding and adding more code until you reach a saturation point
where you need to step back and just start removing things.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
It made me think of so many guitarists in the 80's that just kept adding and adding
notes and playing faster and faster until the music just became guitar masturbation
instead of anything musical.&amp;nbsp; (These guys wouldn't have known a whole note if
it hit them in the face). On the other hand, you take someone like &lt;a href="http://en.wikipedia.org/wiki/David_Gilmour" target=_blank&gt;David
Gilmour&lt;/a&gt; that can play one note and absolutely convey way more than the shred monsters
could ever muster.&amp;nbsp; It's all part of the learning process.&amp;nbsp; There's a curve
graphed somewhere (I'm sure) that shows the guitarist's ascension to knowing when
NOT to play.
&lt;/p&gt;
&lt;p&gt;
So, who is &lt;a href="http://en.wikipedia.org/wiki/Yngwie_Malmsteen" target=_blank&gt;Yngwie
Malmsteen&lt;/a&gt; and what does he have to do with this post?&amp;nbsp; You can find out more
than you ever wanted to know about Yngwie &lt;a href="http://en.wikipedia.org/wiki/Yngwie_Malmsteen" target=_blank&gt;here&lt;/a&gt;.&amp;nbsp;
Yngwie was the &lt;a href="http://www.5min.com/Video/Yngwie-Malmsteen---insane-speed-playing-10238" target=_blank&gt;poster
boy&lt;/a&gt; for never quite knowing when to stop adding notes and he flashed before my
eyes when I looked back and my original Scroller code.&amp;nbsp; Anyway, thanks &lt;a href="http://wildermuth.com/" target=_blank&gt;Shawn&lt;/a&gt; for
saving me from that fate.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
The updated code is &lt;a href="http://www.r2musings.com/downloads/SilverlightScrollerWithItemsControl.zip" target=_blank&gt;here&lt;/a&gt;.&amp;nbsp;
Here is the &lt;a href="http://silverlight.r2musings.com/SilverlightScroller/default.htm" target=_blank&gt;live
demo.&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I'll leave the original code &lt;a href="http://www.r2musings.com/downloads/SilverlightScroller.zip" target=_blank&gt;here&lt;/a&gt; in
case you want to get it and make fun of me.&amp;nbsp; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=1fee07d0-9ab9-4010-ac35-36551e9cf0e3" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,1fee07d0-9ab9-4010-ac35-36551e9cf0e3.aspx</comments>
      <category>Silverlight</category>
      <category>Silverlight 2</category>
    </item>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=6e950805-d321-461e-9c56-18d617c4f2e3</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,6e950805-d321-461e-9c56-18d617c4f2e3.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,6e950805-d321-461e-9c56-18d617c4f2e3.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6e950805-d321-461e-9c56-18d617c4f2e3</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just a quick note that will hopefully save someone the pain that I just went through
chasing yet another exception in Silverlight with nothing to go on from Visual Studio. 
(I really hope that there is some better feedback coming on Silverlight applications
when you hit a runtime error in the future).  Anyway, I was digging in my App.xaml
today to do a bit of much-needed clean up and then started getting System.ExecutionEngineException
being thrown at runtime.  I was just about to the point of pulling out WinDbg
(see <a href="http://devmeat.com/show/89422" target="_blank">this post</a> on that)
and I decided that maybe Blend could help me out.  After all, it really does
owe me one for all the times it wouldn't load my xaml without telling me why.
</p>
        <p>
So, I opened the project in Blend and sure enough, it gave me the old "Invalid XAML"
message that I was expecting when I attempted to open my app.xaml.  However,
it also gave me a bunch of errors about not finding properties from one of my styles. 
I took a wild shot and clicked the View XAML Code link that Blend offered.  It
placed me on a style that I had added earlier and I immediately noticed that I had
left off the TargetType attribute.  Adding this cured the problem.  
</p>
        <p>
And for those that just scan for the code...
</p>
        <p>
          <strong>Bad:</strong>
        </p>
        <p>
        &lt;Style x:Key="MyButtonStyle"&gt; 
<br />
            &lt;Setter Property="FontSize"
Value="10" /&gt; 
<br />
        &lt;/Style&gt;
</p>
        <p>
          <strong>Good:</strong>
        </p>
        <p>
        &lt;Style x:Key="MyButtonStyle" TargetType="Button"&gt; 
<br />
            &lt;Setter Property="FontSize"
Value="10" /&gt; 
<br />
        &lt;/Style&gt;
</p>
        <img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=6e950805-d321-461e-9c56-18d617c4f2e3" />
      </body>
      <title>Silverlight System.ExecutionEngineException</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,6e950805-d321-461e-9c56-18d617c4f2e3.aspx</guid>
      <link>http://www.r2musings.com/2009/01/15/SilverlightSystemExecutionEngineException.aspx</link>
      <pubDate>Thu, 15 Jan 2009 20:46:11 GMT</pubDate>
      <description>&lt;p&gt;
Just a quick note that will hopefully save someone the pain that I just went through
chasing yet another exception in Silverlight with nothing to go on from Visual Studio.&amp;nbsp;
(I really hope that there is some better feedback coming on Silverlight applications
when you hit a runtime error in the future).&amp;nbsp; Anyway, I was digging in my App.xaml
today to do a bit of much-needed clean up and then started getting System.ExecutionEngineException
being thrown at runtime.&amp;nbsp; I was just about to the point of pulling out WinDbg
(see &lt;a href="http://devmeat.com/show/89422" target=_blank&gt;this post&lt;/a&gt; on that)
and I decided that maybe Blend could help me out.&amp;nbsp; After all, it really does
owe me one for all the times it wouldn't load my xaml without telling me why.
&lt;/p&gt;
&lt;p&gt;
So, I opened the project in Blend and sure enough, it gave me the old "Invalid XAML"
message that I was expecting when I attempted to open my app.xaml.&amp;nbsp; However,
it also gave me a bunch of errors about not finding properties from one of my styles.&amp;nbsp;
I took a wild shot and clicked the View XAML Code link that Blend offered.&amp;nbsp; It
placed me on a style that I had added earlier and I immediately noticed that I had
left off the TargetType attribute.&amp;nbsp; Adding this cured the problem.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
And for those that just scan for the code...
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Bad:&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Style x:Key="MyButtonStyle"&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setter Property="FontSize"
Value="10" /&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Style&amp;gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Good:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Style x:Key="MyButtonStyle" TargetType="Button"&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Setter Property="FontSize"
Value="10" /&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Style&amp;gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=6e950805-d321-461e-9c56-18d617c4f2e3" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,6e950805-d321-461e-9c56-18d617c4f2e3.aspx</comments>
      <category>Silverlight</category>
      <category>Silverlight 2</category>
    </item>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=583a3592-0dbb-4238-9115-ff7b8fc0c65c</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,583a3592-0dbb-4238-9115-ff7b8fc0c65c.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,583a3592-0dbb-4238-9115-ff7b8fc0c65c.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=583a3592-0dbb-4238-9115-ff7b8fc0c65c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Last week I had opportunity to really dive into some fun with a Silverlight 2 ListBox. 
It all started with a requirement for a simple Scroller control.  You know, the
simple left-to-right scrollers that you see in many applications?  I've seen
them in several places, yet when I searched around for a Silverlight version that
met my criteria I came up empty.  I have seen many great Image Carousel controls
around, but overall the majority of them were not quite "calm enough" for a typical
Line of Business application and I wasn't really intending on using images only. 
There were some really great "pieces" that I found as I attempted to assemble this
control and now that I have a functional version, I thought I'd share it with the
community.        
</p>
        <p>
The first challenge here was that I needed to have two horizontal rows of items in
the Scroller.  Thanks to a post over at <a href="http://msmvps.com/blogs/theproblemsolver/archive/2008/11/18/some-more-fun-with-a-silverlight-listbox.aspx" target="_blank">The
Problem Solver</a> and the WrapPanel from the <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight
Toolkit</a>, I was able to pull this off pretty easily.  So, I went to work on
a custom template for a ScrollBar.  My initial thought here was that I'd stretch
the ScrollBar to the Height of the ListBox, delete the Thumb, make the Background
Transparent, and delete the Large Increase/Decrease controls.  This worked great,
but the scrolling was what you would typically get when clicking the Small Increase/Decrease
portions of a ScrollBar (i.e. the little arrows).  What we really needed was
for each click to move to the next/previous column of items.  
</p>
        <p>
At this point, I decided to lose the custom template for the ScrollBar and just go
with a pair of RepeatButtons for the Previous/Next buttons so that I could have a
little more control over things.  As I didn't want to see the ScrollBar, I had
to hide it by setting the HorizontalScrollBarVisibility and the VerticalScrollBarVisibility
to Hidden in the ControlTemplate of the ListBox.  
</p>
        <p>
The ScrollViewer (that is part of our ListBox) is what we want to manipulate to give
this per-item scroll experience to the user.  There are a couple of important
properties of the ScrollViewer that we care about.  First, the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrollablewidth(VS.95).aspx" target="_blank">ScrollableWidth</a> which
represents the width of the area that can be scrolled.  You can envision this
as placing all of the columns end-to-end (including those that are scrolled out of
sight) and getting the total width.  Secondly, the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.horizontaloffset(VS.95).aspx" target="_blank">HorizontalOffset</a> which
is simply the indicator of the current scroll position (relative to the entire <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrollablewidth(VS.95).aspx" target="_blank">ScrollableWidth</a>). 
Using these two properties and the ItemWidth, we can compute how far to move the ScrollViewer
for each click of our Previous/Next buttons.  
</p>
        <p>
Since I needed direct access to the ScrollViewer in my ListBox and its not readily
available from the default ListBox, I decided to create a custom control with a ScrollHost
property.  I saw this little trick used in the ItemContainerGenerator class of
the <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> (which
has some really great utility code along with the awesome controls....well worth your
time to investigate that).  Also, since I was using a WrapPanel as my ItemsPanelTemplate
and I needed the ItemWidth for my calculations and since WrapPanel just happens to
have an ItemWidth property, I decided to expose that as a property as well. 
I overrode the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.preparecontainerforitemoverride.aspx" target="_blank">PrepareContainerForItemOverride</a>()
method in my custom ScrollerListBox in order to set these properties.  This worked
pretty well and with a little math and a call to ScrollViewer.ScrollToHorizontalOffset(),
I was able to create the scrolling behavior that I needed.  
</p>
        <p>
But....wouldn't it be cool if the scrolling was animated?  ...it is Silverlight
after all and every demo that I've ever seen at a conference with Silverlight has
animation.  This proved to be a little more difficult as you can't directly animate
HorizontalOffset.  While searching for a way to solve that, I came across a really
great solution on <a href="http://www.robertjantuit.nl/" target="_blank">Rob's Usability
Development blog</a> for creating an <a href="http://www.robertjantuit.nl/index.php/2008/09/13/storyboard-animation-for-the-scrollviewer-animationhelpercontrol/" target="_blank">AnimationHelperControl</a> to
give you something to animate.  His post also made use of his excellent <a href="http://www.robertjantuit.nl/index.php/2008/08/13/animateto-extension-methods-in-silverlight-2/" target="_blank">AnimateTo
extension methods</a> that he describes in another <a href="http://www.robertjantuit.nl/index.php/2008/08/13/animateto-extension-methods-in-silverlight-2/" target="_blank">post</a>.
</p>
        <p>
As I didn't want to hard code the amount of time it took to animate the scroll, I
added a ScrollTime Dependency Property to the ScrollerControl and was able to set
that declaratively in my Page.Xaml.   
</p>
        <p>
I think the final result gives a nice subtle use of animation that doesn't distract
the user from their data.  (As an aside...for a REALLY nice usage of animation
in a Silverlight application, check out the one that <a href="http://perseus.franklins.net/dnrtvplayer/player.aspx?ShowNum=0115" target="_blank">Billy
Hollis shows in this video</a> on <a href="http://www.dnrtv.com/" target="_blank">dnrTV</a>).
</p>
        <p>
My demo uses employees that I've generated in a TestData class and then binds the
various fields to the ItemTemplate of my ListBox using standard Silverlight DataBinding. 
I was a bit too lazy to create a separate image for each of my employees, so I used
the same image for each.  These images could just as easily be streamed from
the database, but that's a different post. 
</p>
        <p>
Here is the <a href="http://silverlight.r2musings.com/SilverlightScroller/default.htm" target="_blank">live
demo</a>.
</p>
        <p>
Here is the <a href="http://www.r2musings.com/downloads/SilverlightScroller.zip" target="_blank">project
source</a>.
</p>
        <p>
I have a few more ideas for the ScrollerControl such as the ability to drag between
the items (sort of like the iPhone).  Anyway, I'll post those as I implement
them.  
</p>
        <img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=583a3592-0dbb-4238-9115-ff7b8fc0c65c" />
      </body>
      <title>Silverlight 2 Scroller</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,583a3592-0dbb-4238-9115-ff7b8fc0c65c.aspx</guid>
      <link>http://www.r2musings.com/2009/01/11/Silverlight2Scroller.aspx</link>
      <pubDate>Sun, 11 Jan 2009 07:44:44 GMT</pubDate>
      <description>&lt;p&gt;
Last week I had opportunity to really dive into some fun with a Silverlight 2 ListBox.&amp;nbsp;
It all started with a requirement for a simple Scroller control.&amp;nbsp; You know, the
simple left-to-right scrollers that you see in many applications?&amp;nbsp; I've seen
them in several places, yet when I searched around for a Silverlight version that
met my criteria I came up empty.&amp;nbsp; I have seen many great Image Carousel controls
around, but overall the majority of them were not quite "calm enough" for a typical
Line of Business application and I wasn't really intending on using images only.&amp;nbsp;
There were some really great "pieces" that I found as I attempted to assemble this
control and now that I have a functional version, I thought I'd share it with the
community.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
The first challenge here was that I needed to have two horizontal rows of items in
the Scroller.&amp;nbsp; Thanks to a post over at &lt;a href="http://msmvps.com/blogs/theproblemsolver/archive/2008/11/18/some-more-fun-with-a-silverlight-listbox.aspx" target=_blank&gt;The
Problem Solver&lt;/a&gt; and the WrapPanel from the &lt;a href="http://www.codeplex.com/Silverlight" target=_blank&gt;Silverlight
Toolkit&lt;/a&gt;, I was able to pull this off pretty easily.&amp;nbsp; So, I went to work on
a custom template for a ScrollBar.&amp;nbsp; My initial thought here was that I'd stretch
the ScrollBar to the Height of the ListBox, delete the Thumb, make the Background
Transparent, and delete the Large Increase/Decrease controls.&amp;nbsp; This worked great,
but the scrolling was what you would typically get when clicking the Small Increase/Decrease
portions of a ScrollBar (i.e. the little arrows).&amp;nbsp; What we really needed was
for each click to move to the next/previous column of items.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
At this point, I decided to lose the custom template for the ScrollBar and just go
with a pair of RepeatButtons for the Previous/Next buttons so that I could have a
little more control over things.&amp;nbsp; As I didn't want to see the ScrollBar, I had
to hide it by setting the HorizontalScrollBarVisibility and the VerticalScrollBarVisibility
to Hidden in the ControlTemplate of the ListBox.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
The ScrollViewer (that is part of our ListBox) is what we want to manipulate to give
this per-item scroll experience to the user.&amp;nbsp; There are a couple of important
properties of the ScrollViewer that we care about.&amp;nbsp; First, the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrollablewidth(VS.95).aspx" target=_blank&gt;ScrollableWidth&lt;/a&gt; which
represents the width of the area that can be scrolled.&amp;nbsp; You can envision this
as placing all of the columns end-to-end (including those that are scrolled out of
sight) and getting the total width.&amp;nbsp; Secondly, the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.horizontaloffset(VS.95).aspx" target=_blank&gt;HorizontalOffset&lt;/a&gt; which
is simply the indicator of the current scroll position (relative to the entire &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.scrollablewidth(VS.95).aspx" target=_blank&gt;ScrollableWidth&lt;/a&gt;).&amp;nbsp;
Using these two properties and the ItemWidth, we can compute how far to move the ScrollViewer
for each click of our Previous/Next buttons.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Since I needed direct access to the ScrollViewer in my ListBox and its not readily
available from the default ListBox, I decided to create a custom control with a ScrollHost
property.&amp;nbsp; I saw this little trick used in the ItemContainerGenerator class of
the &lt;a href="http://www.codeplex.com/Silverlight" target=_blank&gt;Silverlight Toolkit&lt;/a&gt; (which
has some really great utility code along with the awesome controls....well worth your
time to investigate that).&amp;nbsp; Also, since I was using a WrapPanel as my ItemsPanelTemplate
and I needed the ItemWidth for my calculations and since WrapPanel just happens to
have an ItemWidth property, I decided to expose that as a property as well.&amp;nbsp;
I overrode the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.preparecontainerforitemoverride.aspx" target=_blank&gt;PrepareContainerForItemOverride&lt;/a&gt;()
method in my custom ScrollerListBox in order to set these properties.&amp;nbsp; This worked
pretty well and with a little math and a call to ScrollViewer.ScrollToHorizontalOffset(),
I was able to create the scrolling behavior that I needed.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
But....wouldn't it be cool if the scrolling was animated?&amp;nbsp; ...it is Silverlight
after all and every demo that I've ever seen at a conference with Silverlight has
animation.&amp;nbsp; This proved to be a little more difficult as you can't directly animate
HorizontalOffset.&amp;nbsp; While searching for a way to solve that, I came across a really
great solution on &lt;a href="http://www.robertjantuit.nl/" target=_blank&gt;Rob's Usability
Development blog&lt;/a&gt; for creating an &lt;a href="http://www.robertjantuit.nl/index.php/2008/09/13/storyboard-animation-for-the-scrollviewer-animationhelpercontrol/" target=_blank&gt;AnimationHelperControl&lt;/a&gt; to
give you something to animate.&amp;nbsp; His post also made use of his excellent &lt;a href="http://www.robertjantuit.nl/index.php/2008/08/13/animateto-extension-methods-in-silverlight-2/" target=_blank&gt;AnimateTo
extension methods&lt;/a&gt; that he describes in another &lt;a href="http://www.robertjantuit.nl/index.php/2008/08/13/animateto-extension-methods-in-silverlight-2/" target=_blank&gt;post&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
As I didn't want to hard code the amount of time it took to animate the scroll, I
added a ScrollTime Dependency Property to the ScrollerControl and was able to set
that declaratively in my Page.Xaml.&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
I think the final result gives a nice subtle use of animation that doesn't distract
the user from their data.&amp;nbsp; (As an aside...for a REALLY nice usage of animation
in a Silverlight application, check out the one that &lt;a href="http://perseus.franklins.net/dnrtvplayer/player.aspx?ShowNum=0115" target=_blank&gt;Billy
Hollis shows in this video&lt;/a&gt; on &lt;a href="http://www.dnrtv.com/" target=_blank&gt;dnrTV&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
My demo uses employees that I've generated in a TestData class and then binds the
various fields to the ItemTemplate of my ListBox using standard Silverlight DataBinding.&amp;nbsp;
I was a bit too lazy to create a separate image for each of my employees, so I used
the same image for each.&amp;nbsp; These images could just as easily be streamed from
the database, but that's a different post. 
&lt;/p&gt;
&lt;p&gt;
Here is the &lt;a href="http://silverlight.r2musings.com/SilverlightScroller/default.htm" target=_blank&gt;live
demo&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Here is the &lt;a href="http://www.r2musings.com/downloads/SilverlightScroller.zip" target=_blank&gt;project
source&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I have a few more ideas for the ScrollerControl such as the ability to drag between
the items (sort of like the iPhone).&amp;nbsp; Anyway, I'll post those as I implement
them.&amp;nbsp; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=583a3592-0dbb-4238-9115-ff7b8fc0c65c" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,583a3592-0dbb-4238-9115-ff7b8fc0c65c.aspx</comments>
      <category>Silverlight</category>
      <category>Silverlight 2</category>
    </item>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=4515ddc4-d167-4192-9ed9-0383ef75e1b9</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,4515ddc4-d167-4192-9ed9-0383ef75e1b9.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,4515ddc4-d167-4192-9ed9-0383ef75e1b9.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=4515ddc4-d167-4192-9ed9-0383ef75e1b9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently, I was attempting to create my own popup dialog. I had specific requirements
in mind for this dialog, including:  
</p>
        <ol>
          <li>
I wanted to animate the Width/Height from 0x0 to the ActualWidth/ActualHeight 
</li>
          <li>
I wanted to animate the Opacity from 0 to 1 
</li>
          <li>
I wanted to animate the Top/Left properties from the point of mouse click (an icon
in my case) to the center of the screen and back to the original point of mouse click
when the user closed the dialog 
</li>
        </ol>
        <p>
All of these are fairly easy to accomplish using a Storyboard with an x:Name specified. 
In the case of my requirement #3 above, I merely needed to set the From value of my
animation and call the Begin() method, like so (for purposes of illustration, I'll
confine this to the Canvas.Left property only...you can apply the same logic to the
Canvas.Top property and it's all in the accompanying project):
</p>
        <blockquote>
          <p>
&lt;Storyboard x:Name="MoveDialogStoryboard"&gt; 
<br />
  &lt;DoubleAnimation 
<br />
       x:Name="theDialogAnimation" 
<br />
       Storyboard.TargetName="theDialog"  
<br />
       Storyboard.TargetProperty="(Canvas.Left)" 
<br />
      To="0" Duration="0:0:0.5" /&gt; 
<br />
  &lt;/Storyboard&gt;
</p>
          <p>
theDialogAnimation.From = 800;   // this value would actually come from
getting the mouse position via GetPosition() 
<br />
(MoveDialogStoryboard as Storyboard).Begin(); 
</p>
        </blockquote>
        <p>
This all works as you would expect.  However, I really liked the idea of isolating
all of my dialog states into one place and the <a href="http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager(VS.95).aspx" target="_blank">Visual
State Manager</a> sounded like the perfect solution...that is, until I tried to set
the FROM value programmatically and got hit with a NullReferenceException every time
I tried to reference my named Animation.  
</p>
        <p>
I tried several things and ended up <a href="http://silverlight.net/forums/p/61296/153074.aspx#153074" target="_blank">posting
my issue</a> to the <a href="http://silverlight.net/" target="_blank">Silverlight</a><a href="http://silverlight.net/forums/" target="_blank">forum</a> where <a href="http://wildermuth.com/" target="_blank">Shawn
Wildermuth</a> was kind enough to offer a solution.  Shawn's solution was to
simply set the property to the value before calling GoToState() in my code. 
This made perfect sense and I ran off to give it a try.  It worked...once. 
My animation would fire once but then appear to be swallowed or ignored on subsequent
clicks.  After further investigation, this turned out to be an artifact of the
fact that I was never setting my VisualState back to the original state...something
you don't have to do when using a Storyboard outside of the Visual State Manager. 
So, that fixed that issue and Shawn's solution worked.  However, I didn't really
see any way using this solution to animate back to the original point of mouse click.    
</p>
        <p>
Either way, it didn't really satisfy my initial curiosity for WHY I couldn't programmatically
set the FROM value when my animation was inside a Visual State Manager, so I pressed
on.  Thanks to a couple of blog posts (<a href="http://pagebrooks.com/archive/2008/11/05/finding-a-storyboard-in-the-visualstatemanager.aspx" target="_blank">here</a> and <a href="http://math-geek-rock-chick.blogspot.com/2008/11/silverlight-dynamically-finding.html" target="_blank">here</a>)
and some pretty ugly LINQ, I was finally able to programmatically set the FROM value
and have it animate my dialog from the original point of mouse click with a Storyboard
inside of a VisualState like so:  
</p>
        <blockquote>
          <p>
public void ShowDialog(Point startingPosition) 
<br />
{ 
<br />
     Storyboard storyboard = Utils.FindStoryboard(LayoutRoot,
"DialogStates", "Open"); 
<br />
     (storyboard.Children[0] as DoubleAnimation).From = startingPosition.X; 
<br />
     (storyboard.Children[1] as DoubleAnimation).From = startingPosition.Y; 
<br />
     VisualStateManager.GoToState(this, "Open", true); 
<br />
}
</p>
          <p>
// This is the definition of the extension method FindStoryboard() shown above (which
is where the real work happens) 
<br />
public static Storyboard FindStoryboard(this FrameworkElement parent, string groupName,
string stateName) 
<br />
{ 
<br />
     VisualState visualState = VisualStateManager.GetVisualStateGroups(parent) 
<br />
         .Cast&lt;VisualStateGroup&gt;().Where(group
=&gt; group.Name == groupName) 
<br />
         .SingleOrDefault() 
<br />
         .States.Cast&lt;VisualState&gt;() 
<br />
         .Where(state =&gt; state.Name ==
stateName) 
<br />
         .SingleOrDefault(); 
<br /><br />
     if (visualState != null) 
<br />
         return visualState.Storyboard;     
<br /><br />
     return null;     
<br />
}
</p>
        </blockquote>
        <p>
All of that being said, I didn't end up going this route nor do I recommend it. 
It's way too brittle and just plain ugly in my opinion.  In the end, I chose
to create my Open and Closed Storyboard animations for my popup dialog as standard
Resource Storyboards where I don't have to reset the State before calling and I don't
have to jump through hoops to set the value and, most importantly, I can set a name
for the Animation and directly set the property value.  For the actual "modes"
of my dialog (assuming there are multiple views for the dialog), I used the VSM to
represent things like EntryView, EditView, etc.  I think this offers a much cleaner
solution. 
<br /><br />
I've put together a quick demo to illustrate both calling the Storyboard directly
and using a Storyboard in a VSM.  The live version is <a href="http://silverlight.r2musings.com/InitializingAnimations/" target="_blank">here</a> and
the project source is available <a href="http://www.r2musings.com/downloads/InitializingAnimations.zip" target="_blank">here</a>.  
</p>
        <img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=4515ddc4-d167-4192-9ed9-0383ef75e1b9" />
      </body>
      <title>Initializing the FROM value of a Silverlight 2 Animation</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,4515ddc4-d167-4192-9ed9-0383ef75e1b9.aspx</guid>
      <link>http://www.r2musings.com/2009/01/04/InitializingTheFROMValueOfASilverlight2Animation.aspx</link>
      <pubDate>Sun, 04 Jan 2009 00:23:48 GMT</pubDate>
      <description>&lt;p&gt;
Recently, I was attempting to create my own popup dialog. I had specific requirements
in mind for this dialog, including:&amp;nbsp; 
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
I wanted to animate the Width/Height from 0x0 to the ActualWidth/ActualHeight 
&lt;li&gt;
I wanted to animate the Opacity from 0 to 1 
&lt;li&gt;
I wanted to animate the Top/Left properties from the point of mouse click (an icon
in my case) to the center of the screen and back to the original point of mouse click
when the user closed the dialog 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
All of these are fairly easy to accomplish using a Storyboard with an x:Name specified.&amp;nbsp;
In the case of my requirement #3 above, I merely needed to set the From value of my
animation and call the Begin() method, like so (for purposes of illustration, I'll
confine this to the Canvas.Left property only...you can apply the same logic to the
Canvas.Top property and it's all in the accompanying project):
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Storyboard x:Name="MoveDialogStoryboard"&amp;gt; 
&lt;br&gt;
&amp;nbsp; &amp;lt;DoubleAnimation 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x:Name="theDialogAnimation" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Storyboard.TargetName="theDialog"&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Storyboard.TargetProperty="(Canvas.Left)" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To="0" Duration="0:0:0.5" /&amp;gt; 
&lt;br&gt;
&amp;nbsp; &amp;lt;/Storyboard&amp;gt;
&lt;/p&gt;
&lt;p&gt;
theDialogAnimation.From = 800;&amp;nbsp;&amp;nbsp; // this value would actually come from
getting the mouse position via GetPosition() 
&lt;br&gt;
(MoveDialogStoryboard as Storyboard).Begin(); 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This all works as you would expect.&amp;nbsp; However, I really liked the idea of isolating
all of my dialog states into one place and the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager(VS.95).aspx" target=_blank&gt;Visual
State Manager&lt;/a&gt; sounded like the perfect solution...that is, until I tried to set
the FROM value programmatically and got hit with a NullReferenceException every time
I tried to reference my named Animation.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
I tried several things and ended up &lt;a href="http://silverlight.net/forums/p/61296/153074.aspx#153074" target=_blank&gt;posting
my issue&lt;/a&gt; to the &lt;a href="http://silverlight.net/" target=_blank&gt;Silverlight&lt;/a&gt; &lt;a href="http://silverlight.net/forums/" target=_blank&gt;forum&lt;/a&gt; where &lt;a href="http://wildermuth.com/" target=_blank&gt;Shawn
Wildermuth&lt;/a&gt; was kind enough to offer a solution.&amp;nbsp; Shawn's solution was to
simply set the property to the value before calling GoToState() in my code.&amp;nbsp;
This made perfect sense and I ran off to give it a try.&amp;nbsp; It worked...once.&amp;nbsp;
My animation would fire once but then appear to be swallowed or ignored on subsequent
clicks.&amp;nbsp; After further investigation, this turned out to be an artifact of the
fact that I was never setting my VisualState back to the original state...something
you don't have to do when using a Storyboard outside of the Visual State Manager.&amp;nbsp;
So, that fixed that issue and Shawn's solution worked.&amp;nbsp; However, I didn't really
see any way using this solution to animate back to the original point of mouse click.&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Either way, it didn't really satisfy my initial curiosity for WHY I couldn't programmatically
set the FROM value when my animation was inside a Visual State Manager, so I pressed
on.&amp;nbsp; Thanks to a couple of blog posts (&lt;a href="http://pagebrooks.com/archive/2008/11/05/finding-a-storyboard-in-the-visualstatemanager.aspx" target=_blank&gt;here&lt;/a&gt; and &lt;a href="http://math-geek-rock-chick.blogspot.com/2008/11/silverlight-dynamically-finding.html" target=_blank&gt;here&lt;/a&gt;)
and some pretty ugly LINQ, I was finally able to programmatically set the FROM value
and have it animate my dialog from the original point of mouse click with a Storyboard
inside of a VisualState like so:&amp;nbsp; 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
public void ShowDialog(Point startingPosition) 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Storyboard storyboard = Utils.FindStoryboard(LayoutRoot,
"DialogStates", "Open"); 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (storyboard.Children[0] as DoubleAnimation).From = startingPosition.X; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (storyboard.Children[1] as DoubleAnimation).From = startingPosition.Y; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VisualStateManager.GoToState(this, "Open", true); 
&lt;br&gt;
}
&lt;/p&gt;
&lt;p&gt;
// This is the definition of the extension method FindStoryboard() shown above (which
is where the real work happens) 
&lt;br&gt;
public static Storyboard FindStoryboard(this FrameworkElement parent, string groupName,
string stateName) 
&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VisualState visualState = VisualStateManager.GetVisualStateGroups(parent) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Cast&amp;lt;VisualStateGroup&amp;gt;().Where(group
=&amp;gt; group.Name == groupName) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .SingleOrDefault() 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .States.Cast&amp;lt;VisualState&amp;gt;() 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Where(state =&amp;gt; state.Name ==
stateName) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .SingleOrDefault(); 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (visualState != null) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return visualState.Storyboard;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
All of that being said, I didn't end up going this route nor do I recommend it.&amp;nbsp;
It's way too brittle and just plain ugly in my opinion.&amp;nbsp; In the end, I chose
to create my Open and Closed Storyboard animations for my popup dialog as standard
Resource Storyboards where I don't have to reset the State before calling and I don't
have to jump through hoops to set the value and, most importantly, I can set a name
for the Animation and directly set the property value.&amp;nbsp; For the actual "modes"
of my dialog (assuming there are multiple views for the dialog), I used the VSM to
represent things like EntryView, EditView, etc.&amp;nbsp; I think this offers a much cleaner
solution. 
&lt;br&gt;
&lt;br&gt;
I've put together a quick demo to illustrate both calling the Storyboard directly
and using a Storyboard in a VSM.&amp;nbsp; The live version is &lt;a href="http://silverlight.r2musings.com/InitializingAnimations/" target=_blank&gt;here&lt;/a&gt; and
the project source is available &lt;a href="http://www.r2musings.com/downloads/InitializingAnimations.zip" target=_blank&gt;here&lt;/a&gt;.&amp;nbsp; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=4515ddc4-d167-4192-9ed9-0383ef75e1b9" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,4515ddc4-d167-4192-9ed9-0383ef75e1b9.aspx</comments>
      <category>Silverlight</category>
      <category>Silverlight 2</category>
    </item>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=06a23a46-e6ee-48cc-8c20-9fc2847afa98</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,06a23a46-e6ee-48cc-8c20-9fc2847afa98.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,06a23a46-e6ee-48cc-8c20-9fc2847afa98.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=06a23a46-e6ee-48cc-8c20-9fc2847afa98</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We saw it when the world first discovered Flash and I'm sure we've got a lot of it
left to live through with <a href="http://silverlight.net" target="_blank">Silverlight</a>,
so this is pretty timely advice from the "Godfather of Web Usability" himself, <a href="http://www.useit.com/jakob/" target="_blank">Jakob
Nielsen</a>.  This should be required for every web developer.  There are
some great links within the post as well, so be sure to click around.
</p>
        <p>
          <a href="http://www.useit.com/alertbox/application-mistakes.html" target="_blank">Top-10
Application-Design Mistakes</a>
        </p>
        <img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=06a23a46-e6ee-48cc-8c20-9fc2847afa98" />
      </body>
      <title>Top-10 Application-Design Mistakes</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,06a23a46-e6ee-48cc-8c20-9fc2847afa98.aspx</guid>
      <link>http://www.r2musings.com/2008/02/20/Top10ApplicationDesignMistakes.aspx</link>
      <pubDate>Wed, 20 Feb 2008 05:52:10 GMT</pubDate>
      <description>&lt;p&gt;
We saw it when the world first discovered Flash and I'm sure we've got a lot of it
left to live through with &lt;a href="http://silverlight.net" target=_blank&gt;Silverlight&lt;/a&gt;,
so this is pretty timely advice from the "Godfather of Web Usability" himself, &lt;a href="http://www.useit.com/jakob/" target=_blank&gt;Jakob
Nielsen&lt;/a&gt;.&amp;nbsp; This should be required for every web developer.&amp;nbsp; There are
some great links within the post as well, so be sure to click around.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.useit.com/alertbox/application-mistakes.html" target=_blank&gt;Top-10
Application-Design Mistakes&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=06a23a46-e6ee-48cc-8c20-9fc2847afa98" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,06a23a46-e6ee-48cc-8c20-9fc2847afa98.aspx</comments>
      <category>Silverlight</category>
      <category>UI and Usability</category>
    </item>
    <item>
      <trackback:ping>http://www.r2musings.com/Trackback.aspx?guid=0f801d65-5e79-4469-a4f5-34ebe72af74e</trackback:ping>
      <pingback:server>http://www.r2musings.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.r2musings.com/PermaLink,guid,0f801d65-5e79-4469-a4f5-34ebe72af74e.aspx</pingback:target>
      <dc:creator>Rik Robinson</dc:creator>
      <wfw:comment>http://www.r2musings.com/CommentView,guid,0f801d65-5e79-4469-a4f5-34ebe72af74e.aspx</wfw:comment>
      <wfw:commentRss>http://www.r2musings.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0f801d65-5e79-4469-a4f5-34ebe72af74e</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>Back from the Silverlight Tour</title>
      <guid isPermaLink="false">http://www.r2musings.com/PermaLink,guid,0f801d65-5e79-4469-a4f5-34ebe72af74e.aspx</guid>
      <link>http://www.r2musings.com/2008/01/18/BackFromTheSilverlightTour.aspx</link>
      <pubDate>Fri, 18 Jan 2008 03:49:55 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
I had a chance to attend the recent Atlanta stop of &lt;a href="http://www.wildermuthconsulting.com/" target=_blank&gt;Wildermuth
Consulting&lt;/a&gt;’s &lt;a href="http://www.silverlight-tour.com/" target=_blank&gt;Silverlight
Tour&lt;/a&gt; this past week and wanted to offer some quick comments about it here for
anyone considering the class.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
Going into the class, I had about 3 weeks of heads-down knowledge of Silverlight 1.0,
but I had spent no time at all with Silverlight 1.1 (now 2.0).&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I
had also read &lt;a href="http://www.r2musings.com/ct.ashx?id=e3bbac57-25e3-4e3c-b583-6b1c3f4085c2&amp;amp;url=http%3a%2f%2fwww.amazon.com%2fgp%2fproduct%2f0672330075%3fie%3dUTF8%26tag%3dr2musings-20%26linkCode%3das2%26camp%3d1789%26creative%3d9325%26creativeASIN%3d0672330075" target=_blank&gt;Silverlight
1.0 Unleashed&lt;/a&gt;, watched a lot of the webcasts available and I had just (mostly)
completed my &lt;a href="http://www.r2musings.com/MyFirstLookAtTheSilverLight.aspx"&gt;first
Silverlight 1.0 project&lt;/a&gt;.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
The 3-day &lt;a href="http://www.silverlight-tour.com/" target=_blank&gt;Silverlight Tour&lt;/a&gt; begins
with Day 1 of mostly concepts and terminology and an introduction into the Expression
Suite.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This was mostly review for me,
but I still managed several “a-ha” moments during the day as the presenter, &lt;a href="http://www.adoguy.com/" target=_blank&gt;Shawn
Wildermuth&lt;/a&gt;, explained the “why” behind a lot of the concepts and decisions that
were made in regards to Silverlight.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;It
was a good “shoring up” of my skills in the foundations of Silverlight.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
Day 2 was all about the code.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;We spent
about ½ the day on Silverlight 1.0 and the other ½ on Silverlight 1.1. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;We
had several labs, lecture, and discussion throughout the day.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;(A
good mix of the three, in my opinion).&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;One
of the strengths of the class was that when questions would come up, we had the flexibility
in the schedule to actually go off on short tangents and explore different ideas as
a class.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I walked away from this day
with a much better understanding of how the code side of Silverlight works with the
design side, as well as, a lot of anticipation for Silverlight 2.0.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
Day 3 was the main reason I had taken the class and Shawn did not disappoint.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;One
of the things I struggled most with while working through the &lt;a href="http://silverlight.r2musings.com/weatherwidget/default.aspx"&gt;Weather
Widget&lt;/a&gt; was how to organize projects and where do I use this method from the AJAX
assemblies and where do I use Silverlight, etc. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;These
are the types of things that just aren’t in books yet, but Shawn has been there, done
that and you are getting it first-hand.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;We
learned about the integration points with ASP.NET Ajax and Silverlight, and even newer
technologies such as ASP.NET Data Services and the Entity Framework.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;Further,
we talked about packaging of Silverlight controls and other ways of thinking about
the generation of XAML…ways I hadn’t thought about until then.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Very
cool stuff from someone that truly understands the subject matter and takes the time
to explain things in such a way as to really help everyone “get it”.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
So, I walk away with a head full of knowledge about all kinds of fun things that will
be filling my life over the next year (and dying to tear my entire project for the
Weather Widget apart and do it with all the new Best Practices I managed to acquire
over the past 3 days)!&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;font face=Calibri color=#000000 size=3 font &lt;&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;img width="0" height="0" src="http://www.r2musings.com/aggbug.ashx?id=0f801d65-5e79-4469-a4f5-34ebe72af74e" /&gt;</description>
      <comments>http://www.r2musings.com/CommentView,guid,0f801d65-5e79-4469-a4f5-34ebe72af74e.aspx</comments>
      <category>ASP.NET Ajax</category>
      <category>Silverlight</category>
    </item>
  </channel>
</rss>