The following page provides a list of examples that demonstrate how to customize the appearance of table views. For more table view-related information, refer to the Table View topic.
 |
All examples in this topic assume that the grid is bound to the Orders or Employees table of the Northwind database, unless stated otherwise. |
Adding an InsertionRow to the fixed headers
The following example demonstrates how to add an InsertionRow to the fixed header section of a grid.
| 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/>
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid> |
Clearing a fixed header section
The following example demonstrates how to clear the content of all header and footer sections of a grid using its view's UseDefaultHeadersFooters property.
| 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:CardView UseDefaultHeadersFooters="False"/>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid> |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
Hiding the group-level indicator pane
The following example demonstrates how to hide the group-level indicator pane by creating a style which sets the Visibility property of GroupLevelIndicatorPane objects to Collapsed.
| XAML |
Copy Code |
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
<Grid.Resources>
<Style TargetType="{x:Type xcdg:GroupLevelIndicatorPane}">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
<xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
Source="{Binding Source={x:Static Application.Current},
Path=Orders}">
<xcdg:DataGridCollectionViewSource.GroupDescriptions>
<xcdg:DataGridGroupDescription PropertyName="ShipCountry"/>
</xcdg:DataGridCollectionViewSource.GroupDescriptions>
</xcdg:DataGridCollectionViewSource>
</Grid.Resources>
<xcdg:DataGridControl x:Name="OrdersGrid"
ItemsSource="{Binding Source={StaticResource cvs_orders}}"/>
</Grid> |
Hiding the row-selector pane
The following example demonstrates how to hide the row-selector pane.
| 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 ShowRowSelectorPane="False"/>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid> |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
Fixing columns
The following example demonstrates how to fix the ShipCountry and ShipCity columns.
| 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.Columns>
<xcdg:Column FieldName="ShipCountry" VisiblePosition="0"/>
<xcdg:Column FieldName="ShipCity" VisiblePosition="1"/>
</xcdg:DataGridControl.Columns>
<xcdg:DataGridControl.View>
<xcdg:TableView FixedColumnCount="2"/>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid> |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
Allowing horizontal scrolling
The following example demonstrates how to prevent horizontal scrolling of the group-by control in the fixed header section.
| 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}">
<xcdg:DataGridCollectionViewSource.GroupDescriptions>
<xcdg:DataGridGroupDescription PropertyName="ShipCountry"/>
</xcdg:DataGridCollectionViewSource.GroupDescriptions>
</xcdg:DataGridCollectionViewSource>
</Grid.Resources>
<xcdg:DataGridControl x:Name="OrdersGrid"
ItemsSource="{Binding Source={StaticResource cvs_orders}}">
<xcdg:DataGridControl.View>
<xcdg:TableView UseDefaultHeadersFooters="False">
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:GroupByControl xcdg:TableView.CanScrollHorizontally="True"/>
</DataTemplate>
<DataTemplate>
<xcdg:ColumnManagerRow/>
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid> |
Using routed view properties
The following example demonstrates how to set routed view properties on detail configurations to change the width of their detail indicators as well as to fix columns and remove the fixed-column splitter.
| 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>
<xcdg:DataGridControl x:Name="EmployeesGrid"
ItemsSource="{Binding Source={StaticResource cvs_employees}}"
AutoCreateDetailConfigurations="True">
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="Photo"
Visible="False" />
</xcdg:DataGridControl.Columns>
<xcdg:DataGridControl.DetailConfigurations>
<xcdg:DetailConfiguration RelationName="Employee_Orders"
Title="Employee Orders"
xcdg:TableView.DetailIndicatorWidth="50"
xcdg:TableView.FixedColumnCount="2">
<xcdg:DetailConfiguration.Columns>
<xcdg:Column FieldName="EmployeeID"
Visible="False" />
</xcdg:DetailConfiguration.Columns>
<xcdg:DetailConfiguration.DetailConfigurations>
<xcdg:DetailConfiguration RelationName="Order_OrderDetails"
Title="Order Details"
xcdg:TableView.ShowFixedColumnSplitter="False"
xcdg:TableView.DetailIndicatorWidth="50"/>
</xcdg:DetailConfiguration.DetailConfigurations>
</xcdg:DetailConfiguration>
</xcdg:DataGridControl.DetailConfigurations>
</xcdg:DataGridControl>
</Grid> |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
Stretching columns
The following example demonstrates how to stretch all the columns in a grid equally so that they occupy the full width available in the viewport.
| 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" />
<xcdg:DataGridItemProperty Name="ShipCity" />
<xcdg:DataGridItemProperty Name="ShipRegion" />
<xcdg:DataGridItemProperty Name="ShipVia" />
</xcdg:DataGridCollectionViewSource.ItemProperties>
</xcdg:DataGridCollectionViewSource>
</Grid.Resources>
<xcdg:DataGridControl x:Name="OrdersGrid"
ItemsSource="{Binding Source={StaticResource cvs_orders}}">
<xcdg:DataGridControl.View>
<xcdg:TableView ColumnStretchMode="All"
ColumnStretchMinWidth="100"/>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid> |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
| MISSING WIDGET TYPE: The "Fallback" Widget Type could not be found. The "Fallback" Widget Type may have been deleted since this Widget was created. |
Applying a grid background brush