GetCellEditorContext Method
See Also  Example
Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > Cell Class : GetCellEditorContext Method

obj
The dependency object form which the property value is read.
Gets the value of the CellEditorContext attached property for the specified dependency object.

Syntax

Visual Basic (Declaration) 
Public Shared Function GetCellEditorContext( _
   ByVal obj As DependencyObject _
) As CellEditorContext
C# 
public static CellEditorContext GetCellEditorContext( 
   DependencyObject obj
)

Parameters

obj
The dependency object form which the property value is read.

Return Value

The CellEditorContext property value for the dependency object.

Example

XAMLCopy Code
<xcdg:Column.CellEditor> 
  <!-- ForeignKey CellEditor --> 
  <xcdg:CellEditor > 
     <xcdg:CellEditor.EditTemplate> 
        <DataTemplate> 
           <DataTemplate.Resources> 
              <xcdg:NullToBooleanConverter x:Key="nullToBooleanConverter" /> 
           </DataTemplate.Resources> 
            
           <ListBox x:Name="fkListBox" 
                     xcdg:Cell.IsCellFocusScope="True" 
                     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}" /> 
           <!-- 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="fkListBox" 
                         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="fkListBox" 
                         Property="ItemContainerStyleSelector" 
                         Value="{Binding RelativeSource={RelativeSource Self}, 
                                         Path=(xcdg:Cell.CellEditorContext).ForeignKeyConfiguration.ItemContainerStyleSelector, 
                                         Mode=OneWay}" /> 
              </DataTrigger> 
           </DataTemplate.Triggers> 
        </DataTemplate> 
     </xcdg:CellEditor.EditTemplate> 
  </xcdg:CellEditor> 
</xcdg:Column.CellEditor>

Remarks

Whether a foreign key constraint or enum is automatically detected or manually provided, the end result is that a ComboBox is used to edit the content of the corresponding cell unless a cell editor has been explicitly provided, in which case, the provided cell editor will be used. Cell editors that are created to edit foreign key constraints can access information about their parent column, such as the CellContentTemplate to use, through the CellEditorContext attached property (see Example).

Requirements

Supported Frameworks: Microsoft .NET Framework version 3.5

See Also