Customize the visual appearance of read-only data form editor in Xamarin.iOS.
You can customize the visual appearance of read-only data form editor using the Alpha property of UIView for SfDataForm in-built editor.
You should register the editor in data form item.
dataForm.RegisterEditor("Text", new DataFormTextEditorExt(dataForm));
Set the ReadOnly property for required data form item using the AutoGeneratingDataFormItem event.
dataForm.AutoGeneratingDataFormItem += OnAutoGeneratingDataFormItem;
private void OnAutoGeneratingDataFormItem(object sender, AutoGeneratingDataFormItemEventArgs e)
{
if (e.DataFormItem.Name == "Address")
{
e.DataFormItem.IsReadOnly = true;
}
}
You can customize the visual appearance of in-built editor by changing the Alpha property value in OnInitializeView override method of each editor to initialize view for the data form editor.
public class DataFormTextEditorExt : DataFormTextEditor
{
public DataFormTextEditorExt(SfDataForm dataForm) : base(dataForm)
{
}
protected override void OnInitializeView(DataFormItem dataFormItem, UITextField view)
{
base.OnInitializeView(dataFormItem, view);
if (dataFormItem.IsReadOnly)
{
// you can set alpha value for changing the visual appearance for the non-editable DataFormItem
view.Alpha = (nfloat)0.5;
}
}
}
Output:

Click here to download the sample.