Back to Devexpress

DocumentPreviewControl.ShowingEditingFieldEditor Event

wpf-devexpress-dot-xpf-dot-printing-dot-documentpreviewcontrol-9449c785.md

latest7.4 KB
Original Source

DocumentPreviewControl.ShowingEditingFieldEditor Event

Occurs when the editor for the edit field is about to be shown. Allows you to prevent the editor from being displayed.

Namespace : DevExpress.Xpf.Printing

Assembly : DevExpress.Xpf.Printing.v25.2.dll

NuGet Package : DevExpress.Wpf.Printing

Declaration

csharp
public event ShowingEditingFieldEditorEventHandler ShowingEditingFieldEditor
vb
Public Event ShowingEditingFieldEditor As ShowingEditingFieldEditorEventHandler

Event Data

The ShowingEditingFieldEditor event's data class is ShowingEditingFieldEditorEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value that indicates whether the editor should be opened.
EditingFieldGets the edit field for which the event is raised. Inherited from EditingFieldEditorEventArgsBase.
HandledGets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
SourceGets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.

The event data class exposes the following methods:

MethodDescription
InvokeEventHandler(Delegate, Object)When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs.
OnSetSource(Object)When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs.

Remarks

The following code prevents the editors for the Check Box and Picture Box fields from being displayed:

xaml
<Window x:Class="ValidateEditingFields_MVVM.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ValidateEditingFields_MVVM"
        xmlns:dxp="http://schemas.devexpress.com/winfx/2008/xaml/printing"
        xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
        Title="MainWindow" Height="450" Width="800">
    <Window.DataContext>
        <local:ViewModel />
    </Window.DataContext>
    <Grid>
        <dxp:DocumentPreviewControl RequestDocumentCreation="True"
                                    DocumentSource="{Binding Report}"
                                    HighlightEditingFields="True">
            <dxmvvm:Interaction.Behaviors>
                <dxmvvm:EventToCommand Event="{x:Static dxp:DocumentPreviewControl.ShowingEditingFieldEditorEvent}"
                                       PassEventArgsToCommand="True"
                                       Command="{Binding OnShowingEditingFieldEditorCommand}" />
            </dxmvvm:Interaction.Behaviors>
        </dxp:DocumentPreviewControl>
    </Grid>
</Window>
csharp
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Xpf.Printing;
using DevExpress.XtraReports.UI;
using System;

namespace ValidateEditingFields_MVVM {
    public class ViewModel : ViewModelBase {
        [Command]
        public void OnShowingEditingFieldEditor(ShowingEditingFieldEditorEventArgs args) {
            if(args.EditingField.ID == "CheckField" || args.EditingField.ID == "ImageField")
                args.Cancel = true;
        }
    }
}
vb
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.DataAnnotations
Imports DevExpress.Xpf.Printing
Imports DevExpress.XtraReports.UI
Imports System

Namespace ValidateEditingFields_MVVM
    Public Class ViewModel
        Inherits ViewModelBase
        <Command>
        Public Sub OnShowingEditingFieldEditor(ByVal args As ShowingEditingFieldEditorEventArgs)
            If args.EditingField.ID = "CheckField" OrElse args.EditingField.ID = "ImageField" Then
                args.Cancel = True
            End If
        End Sub
    End Class
End Namespace

View Example: How to Validate the Editing Field Value in the Document Preview

See Also

DocumentPreviewControl Class

DocumentPreviewControl Members

DevExpress.Xpf.Printing Namespace