DataFormMultilineItem Class
Stores settings of the data form’s multi-line text editor.
Namespace: DevExpress.Maui.DataForm
Assembly: DevExpress.Maui.Editors.dll
NuGet Package: DevExpress.Maui.Editors
Declaration
public class DataFormMultilineItem :
DataFormTextItemBase,
ITextEditBaseEditorOwner
Remarks
The DataFormMultilineItem
is a multiline text editor that allows you to edit bound properties of the string and char types. You can add a multiline text editor and modify its properties in XAML or C# code.
The following image shows a Data Form with a multiline text editor:
For a list of all supported editors in the DataFormView, refer to the following topic: Data Form – Editors.
Get Started
The following help topic describes how to create your first app with the DevExpress Data Form component for MAUI:
Define Multiline Text Editor Settings in XAML
Specify the DataFormView.DataObject property to define an object whose properties are to be edited in the DataFormView.
To show a multiline text editor in a DataFormView, add a DataFormMultilineItem
object to the DataFormView.Items collection.
Use the item’s FieldName property to specify the name of a property to be edited in the Data Form.
Note: The DataFormView.Items property is a content property. You can skip the <Items>
tag in your markup.
<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"
x:Class="MultilineEditorSample.MainPage" Shell.NavBarIsVisible="False"
xmlns:local="clr-namespace:MultilineEditorSample">
<dxdf:DataFormView x:Name="dataForm" CommitMode="Input" IsAutoGenerationEnabled="False">
<dxdf:DataFormView.DataObject>
<local:UserInfo/>
</dxdf:DataFormView.DataObject>
<dxdf:DataFormMultilineItem FieldName="UserBio"
HelpText="Add a bio"
LabelText="Bio"
MinLineCount="2"
MaxLineCount="4"
MaxCharacterCountOverflowMode="LimitInput"
MaxCharacterCount="200"
LabelMaxWidth="30"
RowOrder="0"/>
</dxdf:DataFormView>
</ContentPage>
using DevExpress.Maui.DataForm;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace MultilineEditorSample {
public class UserInfo : INotifyPropertyChanged {
// ...
string userBio;
public string UserBio {
get {
return this.userBio;
}
set {
if (value != this.userBio) {
this.userBio = value;
NotifyPropertyChanged();
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public partial class MainPage : ContentPage {
public MainPage() {
InitializeComponent();
dataForm.DataObject = new UserInfo();
}
}
}
Use Attributes to Generate the Editor
You can apply the DataFormMultilineEditorAttribute to the Data Object’s property whose value you want to edit in a text editor in the DataFormView.
Additionally, you can use the DataFormDisplayOptionsAttribute and DataFormItemPositionAttribute to configure display settings for the text editor:
<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"
x:Class="MultilineEditorSample.MainPage" Shell.NavBarIsVisible="False"
xmlns:local="clr-namespace:MultilineEditorSample">
<dxdf:DataFormView x:Name="dataForm" CommitMode="Input" IsAutoGenerationEnabled="True"/>
</ContentPage>
using DevExpress.Maui.DataForm;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using DevExpress.Maui.Editors;
namespace MultilineEditorSample {
public class UserInfo : INotifyPropertyChanged {
string userBio;
[DataFormMultilineEditor(MinLineCount = 2, MaxLineCount = 4,
MaxCharacterCountOverflowMode = OverflowMode.LimitInput, MaxCharacterCount = 200)]
[DataFormDisplayOptions(HelpText = "Add a bio", LabelText = "Bio")]
[DataFormItemPosition (RowOrder = 2)]
public string UserBio {
get {
return this.userBio;
}
set {
if (value != this.userBio) {
this.userBio = value;
NotifyPropertyChanged();
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public partial class MainPage : ContentPage {
public MainPage() {
InitializeComponent();
dataForm.DataObject = new UserInfo();
}
}
}
Validate Input
You can use the following techniques to validate user input values:
Use data annotations.
Handle the DataFormView.ValidateProperty and/or DataFormView.ValidateForm event.
Implement the IDataErrorInfo or INotifyDataErrorInfo interface in the Data Object.
For more information about input data validation, refer to the following help topic: Validate User Input in Data Form.
Manage the Display Item Value
You can use the following methods to specify or obtain the editor value or display text:
- DataFormItem.SetValue(Object newValue) – Specifies the Data Form editor value.
- DataFormItem.GetValue() – Returns the current value of the data form editor.
- DataFormView.GetValue(String propertyName) – Returns the current value of a Data Form editor by the name of the property to which the editor is bound.
Specify Layout
Refer to the following help topic for more information on how to position editors in a DataFormView: