Xceed DataGrid for WPF v7.2 Documentation
Defining Foreign Key Configurations

The following example demonstrates how to define foreign key configurations for foreign key descriptions that were automatically created from the constraints extracted from the underlying DataTable.

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}"

                                       AutoCreateForeignKeyDescriptions="True"/>

 </Grid.Resources>      

 

 <xcdg:DataGridControl x:Name="OrdersGrid"

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

                       AutoCreateForeignKeyConfigurations="True">

    <xcdg:DataGridControl.Columns>

       <xcdg:Column FieldName="EmployeeID"

                    Title="Employee">

          <xcdg:Column.CellContentTemplate>

             <DataTemplate>

                <StackPanel Orientation="Horizontal">

                   <TextBlock Text="{Binding FirstName}" />

                   <TextBlock Text=" " />

                   <TextBlock Text="{Binding LastName}" />

                </StackPanel>

             </DataTemplate>

          </xcdg:Column.CellContentTemplate>

       </xcdg:Column>

       <xcdg:Column FieldName="CustomerID"

                    Title="Customer">

          <xcdg:Column.ForeignKeyConfiguration>

             <xcdg:ForeignKeyConfiguration DisplayMemberPath="CompanyName"

                                           ValuePath="CustomerID" />

          </xcdg:Column.ForeignKeyConfiguration>

       </xcdg:Column>

       

       <xcdg:Column FieldName="ShipVia"

                    Title="Shipping Company">

          <xcdg:Column.ForeignKeyConfiguration>

             <xcdg:ForeignKeyConfiguration DisplayMemberPath="CompanyName"

                                           ValuePath="ShipperID" />

          </xcdg:Column.ForeignKeyConfiguration>

       </xcdg:Column>

    </xcdg:DataGridControl.Columns>

 </xcdg:DataGridControl>

</Grid>