Hi Jason,
You would need to set a ComboBox in the CellEditor and hook to the Loaded event from there. Unfortunately while trying to make an example I found out that the default ForeignKey ComboBox isn't public.
However the developer found the following workaround by making your own ComboBox template:
<!-- Resources -->
<xcdg:NullToBooleanConverter x:Key="nullToBooleanConverter" />
<xcdg:CellEditor x:Key="fkCellEditor">
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<ComboBox x:Name="fkComboBox"
xcdg:Cell.IsCellFocusScope="True"
BorderThickness="0"
ItemTemplate="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ParentColumn.CellContentTemplate, Mode=OneWay}"
ItemContainerStyle="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ItemContainerStyle, Mode=OneWay}"
ItemsSource="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ItemsSource, Mode=OneWay}"
SelectedValuePath="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ValuePath, Mode=OneWay}"
DisplayMemberPath="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.DisplayMemberPath, Mode=OneWay}"
SelectedValue="{xcdg:CellEditorBinding}"
Loaded="fkComboBox_Loaded" />
<!-- Only affect Selector if Template or Style is null -->
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ParentColumn.CellContentTemplate, Converter={StaticResource nullToBooleanConverter}, Mode=OneWay}"
Value="True">
<Setter TargetName="fkComboBox"
Property="ItemTemplateSelector"
Value="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ParentColumn.CellContentTemplateSelector, Mode=OneWay}" />
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ItemContainerStyle, Converter={StaticResource nullToBooleanConverter}, Mode=OneWay}"
Value="True">
<Setter TargetName="fkComboBox"
Property="ItemContainerStyleSelector"
Value="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ItemContainerStyleSelector, Mode=OneWay}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
<!-- DataGridControl -->
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="MyValue"
CellEditor="{StaticResource fkCellEditor}" />
</xcdg:DataGridControl.Columns>
// Code-behind
private void fkComboBox_Loaded( object sender, RoutedEventArgs e )
{
ComboBox fkCombo = sender as ComboBox;
AdornerLayer.GetAdornerLayer( fkCombo ).Add( new MustSelectAddorner( fkCombo ) );
}
// Remove the following line from your code:
//map.Add( int.MinValue, "Select..." );
** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!
Diane Lafontaine
Technical Support
Xceed Software Inc.