Syncfusion AI Assistant

How can I help you?

Form Field Events in .NET MAUI PDF Viewer (SfPdfViewer)

25 Mar 20262 minutes to read

The SfPdfViewer exposes events that allow you to track and respond to user interactions with form fields, such as value changes and focus changes.

Detect value changes

The FormFieldValueChanged event is raised whenever the value of a form field changes. You can use the OldValue and NewValue properties of FormFieldValueChangedEventArgs to read the before and after values.

Subscribe to the event in XAML:

<syncfusion:SfPdfViewer x:Name="pdfViewer"
                        FormFieldValueChanged="PdfViewer_FormFieldValueChanged"/>

Handle the event in code:

private void PdfViewer_FormFieldValueChanged(object? sender, FormFieldValueChangedEventArgs? e)
{
    if (e != null && e.FormField is TextFormField textFormField)
    {
        // Read the previous and current values.
        string? oldText = e.OldValue?.ToString();
        string? newText = e.NewValue?.ToString();
    }
}

NOTE

The OldValue and NewValue types vary by field type. For a checkbox, cast them to bool to read the checked state. For a combo box or radio button, cast them to string.

Detect focus and unfocus

The FormFieldFocusChanged event is raised when a text or signature field gains or loses focus. Use the HasFocus property to determine whether the field is being focused or unfocused.

Subscribe to the event in XAML:

<syncfusion:SfPdfViewer x:Name="pdfViewer"
                        FormFieldFocusChanged="PdfViewer_FormFieldFocusChanged"/>

Handle the event in code:

private void PdfViewer_FormFieldFocusChanged(object? sender, FormFieldFocusChangedEvenArgs? e)
{
    if (e != null)
    {
        FormField? field = e.FormField;
        bool hasFocus = e.HasFocus;
    }
}

NOTE

FormFieldFocusChanged is raised only for text and signature form fields.

See Also