Xceed DataGrid for WPF v7.2 Documentation
SelectDetailConfiguration Method
Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DetailConfigurationSelector Class : SelectDetailConfiguration Method

The name used to identify the relation between the master item and its detail items

The DataGridDetailDescription that represents the relation in the DataGridCollectionView

Selects the appropriate detail configuration based on the specified information.

Syntax
'Declaration
 
Public Overridable Function SelectDetailConfiguration( _

   ByVal relationName As String, _

   ByVal dataGridDetailDescription As DataGridDetailDescription _

) As DetailConfiguration
'Usage
 
Dim instance As DetailConfigurationSelector

Dim relationName As String

Dim dataGridDetailDescription As DataGridDetailDescription

Dim value As DetailConfiguration

 

value = instance.SelectDetailConfiguration(relationName, dataGridDetailDescription)
public virtual DetailConfiguration SelectDetailConfiguration( 

   string relationName,

   DataGridDetailDescription dataGridDetailDescription

)

Parameters

relationName

The name used to identify the relation between the master item and its detail items

dataGridDetailDescription
The DataGridDetailDescription that represents the relation in the DataGridCollectionView
Example
This example assumes that the grid is bound to the Orders table of the Northwind database. The following example demonstrates how to create a custom detail-configuration selector that will return the appropriate detail configuration depending on the relation name, and in which a column is hidden and another is modified in its width and content alignment. The implementation of the OrdersDetailConfigurationSelector is provided below.
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">

   <Grid.Resources>



      <xcdg:DataGridCollectionViewSource x:Key="cvsOrders"

                                         Source="{Binding Source={x:Static Application.Current},Path=Orders}" />



      <local:OrdersDetailConfigurationSelector x:Key="ordersDetailConfigurationSelector" />



   </Grid.Resources>



   <xcdg:DataGridControl x:Name="dataGrid"

                         ItemsSource="{Binding Source={StaticResource cvsOrders}}"

                         DetailConfigurationSelector="{StaticResource ordersDetailConfigurationSelector}" />

</Grid>
public class OrdersDetailConfigurationSelector : DetailConfigurationSelector

{

  public override DetailConfiguration SelectDetailConfiguration( string relationName, DataGridDetailDescription dataGridDetailDescription )

  {

    var detailConfig = default( DetailConfiguration );



    if( relationName == "OrdersOrderDetails" )

    {

      var discountColumn = new Column { FieldName = "Discount", Visible = false };

      var unitPriceColumn = new Column { FieldName = "UnitPrice", Title = "Unit Price", Width = 60, CellHorizontalContentAlignment = HorizontalAlignment.Center };



      detailConfig = new DetailConfiguration();

      detailConfig.RelationName = relationName;

      detailConfig.AutoCreateDetailConfigurations = true;

      detailConfig.Columns.Add( discountColumn );

      detailConfig.Columns.Add( unitPriceColumn );

    }



    return detailConfig;

  }

}
Public Class OrdersDetailConfigurationSelector

      Inherits DetailConfigurationSelector

    Public Overrides Function SelectDetailConfiguration(ByVal relationName As String, ByVal dataGridDetailDescription As DataGridDetailDescription) As DetailConfiguration

      Dim detailConfig = Nothing



      If relationName = "OrdersOrderDetails" Then

          Dim discountColumn = New Column With {.FieldName = "Discount", .Visible = False}

          Dim unitPriceColumn = New Column With {.FieldName = "UnitPrice", .Title = "Unit Price", .Width = 60, .CellHorizontalContentAlignment = HorizontalAlignment.Center}



          detailConfig = New DetailConfiguration()

          detailConfig.RelationName = relationName

          detailConfig.AutoCreateDetailConfigurations = True

          detailConfig.Columns.Add(discountColumn)

          detailConfig.Columns.Add(unitPriceColumn)

      End If



      Return detailConfig

    End Function

End Class
Requirements

Target Platforms: Windows 11, Windows, 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DetailConfigurationSelector Class
DetailConfigurationSelector Members