FixedCellPanel Class
See Also  Members   Example 
Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid.Views Namespace : FixedCellPanel Class


Panel used as the PART_CellsHost template part when a grid is in a table-view layout.

Syntax

Visual Basic (Declaration) 
Public Class FixedCellPanel 
   Inherits Panel
   Implements ISupportInitializeIFrameworkInputElementIInputElementIWeakEventListenerIAddChildIHaveResourcesIAnimatableDUCE.IResource, IPrintInfo, IVirtualizingCellsHost 
C# 
public class FixedCellPanel : Panel, ISupportInitializeIFrameworkInputElementIInputElementIWeakEventListenerIAddChildIHaveResourcesIAnimatableDUCE.IResource, IPrintInfo, IVirtualizingCellsHost  

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.
XAMLCopy 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.
XAMLCopy 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.
XAMLCopy 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>

Remarks

Fixed Columns vs. Templates This feature is available only in the Professional Edition 

In order to support fixed columns when creating a new row template for a table-view layout, the following criteria must be met:

  1. The PART_CellsHost template part must be a FixedCellPanel.
  2. The FixedCellCount property of the FixedCellPanel must be bound to the table view's FixedColumnCount property using a TwoWay ViewBinding.

The fixed-cell-panel properties listed below are also usually bound when provided a new row template for a table-view layout:

  1. SplitterStyle (TemplateBinding xcdg:TableView.FixedColumnSplitterStyle)
  2. SplitterWidth (xcdg:ViewBinding FixedColumnSplitterWidth)
  3. ShowSplitter (xcdg:ViewBinding ShowFixedColumnSplitter)
  4. FixedColumnDropMarkPen (xcdg:ViewBinding FixedColumnDropMarkPen)

If a new template is provided for a DataGridControl and fixed columns are to be supported, it is essential that a TableViewScrollViewer be used. This scroll viewer is responsible for preserving the TranslateTransforms that fix and scroll elements, as well as executing the PageLeft and PageRight actions according to the reduced viewport.  It is also recommended that an AdornerDecorator be located above the TableViewScrollViewer of the templated DataGridControl to support drag and dropping of the fixed-column splitter correctly.

Notes

When using a FixedCellPanel, the orientation of the ItemsHost must be set to Vertical.

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Media.Visual
            System.Windows.UIElement
               System.Windows.FrameworkElement
                  System.Windows.Controls.Panel
                     Xceed.Wpf.DataGrid.Views.FixedCellPanel

Requirements

Supported Operating Systems: Windows Server 2003 Service Pack 1; Windows Vista; Windows XP Service Pack 2

See Also