maui-404720-form-items-custom-appearance.md
Use properties listed in this topic to configure the appearance of FormItem elements.
Properties in this section customize a form item’s primary text (header):
TextSpecifies the content of a form item’s primary text.TextColorSpecifies the form item text’s color.TextFontAttributesDefines font attributes for the form item’s text. You can use the following options: Bold, Italic, or None.TextFontFamilySpecifies the text’s font name. You can only use fonts previously registered in the app. For more information, refer to: Register Fonts.TextFontSizeDefines the text’s font size.TextLineBreakModeSpecifies the line break mode for a font item’s text.TextMarginAllows you to set the gaps between the text and other form item elements.TextMaxLineCountDefines the maximum number of text lines.
The markup below adds a text header to a form item and specifies text settings:
<dxe:FormItem Text="Brightness level"
TextColor="Gray"
TextFontAttributes="Bold"
TextFontFamily="OpenSansRegular"
TextFontSize="18"
TextLineBreakMode="CharacterWrap"
TextMargin="4"
TextMaxLineCount="2"/>
The Detail is the form item’s secondary text (description). Use the following properties to specify a form item’s detail text and configure its appearance:
DetailSpecifies the content of a form item’s secondary text.DetailColorSpecifies the form item detail’s color.DetailFontAttributesDefines font attributes for the form item’s detail. You can use the following options: Bold, Italic, or None.DetailFontFamilySpecifies the detail’s font name. You can only use fonts previously registered in the app. For more information, refer to: Register Fonts.DetailFontSizeDefines the detail’s font size.DetailLineBreakModeSpecifies the line breaking mode for a font item’s detail.DetailMarginAllows you to set the gaps between the detail and other form item elements.DetailMaxLineCountDefines the maximum number of detail lines.
The markup below adds secondary text for a form item and configures text options :
<dxe:FormItem Detail="The reading mode adjusts colors and
textures in order to reduce eye strain."
DetailColor="LightGray"
DetailFontAttributes="Italic"
DetailFontFamily="OpenSansRegular"
DetailFontSize="14"
DetailLineBreakMode="TailTruncation"
DetailMargin="4"
DetailMaxLineCount="2"/>
You can use the following properties to specify and configure a form item’s image (icon):
Specifies the image source. In XAML, use the name of an image in the Resources/Images folder to define the source. Ensure that the image’s Build Action is MauiImage.
For more information about images, refer to the following page: Add images to a .NET MAUI app project.
ImageColorDefines the tint color of the form item’s image.ImageHeightSpecifies the height of the form item’s image.ImageWidthSpecifies the width of the form item’s image.ImageMarginAllows you to set the gaps between the image and other form item elements.ImageVerticalOptionsSpecifies how the image is positioned vertically. You can use the following options: Fill, Center, Start, and End.ImageTemplateDefines a template that configures image appearance.
The following example configures image settings:
<dxe:FormItem Text="Brightness level"
TextMargin="4,4,4,16"
InlineContent="80%"
ShowArrow="True"
ImageSource="brightness"
ImageColor="#F9C938"
ImageHeight="36"
ImageWidth="36"
ImageMargin="4"
ImageVerticalOptions="Start">
</dxe:FormItem>
The following example shows how to create a DataTemplate to customize the image’s content:
<ContentPage ...
xmlns:dxco="clr-namespace:DevExpress.Maui.Controls;assembly=DevExpress.Maui.Controls"
...>
<ScrollView>
<VerticalStackLayout>
<dxe:FormItem Text="Brightness level"
TextMargin="4,4,4,16"
InlineContent="80%"
ShowArrow="True">
<dxe:FormItem.ImageTemplate>
<DataTemplate>
<Border StrokeThickness="2" Stroke="LightGray"
WidthRequest="50" HeightRequest="50"
VerticalOptions="Start">
<dxco:DXImage Source="brightness"
TintColor="#F9C938"
WidthRequest="30"
HeightRequest="30"/>
</Border>
</DataTemplate>
</dxe:FormItem.ImageTemplate>
</dxe:FormItem>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
An Arrow indicates that a user can tap the form item to perform an action. Use the following properties to display the arrow and customize it:
ShowArrowSpecifies whether to show the form item’s arrow.ArrowColorSets the arrow’s fill color.ArrowTemplateSpecifies a template that configures the arrow’s appearance.ArrowMarginAllows you to set the gaps between the arrow and other form item elements.ArrowVerticalOptionsSpecifies how the arrow is positioned vertically. You can use the following options: Fill, Center, Start, and End.
The following markup customizes the default arrow’s settings for a Form Item:
<dxe:FormItem ShowArrow="True"
ArrowColor="Gray"
ArrowMargin="10"
ArrowVerticalOptions="Center"/>
The following markup shows how to replace the default arrow icon with a custom icon:
<dxe:FormItem ...
ShowArrow="True">
<dxe:FormItem.ArrowTemplate>
<DataTemplate>
<dxco:DXImage Source="rightarrow"
WidthRequest="30"
HeightRequest="30"
TintColor="Coral" />
</DataTemplate>
</dxe:FormItem.ArrowTemplate>
</dxe:FormItem>
The Separator is a line that separates form items. The settings below allow you to show a form item’s separator and define its appearance:
ShowSeparatorSpecifies whether the separator is visible.SeparatorColorDefines the separator’s fill color.SeparatorThicknessSpecifies the separator’s thickness.
<dxe:FormItem ShowSeparator="True"
SeparatorColor="LightGray"
SeparatorThickness="1">
The form item displays Inline Content to the left of the arrow. Inline content can contain any image and/or text. Use the following properties to customize this element:
InlineContentSpecifies the content of a form item’s inline content.InlineContentTemplateDefines the template that specifies the appearance of the inline content.
The example below shows how to create a template that changes the text color for inline content:
<ContentPage.Resources>
<DataTemplate x:Key="inlineContentTemplate">
<Label Text="{Binding}" TextColor="#999999"/>
</DataTemplate>
</ContentPage.Resources>
<ScrollView>
<VerticalStackLayout>
<dxe:FormItem ...
InlineContent="60 Hz"
InlineContentTemplate="{StaticResource inlineContentTemplate}"/>
</VerticalStackLayout>
</ScrollView>
You can show any content in a form item. Use the following properties to specify the content and configure its appearance:
ContentSpecifies the form item’s content.ContentTemplateSets the template that configures the content’s appearance.
The following example shows how to create a form item with custom content:
<dxe:FormItem ShowSeparator="True" Padding="10,20">
<dxe:FormItem.ContentTemplate>
<DataTemplate>
<Frame BorderColor="Gray" BackgroundColor="#20606060" CornerRadius="10">
<VerticalStackLayout>
<Label Text="Need other settings?" />
<Label Text="Font settings" TextColor="CornflowerBlue">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
</Label.GestureRecognizers>
</Label>
<Label Text="Status bar settings" TextColor="CornflowerBlue">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</Label.GestureRecognizers>
</Label>
</VerticalStackLayout>
</Frame>
</DataTemplate>
</dxe:FormItem.ContentTemplate>
</dxe:FormItem>