Xceed DataGrid for Silverlight Documentation
ActivatingCellEditor Event
Example 


Raised when a cell editor is about to be activated to allow custom settings to be provided.
Syntax
'Declaration
 
Public Event ActivatingCellEditor As EventHandler(Of ActivatingCellEditorEventArgs)
'Usage
 
Dim instance As Column
Dim handler As EventHandler(Of ActivatingCellEditorEventArgs)
 
AddHandler instance.ActivatingCellEditor, handler
public event EventHandler<ActivatingCellEditorEventArgs> ActivatingCellEditor
Event Data

The event handler receives an argument of type ActivatingCellEditorEventArgs containing data related to this event. The following ActivatingCellEditorEventArgs properties provide information specific to this event.

PropertyDescription
Cell  
CellEditor Gets the cell editor that is being activated.
Column  
DataItem  
DataPath  
Row  
Example
Private Sub CustomerIDColumn_ActivatingCellEditor( ByVal sender As Object, ByVal e As ActivatingCellEditorEventArgs )
   Dim comboCellEditor As ComboBoxCellEditor = CType( e.CellEditor, ComboBoxCellEditor )
   comboCellEditor.ItemsSource = Data.Customers
 
   ' Set the SelectedValuePath of the ComboBoxCellEditor to ensure the value
   ' returned by the CellEditor is the CustomerID value and not the Customer
   ' instance directly      
   comboCellEditor.SelectedValuePath = "CustomerID"
End Sub
private void CustomerIDColumn_ActivatingCellEditor( object sender, ActivatingCellEditorEventArgs e )
{
   ComboBoxCellEditor comboCellEditor = e.CellEditor as ComboBoxCellEditor;
   comboCellEditor.ItemsSource = Data.Customers;
 
   // Set the SelectedValuePath of the ComboBoxCellEditor to ensure the value
   // returned by the CellEditor is the CustomerID value and not the Customer
   // instance directly      
   comboCellEditor.SelectedValuePath = "CustomerID";
}
<sldg:DataGridControl x:Name="sldgDataGridControl"
                      ItemsSource="{Binding Path=Orders}">
    <sldg:DataGridControl.Resources>
        <!-- ControlTemplate to display the Value in a foreign source from the primary key -->
        <ControlTemplate x:Key="idDictionaryControlTemplate"
                         TargetType="local:IDDictionary">
            <ContentPresenter Content="{TemplateBinding Value}"
                              ContentTemplate="{TemplateBinding ValueTemplate}"/>
        </ControlTemplate>
 
        <!-- DataTemplate to display a Customer -->
        <DataTemplate x:Key="customerDataTemplate">
            <TextBlock Text="{Binding CompanyName}"/>
        </DataTemplate>
 
        <DataTemplate x:Key="customerIDDataTemplate">
            <!-- Use the IDDictionary to convert the value in the source to an instance of Customer -->
            <local:CustomerIDDictionary ID="{Binding}"
                                        ValueTemplate="{StaticResource customerDataTemplate}"
                                        Template="{StaticResource idDictionaryControlTemplate}"
                                        VerticalAlignment="Top"/>
        </DataTemplate>
    </sldg:DataGridControl.Resources>
    <sldg:DataGridControl.Columns>
        <sldg:Column FieldName="CustomerID"
                     Title="Customer ID"
                     CellEditorType="Xceed.Silverlight.DataGrid.ComboBoxCellEditor"
                     ActivatingCellEditor="CustomerIDColumn_ActivatingCellEditor"
                     CellContentTemplate="{StaticResource customerIDDataTemplate}">
            <sldg:Column.CellEditorStyle>
                <!-- Set the ItemTemplate of the ComboBoxEditor to be the same as the CellContentTemplate -->
                <Style TargetType="sldg:ComboBoxCellEditor">
                    <Setter Property="ItemTemplate"
                  Value="{StaticResource customerDataTemplate}"/>
                </Style>
            </sldg:Column.CellEditorStyle>
        </sldg:Column>
    </sldg:DataGridControl.Columns>
</sldg:DataGridControl>
Requirements

Target Platforms: Windows 7, Windows Vista, Windows XP SP3, Windows Server 2008 family

See Also

Reference

Column Class
Column Members

Editing and Inserting Data

Cell Editors

Send Feedback