wpf-devexpress-dot-xpf-dot-layoutcontrol-dot-layoutitem.md
Gets or sets a label for the current LayoutItem. This is a dependency property.
Namespace : DevExpress.Xpf.LayoutControl
Assembly : DevExpress.Xpf.LayoutControl.v25.2.dll
NuGet Package : DevExpress.Wpf.LayoutControl
public object Label { get; set; }
Public Property Label As Object
| Type | Description |
|---|---|
| Object |
An object that represents a label for the current LayoutItem.
|
Typically, you assign a text string to the Label property. However, you can assign any object to the Label property, and then specify how the object should be rendered via the LayoutItem.LabelTemplate property.
A label’s style can be customized via the LayoutItem.LabelStyle property.
The following code shows how to change the styles of labels for individual layout items, or all of them. The style is changed via the LayoutItem.LabelStyle property. Styles of layout items’ labels can be customized via the LayoutItem.LabelStyle property. This example demonstrates two approaches to changing the LabelStyle property:
The following image shows the result:
<Window
x:Class="LabelStyle.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<!--The default style for layout items: labels are painted in blue-->
<Style x:Key="DefaultLayoutItemStyle" TargetType="lc:LayoutItem">
<Setter Property="LabelStyle">
<Setter.Value>
<Style TargetType="lc:LayoutItemLabel">
<Setter Property="Foreground" Value="#FF0000FF" />
</Style>
</Setter.Value>
</Setter>
<Setter Property="ElementSpace" Value="8" />
</Style>
<!--A custom style to paint labels in red-->
<Style x:Key="MyLabelStyle" TargetType="lc:LayoutItemLabel">
<Setter Property="Foreground" Value="#FFFF0000" />
</Style>
</Window.Resources>
<!--Apply the default style to layout items-->
<lc:LayoutControl x:Name="LayoutRoot" ItemStyle="{StaticResource DefaultLayoutItemStyle}">
<!--Apply the custom style to the first layout item-->
<lc:LayoutGroup Header="Group 1" View="GroupBox" Orientation="Vertical">
<lc:LayoutItem Label="Model:" LabelStyle="{StaticResource MyLabelStyle}">
<TextBlock Text="530i" />
</lc:LayoutItem>
<lc:LayoutItem Label="HP:">
<TextBlock Text="225" />
</lc:LayoutItem>
<lc:LayoutItem Label="# of Gears:">
<TextBlock Text="5" />
</lc:LayoutItem>
</lc:LayoutGroup>
</lc:LayoutControl>
</Window>
The following code snippets (auto-collected from DevExpress Examples) contain references to the Label property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
<dxlc:LayoutGroup Orientation="Vertical">
<dxlc:LayoutItem AddColonToLabel="True" Label="First Name">
<dxe:TextEdit EditValue="{Binding Path=FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
wpf-data-grid-implement-crud-operations/CS/CodeBehind/EFCore/ServerMode/IssueDetailView.xaml#L11
<dxlc:DataLayoutItem Binding="{Binding Item.Subject}" />
<dxlc:LayoutItem Label="User">
<dxe:ComboBoxEdit EditValue="{Binding Item.UserId}" ItemsSource="{Binding EditOperationContext.Users}"
<!--Subject-->
<dxlc:LayoutItem Label="Patient name:">
<dxe:TextEdit x:Name="subjectEdit" EditValue="{Binding Subject, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
reporting-wpf-wizard-custom-page/CS/App.xaml#L20
<dxlc:LayoutGroup Orientation="Vertical">
<dxlc:LayoutItem Label="Orientation: " LabelVerticalAlignment="Top">
<UniformGrid Columns="2" Rows="1" Grid.Column="2" Margin="0,0,0,12">
reporting-wpf-report-designer-customize-controls-smart-tag/CS/App.xaml#L22
<DataTemplate x:Key="dataBindingTemplate">
<dxlc:LayoutItem x:Name="DataBindings" Label="{dxrud:ReportDesignerStringId StringId=Properties_DataBinding}">
<dxrude:PopupTreeListEdit EditValue="{Binding ProgressBinding, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
See Also