Represents a specialized layout panel that arranges two child elements (an image element and a text element) with configurable positioning and alignment.
ImageAndTextLayoutPanel extends LayoutPanel to provide sophisticated layout capabilities specifically designed for image and text combinations commonly found in buttons, menu items, list items, and similar UI elements. The panel can arrange the image and text in various spatial relationships such as side-by-side, stacked, or overlaid configurations.
The layout panel supports different display styles including image-only, text-only, or combined image and text display. Each element can be independently aligned within its allocated space using standard ContentAlignment values, and their relative positioning is controlled through the TextImageRelation property.
This layout panel is commonly used in controls like buttons, toolstrip items, menu items, and tree nodes where consistent image and text arrangement is required across multiple instances.
Definition
Namespace:Telerik.WinControls.Layouts
Assembly:Telerik.WinControls.dll
Syntax:
public class ImageAndTextLayoutPanel : LayoutPanel, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IStylableNode
Inheritance: objectDisposableObjectRadObjectRadElementLayoutPanelImageAndTextLayoutPanel...
Derived Classes:
Implements:
Inherited Members
Constructors
public ImageAndTextLayoutPanel()
Fields
Identifies the property that controls whether the image, text, both, or neither are displayed.
public static RadProperty DisplayStyleProperty
Identifies the property that aligns the image child within its allocated region.
public static RadProperty ImageAlignmentProperty
Identifies the property used to mark a child as the image element.
public static RadProperty IsImagePrimitiveProperty
Identifies the property used to mark a child as the text element.
public static RadProperty IsTextPrimitiveProperty
Identifies the property that aligns the text child within its allocated region.
public static RadProperty TextAlignmentProperty
Identifies the property that controls whether the image and text are overlaid or placed relative to one another.
public static RadProperty TextImageRelationProperty
Properties
Gets or sets which elements should be displayed in the layout panel.
public DisplayStyle DisplayStyle { get; set; }
A DisplayStyle value that determines which elements are visible. The default value is ImageAndText.
This property controls the visibility of the image and text elements:
- None: Neither image nor text is displayed
- Image: Only the image element is displayed
- Text: Only the text element is displayed
- ImageAndText: Both image and text elements are displayed
The layout calculations automatically adjust based on which elements are visible.
Gets or sets the alignment of the image element within its allocated space.
public ContentAlignment ImageAlignment { get; set; }
A ContentAlignment value that specifies where the image should be positioned. The default value is MiddleLeft.
This property determines how the image element is positioned within the space allocated to it by the layout calculation. The alignment is relative to the image's designated area, not the entire panel.
Gets or sets the alignment of the text element within its allocated space.
public ContentAlignment TextAlignment { get; set; }
A ContentAlignment value that specifies where the text should be positioned. The default value is MiddleLeft.
This property determines how the text element is positioned within the space allocated to it by the layout calculation. The alignment is relative to the text's designated area, not the entire panel.
Gets or sets the spatial relationship between the image and text elements.
public TextImageRelation TextImageRelation { get; set; }
A TextImageRelation value that specifies how the image and text should be positioned relative to each other. The default value is Overlay.
This property controls the fundamental layout relationship between the image and text elements:
- ImageAboveText: Image is positioned above the text
- ImageBeforeText: Image is positioned to the left of the text
- TextAboveImage: Text is positioned above the image
- TextBeforeImage: Text is positioned to the left of the image
- Overlay: Image and text overlap in the same space
Methods
Places and aligns the image and text children within the panel's client rectangle.
Clears the cached image and text child references before releasing base resources.
protected override void DisposeManagedResources()
Overrides:
Measures the image and text children according to their configured relation.
protected override SizeF MeasureOverride(SizeF availableSize)
The space available for the children.
Returns:The combined desired size, summing the dimensions along the relation axis and taking the larger child dimension across the other axis; overlaid children use the larger width and height.
Overrides:
Updates the cached image or text child when the child collection changes, then reapplies display visibility.
protected override void OnChildrenChanged(RadElement child, ItemsChangeOperation changeOperation)
The child involved in the collection change.
changeOperationItemsChangeOperationThe kind of collection change.
Overrides:
Applies the configured child alignments and display style after the panel is loaded.
protected override void OnLoaded()
Overrides:
Once loaded, updates child visibility for display-style changes and child alignment for alignment-property changes.
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
The property change details.
Overrides: