title: Nested Silverlight Datagrid - Row Details works great, but I want a button!
body: <p>I'm using a silverlight 3 datagrid, and within it, I'm nesting related records in another control by using the rowdetails (visibilitymode = visiblewhenselected).</p>
  
  <p>I really like how this works, but I'd much rather have the grid display the row details when a "+" button is pressed, much as a tree will expand when you click a node.</p>
  
  <p>I tried programmatically defining the template by using resources like this:</p>
  
  <pre><code>&lt;Grid.Resources&gt;
      &lt;DataTemplate x:Key="EmptyTemplate"&gt;
          &lt;StackPanel&gt;
              &lt;!--&lt;TextBlock Text="Empty Template!!!" /&gt;--&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
      &lt;DataTemplate x:Key="SongTemplate"&gt;
          &lt;StackPanel&gt;
              &lt;AdminControls:ArtistSongControl x:Name="ArtistSongControl" /&gt;
          &lt;/Stack&gt;
      &lt;/DataTemplate&gt;
  &lt;/Grid.Resources&gt;
  </code></pre>
  
  <p>And in the grid's LoadingRowDetails event, I'd choose which template to set by:</p>
  
  <pre><code>e.Row.DetailsTemplate = (DataTemplate)LayoutRoot.Resources["SongTemplate"];
  </code></pre>
  
  <p>This sortof worked, but I found that I had problems with collapsing previous rows details template, and even crashed ie8 (not sure if that's related).</p>
  
  <p>Basically, I really like how the silverlight 3 datagrid works, and even how the rowdetailstemplate stuff is implemented.  I simply would like to defer loading any details until a row is expanded purposely (as a tree would be).  All of the 3rd party grids seem to do this, and microsoft's is soooo close.  Does anyone have any idea how to solve this one?</p>
  
  <p>Thanks, Dennis</p>