Possible to access the value of DataFormTextItem?

I'd like to bind a property to the value of the text being inserted by the user. Is it possible to retrieve the text inputted by the user from the underlying Entry control encapsulated by the DataFormTextItem


1 Reply

SS SaiGanesh Sakthivel Syncfusion Team May 18, 2023 01:13 PM UTC

Hi Frederick,


Your requirement can achieve with the help of ValidateProperty event. Inside the event, you can get the editor value. Please refer to the following code snippet for your reference.


Code snippet

private void dataForm_ValidateProperty(object sender, DataFormValidatePropertyEventArgs e)

{

    var value = e.NewValue;

}


And also, you can achieve with the help of GetValue method for DataFormItem in Items class. Please refer to the following code snippet for your reference.


Code snippet

private void Button_Clicked(object sender, EventArgs e)

{

    //// - get the value of the editor

    if (this.dataForm.Items != null)

    {

        foreach (var viewItem in this.dataForm.Items)

        {

            if (viewItem is DataFormItem dataFormItem)

            {

                var value = dataFormItem.GetValue();

            }

        }

    }

}


Please refer to the demo sample in the attachment. Please let us know if you have any concerns.


Regards,
SaiGanesh Sakthivel


Attachment: DataFormMAUI_171632a2.zip

Loader.
Up arrow icon