New to Telerik UI for .NET MAUIStart a free 30-day trial

.NET MAUI SmartPasteButton Integration with DataForm

Updated on Apr 16, 2026

The SmartPasteButton control has an integration to work with the DataForm control, allowing you to populate form fields with structured data extracted from unstructured text. By integrating the SmartPasteButton with the DataForm, you can enhance the user experience and streamline data entry processes within your application.

To integrate the SmartPasteButton with the DataForm, you need to set the Provider property of the SmartPasteButton to reference the DataForm instance. This allows the SmartPasteButton to extract structured information from the clipboard content and populate the corresponding fields in the DataForm based on the form structure.

The following snippet shows how to set the Provider property of the SmartPasteButton to reference a DataForm instance in XAML:

XAML
<telerik:RadDataForm x:Name="dataForm" ... />

<telerik:RadSmartPasteButton Provider="{x:Reference dataForm}" ... />

The following example demonstrates the SmartPasteButton and DataForm integration:

1. Define the DataForm and the SmartPasteButton controls on the page:

XAML
<telerik:RadSmartPasteButton Provider="{x:Reference dataForm}"
                             SmartPasteRequest="OnSmartPasteRequest" />

2. Add the DataForm control to your page. The SmartPasteButton is designed to work in conjunction with the DataForm control, allowing you to easily populate form fields with structured data extracted from unstructured text. By integrating the SmartPasteButton with the DataForm, you can enhance the user experience and streamline data entry processes within your application.

XAML
<telerik:RadDataForm x:Name="dataForm"
                     AutoGenerateItems="False" 
                     Grid.Row="1">
    <telerik:RadDataForm.BindingContext>
        <local:Profile />
    </telerik:RadDataForm.BindingContext>
    <telerik:DataFormRadEntryEditor PropertyName="Name" />
    <telerik:DataFormRadEmailMaskedEditor PropertyName="Email" />
    <telerik:DataFormRadEntryEditor PropertyName="JobTitle" />
    <telerik:DataFormRadEntryEditor PropertyName="Address" />
</telerik:RadDataForm>

3. Text from the clipboard is used for the smart paste operation.

XAML
<telerik:RadTemplatedButton Content="Copy To Clipboard"
                            Clicked="OnCopyFromClipboardClicked"/>

4. Add the telerik namespace:

XAML
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"

5. Define the copy button's Clicked event handler:

C#
private async void OnCopyFromClipboardClicked(object sender, System.EventArgs e)
{
    if (!string.IsNullOrEmpty(this.label.Text))
    {
        await Clipboard.SetTextAsync(this.label.Text);
    }
}

6. The SmartPasteRequest event handler:

C#
private async void OnSmartPasteRequest(object sender, SmartPasteButtonRequestContext e)
{
    try
    {
        var request = new { Content = e.Content, FormFields = e.Fields };
        var httpResponse = await new HttpClient().PostAsJsonAsync(
            "https://demos.telerik.com/service/v2/ai/smartpaste/smartpaste",
            request,
            e.CancellationToken);
        httpResponse.EnsureSuccessStatusCode();

        var response = await httpResponse.Content.ReadFromJsonAsync<SmartPasteResponse>(e.CancellationToken);
        e.SetResponse(response.FieldValues);
    }
    catch (OperationCanceledException)
    {
        e.Cancel();
    }
    catch (Exception ex)
    {
        e.SetError(ex);
    }
}

.NET MAUI SmartPasteButton Getting Started

The SmartPasteButton examples in the SDKBrowser Demo Application use a Telerik-hosted AI service for demonstration purposes only.

To use the smart paste functionality in your application, you must configure your own AI service.

How to do that is described in the Configuration article.

For a runnable example with the SmartPasteButton Integration with DataForm, see the SDKBrowser Demo Application and go to SmartPasteButton > Getting Started.

See Also

In this article
See Also
Not finding the help you need?
Contact Support