Retrieving a Reference to an Item in a Header or Footer Section
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.
tip
The sender in the Loaded event handler will be the InsertionRow and can be cast as such.
- XAML
- C#
- VB.NET
<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>
private void InsertionRow_Loaded( object sender, RoutedEventArgs e )
{
InsertionRow insertionRow = sender as InsertionRow;
if( insertionRow != null )
{
// Your code here
}
}
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