Skip to main content

DataFormCustomItem.EditorValue Property

Gets or sets a value of the data object’s property assigned to the DataFormCustomItem.FieldName. This is a bindable property.

Namespace: DevExpress.Maui.DataForm

Assembly: DevExpress.Maui.Editors.dll

NuGet Package: DevExpress.Maui.Editors

Declaration

public object EditorValue { get; set; }

Property Value

Type Description
Object

An object that specifies the data object’s property value.

Remarks

When you define a custom editor for the data form, you can bind the custom editor property to any property of the data object (it is the binding context of the data form’s custom editors). Note, in this case, the data form’s built-in validate and commit mechanisms are not available for the custom editor. If you need to validate and commit values entered within the custom editor, bind its value property to the EditorValue property.

The following example shows how to validate a custom editor’s input values. A warning hint appears when the Name field contains less than 3 symbols:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:dxdf="clr-namespace:DevExpress.Maui.DataForm;assembly=DevExpress.Maui.Editors"
             xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
             xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
             ios:Page.UseSafeArea="true"
             x:Class= "DXMauiApp.MainPage">
    <ContentPage.Content>
        <dxdf:DataFormView DataObject="{Binding Item}" x:Name="view" IsAutoGenerationEnabled="False" 
                           ValidationMode="Input" ValidateProperty="view_ValidateProperty">
            <dxdf:DataFormCustomItem FieldName="Name" x:Name="item">
                <dxe:TextEdit Text="{Binding Source={x:Reference item}, Path=EditorValue, Mode=TwoWay}" LabelText="CustomItem"/>
            </dxdf:DataFormCustomItem>
        </dxdf:DataFormView>
    </ContentPage.Content>
</ContentPage>
using DevExpress.Maui.DataForm;
namespace DXMauiApp {
    public partial class MainPage : ContentPage {
        public MainPage() {
            InitializeComponent();
            this.BindingContext = this;

        }
        public Item Item { get; set; } = new Item() { Id = 123, Name = "Alice" };
        private void view_ValidateProperty(object sender, DataFormPropertyValidationEventArgs e) {
            if (e.PropertyName == "Name") {
                if (e.NewValue.ToString().Length <= 2) {
                    e.HasError = true;
                    e.ErrorText = "The name should contain more than 2 symbols.";
                }
            }
        }
    }
    public class Item {
        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime Date { get; set; } = new DateTime(2001, 1, 1);
    }
}
See Also