Xceed DataGrid for WPF v7.3 Documentation
In This Topic
    Coercing a surface configuration
    In This Topic

    The following example demonstrates how to apply a different surface configuration on the back surface of the center card using the CoercedSurfaceConfiguration attached property.

    VB.NET
    Copy Code
    Private m_fullSurfaceConfiguration As New ImageAndDataSurfaceConfiguration()
    Private Sub ApplyCoercedSurfaceConfiguration( ByVal sender As Object, ByVal e As RoutedEventArgs )
      If Not Me.ProductsGrid.CurrentItem Is Nothing Then
        Dim card As Xceed.Wpf.DataGrid.DataRow = CType( Me.ProductsGrid.GetContainerFromItem( _
                                             Me.ProductsGrid.CurrentItem ), Xceed.Wpf.DataGrid.DataRow )
        If Not card Is Nothing Then
           card.SetValue( MultiSurfaceViewBase.CoercedSurfaceConfigurationProperty, m_fullSurfaceConfiguration )
        End If
      End If
    End Sub
    C#
    Copy Code
    private ImageAndDataSurfaceConfiguration m_fullSurfaceConfiguration = new ImageAndDataSurfaceConfiguration();
    private void ApplyCoercedSurfaceConfiguration( object sender, RoutedEventArgs e )
    {
      if( this.ProductsGrid.CurrentItem != null )
      {
       Xceed.Wpf.DataGrid.DataRow card = this.ProductsGrid.GetContainerFromItem(
                                            this.ProductsGrid.CurrentItem ) as Xceed.Wpf.DataGrid.DataRow;
       if( card != null )
       {
         card.SetValue( MultiSurfaceViewBase.CoercedSurfaceConfigurationProperty, m_fullSurfaceConfiguration );
       }
      }
    }

    The following XAML demonstrates how to define the initial surface configurations that are applied to various surfaces. 

    XAML
    Copy Code
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">     
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto"/>
         <RowDefinition/>
      </Grid.RowDefinitions>
      <Grid.Resources>
        
         <xcdg:DataGridCollectionViewSource x:Key="cvs_products"
                                        Source="{Binding Source={x:Static Application.Current}, Path=ProductsTable}"/>
      </Grid.Resources>
     <Button Content="Coerce Surface Configuration"
             Click="ApplyCoercedSurfaceConfiguration"
             Grid.Row="0"/>
      <xcdg:DataGridControl x:Name="ProductsGrid"
                            ItemsSource="{Binding Source={StaticResource cvs_products}}"
                            Grid.Row="1">
         <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="ProductName"
                         IsMainColumn="True"/>
         </xcdg:DataGridControl.Columns>
        <xcdg:DataGridControl.View>
           <xcdg:CardflowView3D CardHeightToViewportRatio="0.5">
              <xcdg:CardflowView3D.Theme>
                 <xcdg:ElementalBlackTheme>
                    <xcdg:ElementalBlackTheme.SurfaceConfigurations>
                       <xcdg:ImageSurfaceConfiguration xcdg:CardflowView3D.Surfaces="Left, Right"/>
                       <xcdg:ImageAndTitleSurfaceConfiguration xcdg:CardflowView3D.Surfaces="Center"/>
                       <xcdg:CompleteSurfaceConfiguration xcdg:CardflowView3D.Surfaces="Back"
                                                          AutoFillDefaultRegion="False">
                          <xcdg:CompleteSurfaceConfiguration.DataRegionConfiguration>
                             <xcdg:RegionConfiguration FieldNames="ProductID, UnitPrice, UnitsInStock"/>
                          </xcdg:CompleteSurfaceConfiguration.DataRegionConfiguration>                      
                       </xcdg:CompleteSurfaceConfiguration>
                    </xcdg:ElementalBlackTheme.SurfaceConfigurations>
                 </xcdg:ElementalBlackTheme>
              </xcdg:CardflowView3D.Theme>
           </xcdg:CardflowView3D>           
        </xcdg:DataGridControl.View>
      </xcdg:DataGridControl>
    </Grid>