Interprets and creates the binding between an element and the view applied to a grid.
Syntax
Example
All examples in this topic assume that the grid is bound to the
Orders table of the Northwind database, unless stated otherwise.
The following example demonstrates how to provide, through a style, a new InsertionRow template. In order to preserve the fixed-column splitter in the insertion row, we need to use a FixedCellPanel as the PART_CellsHost template part.
| 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}" AutoCreateItemProperties="False"/> <Style x:Key="insertionrow_style" TargetType="{x:Type xcdg:InsertionRow}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type xcdg:InsertionRow}"> <Expander Header="Insert New Data"> <Border BorderBrush="LightBlue" BorderThickness="0, 1, 0, 1"> <xcdg:FixedCellPanel x:Name="PART_CellsHost" FixedCellCount="{xcdg:ViewBinding FixedColumnCount, Mode=TwoWay}" SplitterStyle="{TemplateBinding xcdg:TableView.FixedColumnSplitterStyle}" SplitterWidth="{xcdg:ViewBinding FixedColumnSplitterWidth}" ShowSplitter="{xcdg:ViewBinding ShowFixedColumnSplitter}" FixedColumnDropMarkPen="{xcdg:ViewBinding FixedColumnDropMarkPen}" Background="LightBlue"/> </Border> </Expander> </ControlTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources> <xcdg:DataGridControl x:Name="OrdersGrid" ItemsSource="{Binding Source={StaticResource cvs_orders}}"> <xcdg:DataGridControl.View> <xcdg:TableView> <xcdg:TableView.FixedFooters> <DataTemplate> <xcdg:InsertionRow Style="{StaticResource insertionrow_style}"/> </DataTemplate> </xcdg:TableView.FixedFooters> </xcdg:TableView> </xcdg:DataGridControl.View> </xcdg:DataGridControl> </Grid> |
The following example demonstrates how to initialize the values of the ShipCountry, ShipCity, and ShipVia columns in an insertion row located in the fixed headers. The handler for the InitializingInsertionRow event is defined in the code-behind class.
The columns that are contained in the grid will be limited to those specified in the ItemProperties of the DataGridCollectionViewSource.
| 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}" AutoCreateItemProperties="False"> <xcdg:DataGridCollectionViewSource.ItemProperties> <xcdg:DataGridItemProperty Name="ShipCountry" Title="Country"/> <xcdg:DataGridItemProperty Name="ShipCity" Title="City"/> <xcdg:DataGridItemProperty Name="ShipVia" Title="Ship With"/> </xcdg:DataGridCollectionViewSource.ItemProperties> </xcdg:DataGridCollectionViewSource> </Grid.Resources> <xcdg:DataGridControl x:Name="OrdersGrid" ItemsSource="{Binding Source={StaticResource cvs_orders}}" InitializingInsertionRow="InitInsertion"> <xcdg:DataGridControl.View> <xcdg:CardView> <xcdg:CardView.FixedHeaders> <DataTemplate> <xcdg:InsertionRow/> </DataTemplate> </xcdg:CardView.FixedHeaders> </xcdg:CardView> </xcdg:DataGridControl.View> </xcdg:DataGridControl> </Grid> |
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.
| 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}" AutoCreateItemProperties="False/> </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 example demonstrates how to use a PrintTableView and configure it to display a title in the page headers and the page number in the page footers. The elements added to these sections must be added as DataTemplates and will be repeated on each page.
The Print method will be called in the button's Click event, whose implementation is not provided.
| XAML | Copy Code |
|---|
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" xmlns:local="clr-namespace:Xceed.Wpf.Documentation"> <Grid.Resources> <xcdg:DataGridCollectionViewSource x:Key="cvs_employees" Source="{Binding Source={x:Static Application.Current}, Path=Employees}"/> </Grid.Resources> <DockPanel> <Button Content="Print Grid" Click="PrintGrid" DockPanel.Dock="Top"/> <xcdg:DataGridControl x:Name="EmployeesGrid" ItemsSource="{Binding Source={StaticResource cvs_employees}}"> <xcdg:DataGridControl.PrintView> <xcdg:PrintTableView> <xcdg:PrintTableView.PageHeaders> <DataTemplate> <TextBlock Text="Xceed WPF Documentation" HorizontalAlignment="Center" FontWeight="Bold" FontSize="20"/> </DataTemplate> <DataTemplate> <TextBlock Text="Printing Example" HorizontalAlignment="Center" FontSize="16"/> </DataTemplate> </xcdg:PrintTableView.PageHeaders> <xcdg:PrintTableView.PageFooters> <DataTemplate> <TextBlock Text="{xcdg:ViewBinding CurrentPageNumber}" HorizontalAlignment="Right"/> </DataTemplate> </xcdg:PrintTableView.PageFooters> </xcdg:PrintTableView> </xcdg:DataGridControl.PrintView> </xcdg:DataGridControl> </DockPanel> </Grid> |
The following example demonstrates how to change the default text displayed in the progress window when the Print or ExportToXps methods are called. The implementation of the PrintGrid method is not provided.
| XAML | Copy Code |
|---|
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> <Grid.Resources> <xcdg:DataGridCollectionViewSource x:Key="cvs_employees" Source="{Binding Source={x:Static Application.Current}, Path=Employees}"/> </Grid.Resources> <DockPanel> <Button Content="Print Employee Information" Click="PrintGrid" DockPanel.Dock="Top"/> <xcdg:DataGridControl x:Name="EmployeesGrid" ItemsSource="{Binding Source={StaticResource cvs_employees}}" DockPanel.Dock="Bottom"> <xcdg:DataGridControl.PrintView> <xcdg:PrintTableView> <xcdg:PrintTableView.ProgressWindowDescription> <StackPanel Orientation="Horizontal"> <TextBlock Text="Printing page "/> <TextBlock Text="{Binding CurrentPageNumber}"/> <TextBlock Text=" of employee information..."/> </StackPanel> </xcdg:PrintTableView.ProgressWindowDescription> </xcdg:PrintTableView> </xcdg:DataGridControl.PrintView> </xcdg:DataGridControl> </DockPanel> </Grid> |
Remarks
Inheritance Hierarchy
Requirements
Supported Operating Systems: Windows Server 2003 Service Pack 1; Windows Vista; Windows XP Service Pack 2
See Also