[Root] / Welcome to Xceed DataGrid, Editors, and 3D Views for WPF v7.3 / [Root] / Xceed DataGrid for WPF / [Root] / Code Snippets / Retrieving a Reference to an Item in a Header or Footer Section

In This Topic
    Retrieving a Reference to an Item in a Header or Footer Section
    In This Topic

    The following example demonstrates how to retrieve a reference to an InsertionRow that is located in the fixed headers of a grid by handling its Loaded event.

    The sender in the Loaded event handler will be the InsertionRow and can be cast as such.
    XAML
    Copy Code
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
       <Grid.Resources>
          <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                             Source="{Binding Source={x:Static Application.Current},
                                                              Path=Orders}" />
       </Grid.Resources>
       <xcdg:DataGridControl x:Name="OrdersGrid"
                             ItemsSource="{Binding Source={StaticResource cvs_orders}}">
          <xcdg:DataGridControl.View>
             <xcdg:TableView>
               <xcdg:TableView.FixedHeaders>
                  <DataTemplate>
                     <xcdg:InsertionRow Loaded="InsertionRow_Loaded"/>
                  </DataTemplate>
               </xcdg:TableView.FixedHeaders>
            </xcdg:TableView> 
          </xcdg:DataGridControl.View>
       </xcdg:DataGridControl>    
    </Grid>

    The following code provides the implementation of the Loaded event handler. 

    VB.NET
    Copy Code
    Private Sub InsertionRow_Loaded( ByVal sender As Object, ByVal e As RoutedEventArgs )
       Dim insertionRow As InsertionRow = TryCast( sender, InsertionRow )
       If Not insertionRow Is Nothing Then
          ' Your code here
       End If
    End Sub
    C#
    Copy Code
    private void InsertionRow_Loaded( object sender, RoutedEventArgs e )
    {
       InsertionRow insertionRow = sender as InsertionRow;
       if( insertionRow != null )
       {
          // Your code here
       }
    }