We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfDataForm - who to exclude readonly properties of an DataObject -- public double Sum {get => 1+1;}

how can i exlude readonly properties of a DataObject from the form

example property:

public double Sum {get => 1+1;}

3 Replies

SS SaiGanesh Sakthivel Syncfusion Team April 7, 2023 05:56 AM UTC

Hi Andreas,

#Regarding ReadOnly property of the dataform editors

we have documented ‘How to set the readonly property for dataform editor in MAUI DataForm’ in our user guidance document. Please refer to the following UG documentation for your reference.  

UG: https://help.syncfusion.com/maui/dataform/editing?cs-save-lang=1&cs-lang=csharp#using-attribute


Please let us know if you have any concerns.

SaiGanesh Sakthivel

AN Andreas April 7, 2023 07:01 AM UTC

yes but i want to have a way to completely remove them from the dataform.

or in a more general way, a way to specify that only some properties are visible in the dataform.

since the DataObject comes from a libary i can not / want not to add Attributes to the class.

so maybe a way like if i use the  OnGenerateDataFormItem event to hide/remove selected properties from the DataForm

SS SaiGanesh Sakthivel Syncfusion Team April 10, 2023 06:50 AM UTC


Your requirement can be achieved with the help of the GenerateDataFormItem event. Inside the event, we can check if the property of the model property is CanWrite or not and change the corresponding dataform editor's IsReadOnly or IsVisible property. Please refer to the code snippet for your reference.

Code Snippet

private void dataForm_GenerateDataFormItem(object sender, GenerateDataFormItemEventArgs e)


    if (e.DataFormItem != null)


        var canWrite = dataForm.DataObject.GetType().GetProperty(e.DataFormItem.FieldName).CanWrite;

        if (!canWrite)


            //// - set the IsReadOnly property to true

            e.DataFormItem.IsReadOnly = true;

            //// - set the IsVisible property to false

            e.DataFormItem.IsVisible = false;




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

Attachment: DataFormMAUI_35142c37.zip

Live Chat Icon For mobile
Up arrow icon