title: Silverlight DataGrid - Customizing Group Header Text with info from items contained within
body: <p>I have restyled the DataGridRowGroupHeader on my datagrid because I want to change the text it displays.
  What I want is for it to summarize the data that it holds in its group.
  (Specifically code should be able to check all the items held in the collection to find the one with the oldest date).</p>
  
  <p>I am having trouble though with trying to access the items in the collection.
  I was trying using a converter in the RowGroupHeader where it renders the text - but the collection always comes back as empty.</p>
  
  <pre><code>&lt;sdk:DataGrid.RowGroupHeaderStyles&gt; 
          &lt;Style TargetType="sdk:DataGridRowGroupHeader"&gt; 
              &lt;Setter Property="Template"&gt; 
          &lt;!-- All the other spield from the default template, leading to below where the header text is rendered --&gt; 
  
          &lt;StackPanel Grid.Column="3" Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,1,0,1"&gt; 
              &lt;TextBlock x:Name="PropertyNameElement" Margin="4,0,0,0"/&gt; 
              &lt;TextBlock Margin="4,0,0,0" Text="{Binding Name}" /&gt; 
              &lt;TextBlock x:Name="ItemCountElement" Margin="4,0,0,0" Visibility="{TemplateBinding ItemCountVisibility}"/&gt; 
              &lt;TextBlock x:Name="oldest" Margin="4,0,0,0" Text="{Binding Converter={StaticResource myConverter}, ConverterParameter=Orders}" /&gt; 
          &lt;/StackPanel&gt;
  </code></pre>
  
  <p>And my converter is looking like:</p>
  
  <pre><code>public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
  { 
      CollectionViewGroup cvg = value as CollectionViewGroup; 
  
      if (cvg.Items.Count==0) 
          return "Test Fails"; 
      else 
          return FindOldestObjectInCollection(cvg.Items); 
  }
  </code></pre>
  
  <p>The CollectionViewGroup above is always empty - I was lead to beleive it should contain all the items in the group.
  (Group created as a PagedCollectionView).
  Any ideas where I am going wrong?</p>