New to Telerik UI for WinUI? Download free 30-day trial

Events

RadDataForm provides a set of events raised on different occassions.

This article lists the data form specific events.

  • AutoGeneratingField: Raised during the automatic creation a data field. The event is raised for each data field that will be created and can be used to modify or replace the field. The event arguments are of type AutoGeneratingFieldEventArgs and provide access to information for the edited property, the display index of the data field and the data field itself.

    Example 1: AutoGeneratingField event handler

        private void RadDataForm_AutoGeneratingField(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e) 
        { 
            DataFormDataField datafield = e.DataField; 
            int? displayIndex = e.Order; 
            string propertyName = e.PropertyName; 
            Type propertyType = e.PropertyType; 
     
            if (propertyName == "PropertyThatShouldNotBePresentedInTheUI") 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • DataFieldPreparedEditor: Raised when the editor of the associated data field was created. The event arguments are of type DataFieldPreparedEditorEventArgs which provide information about the editor and the data field object.

    Example 2: DataFieldPreparedEditor event handler

        private void RadDataForm_DataFieldPreparedEditor(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.DataFieldPreparedEditorEventArgs e) 
        { 
            DataFormDataField datafield = e.DataField; 
            FrameworkElement editor = e.Editor; 
        } 
    
  • CurrentItemChanged: Raised when the currently selected item changes.

  • InitializingNewItem: Raised when a new item creation begins. The event arguments are of type InitializingNewItemEventArgs which allows you to replace or edit the created item, or cancel the creation.

    Example 3: InitializingNewItem event handler

        private void RadDataForm_InitializingNewItem(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.InitializingNewItemEventArgs e) 
        { 
            e.DataItem = new MyDataItem(); 
        } 
    
  • AddingNewItem: Raised when adding a new item using the UI or the control's API. The event arguments are of type AddingNewItemEventArgs which can be used to cancel the item adding.

    Example 4: AddingNewItem event handler

        private void RadDataForm_AddingNewItem(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.AddingNewItemEventArgs e) 
        { 
            if (shouldNotAllowNewItemAdding) 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • AddedNewItem: Raised after a new item was added in the ItemsSource using the UI or the control's API. The event arguments are of type AddedNewItemEventArgs and contain information about the newly added item.

    Example 5: AddedNewItem event handler

        private void RadDataForm_AddedNewItem(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.AddedNewItemEventArgs e) 
        { 
            object addedItem = e.NewItem; 
        } 
    
  • DeletingItem: Raised when deleting an item using the UI or the control's API. The event arguments are of type CancelEventArgs which can be used to cancel the item deletion.

    Example 6: DeletingItem event handler

        private void RadDataForm_DeletingItem(object sender, CancelEventArgs e) 
        { 
            if (shouldNotAllowItemDeleting) 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • DeletedItem: Raised after an item was deleted using the UI or the control's API. The event arguments are of type ItemDeletedEventArgs which provides access to the deleted item.

    Example 7: DeletedItem event handler

        private void RadDataForm_DeletedItem(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.ItemDeletedEventArgs e) 
        { 
            object removedItem = e.DeletedItem; 
        } 
    
  • BeginningEdit: Raised when the editing is beginning. The event arguments are of type CancelEventArgs which can be used to cancel the item edit beginning.

    Example 8: BeginningEdit event handler

        private void RadDataForm_BeginningEdit(object sender, CancelEventArgs e) 
        { 
            if (shouldNotAllowEditStart) 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • EditEnding: Raised when the editing is ending. The event arguments are of type EditEndingEventArgs which can be used to cancel the item edit ending and also to get the edit action (cancel or commit).

    Example 9: EditEnding event handler

        private void RadDataForm_EditEnding(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.EditEndingEventArgs e) 
        { 
            EditAction action = e.EditAction; 
            if (shouldCancelEditEnded) 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • EditEnded: Raised after the editing was ended. The event arguments are of type EditEndedEventArgs which allows you to get the edit action (cancel or commit).

    Example 10: EditEnded event handler

        private void RadDataForm_EditEnded(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.EditEndedEventArgs e) 
        { 
            EditAction action = e.EditAction; 
        } 
    
  • DataFieldBeginningEdit: Raised when the data field editing is beginning. The event arguments are of type DataFieldCancelEventArgs which allows you to cancel the editing and also to get the associated data field object.

    Example 11: DataFieldBeginningEdit event handler

        private void RadDataForm_DataFieldBeginningEdit(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.DataFieldCancelEventArgs e) 
        { 
            DataFormDataField datafield = e.DataField; 
            if (shouldCancelEditStart) 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • DataFieldEditEnded: Raised after the editing was ended. The event arguments are of type DataFieldEditEndedEventArgs which allows you to get the edit action (cancel or commit) and also the previous and new values.

    Example 12: DataFieldEditEnded event handler

        private void dataForm_DataFieldEditEnded(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.DataFieldEditEndedEventArgs e) 
        { 
            DataFormDataField datafield = e.DataField; 
            EditAction action = e.EditAction; 
            object newValue = e.NewValue; 
            object previousValue = e.OldValue; 
        } 
    
  • ValidatingItem: Raised when an item is validating. The event arguments are of type CancelEventArgs which can be used to cancel the item validating.

    Example 13: ValidatingItem event handler

        private void RadDataForm_ValidatingItem(object sender, CancelEventArgs e) 
        { 
            if (shouldCancelItemValidating) 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • DataFieldValidating: Raised when a data field's value is validating. The event arguments are of type DataFieldValidatingEventArgs which provide information about the validation state of the field and also about the new and old value in the editor.

    Example 14: DataFieldValidating event handler

        private void RadDataForm_DataFieldValidating(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.DataFieldValidatingEventArgs e) 
        { 
            DataFormDataField datafield = e.DataField; 
            object newValue = e.NewValue; 
            object previousValue = e.OldValue; 
            IEnumerable<ValidationResult> results = e.ValidationResults; 
     
            if (!isTheDataFieldValid) 
            { 
                e.IsValid = false; 
            }             
        } 
    
  • DataFieldValidated: Raised after the data field validation was finished. The event arguments are of type DataFieldValidatedEventArgs which provide information about the validation results and also the data field object.

    Example 15: DataFieldValidated event handler

        private void RadDataForm_DataFieldValidated(object sender, Telerik.UI.Xaml.Controls.Data.DataForm.DataFieldValidatedEventArgs e) 
        { 
           DataFormDataField datafield = e.DataField; 
           IEnumerable<ValidationResult> results = e.ValidationResults; 
        } 
    

    See Also

  • Getting Started
  • Visual Structure
In this article
Not finding the help you need?