Xceed Toolkit Plus for WPF v4.7 Documentation
Handling edit events2

The following example demonstrates how to subscribe to the Cell.EditBeginning and EditBegun routed events as well as how to handle and cancel them.

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}" />
        </Grid.Resources>
   <DockPanel>
      <StackPanel DockPanel.Dock="Top">
         <CheckBox x:Name="handledByRowCheckBox"
                   Content="Events are handled by the rows"
                   IsChecked="False" />
         <CheckBox x:Name="cancelBeginEdit"
                   Content="Cancel BeginEdit event"
                   IsChecked="False" />
      </StackPanel>
      <xcdg:DataGridControl x:Name="OrdersGrid"
                            ItemsSource="{Binding Source={StaticResource cvs_orders}}"
                            xcdg:Cell.EditBeginning="EditBeginning"
                            xcdg:Cell.EditBegun="EditBegun"/>
   </DockPanel>
</Grid>

The following code provides the implementation of the EditBeginning and EditBegun event handlers.

VB.NET
Copy Code
Public Sub EditBeginning( ByVal sender As Object, ByVal e As CancelRoutedEventArgs )
   If Me.cancelBeginEdit.IsChecked = True Then
      e.Cancel = True
   End If
   If Me.handledByRowCheckBox.IsChecked = True Then
     e.Handled = True
   End If
   Debug.WriteLine( sender + ": EditBeginning" )
End Sub
Public Sub EditBegun( ByVal sender As Object, ByVal e As RoutedEventArgs )
   If Me.handledByRowCheckBox.IsChecked = True Then
     e.Handled = True
   End If
   Debug.WriteLine( sender + ": EditBegun" )
End Sub
C#
Copy Code
public void EditBeginning( object sender, CancelRoutedEventArgs e )
{
  e.Cancel = ( this.cancelBeginEdit.IsChecked == true );
  e.Handled = ( this.handledByRowCheckBox.IsChecked == true );
  Debug.WriteLine( sender + ": EditBeginning" );
}
public void EditBegun( object sender, RoutedEventArgs e )
{
  e.Handled = ( this.handledByRowCheckBox.IsChecked ?? true );
  Debug.WriteLine( sender + ": EditBegun" );
}