Class SfDockLayout
Arranges child elements using a docking pattern, allowing a flexible layout design.
Inheritance
Namespace: Syncfusion.Maui.Core
Assembly: Syncfusion.Maui.Core.dll
Syntax
public class SfDockLayout : Layout
Remarks
The SfDockLayout allows positioning of child elements by docking them to the container.
Docking Positions
Use the Dock property to determine where to position child elements: Top, Bottom, Left, Right, or None.
<dx:SfDockLayout>
<Label Text="Top Docked"
dx:SfDockLayout.Dock="Top"
BackgroundColor="LightBlue"/>
<Label Text="Bottom Docked"
dx:SfDockLayout.Dock="Bottom"
BackgroundColor="LightCoral"/>
<Label Text="Left Docked"
dx:SfDockLayout.Dock="Left"
BackgroundColor="LightGreen"/>
<Label Text="Right Docked"
dx:SfDockLayout.Dock="Right"
BackgroundColor="LightGoldenrodYellow"/>
<Label Text="Fill Remaining"
dx:SfDockLayout.Dock="None"
BackgroundColor="LightGray"/>
</dx:SfDockLayout>
Constructors
SfDockLayout()
Declaration
public SfDockLayout()
Fields
DockProperty
Identifies the Dock attached property for a View, determining the docking position of a child view within the SfDockLayout, such as None, Left, Top, Right, or Bottom.
Declaration
public static readonly BindableProperty DockProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
HorizontalSpacingProperty
Sets the HorizontalSpacing between the docked views in the layout.
Declaration
public static readonly BindableProperty HorizontalSpacingProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ShouldExpandLastChildProperty
Determines whether the last child in the layout should automatically expand to fill the remaining space. The default value is true.
Declaration
public static readonly BindableProperty ShouldExpandLastChildProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
VerticalSpacingProperty
Sets the VerticalSpacing between the docked views in the layout.
Declaration
public static readonly BindableProperty VerticalSpacingProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Properties
HorizontalSpacing
Gets or sets the horizontal gap between child elements within the layout.
Declaration
public double HorizontalSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A System.Double value that specifies the spacing between elements horizontally. |
Remarks
This property controls the amount of horizontal space between elements in the layout.
It helps manage consistent spacing and alignment, particularly when creating adaptive UIs.
Examples
<dx:SfDockLayout HorizontalSpacing="10">
</dx:SfDockLayout>
ShouldExpandLastChild
Gets or sets a value indicating whether the last visible child in the SfDockLayout should expand to fill the remaining available space.
Declaration
public bool ShouldExpandLastChild { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean value that determines whether the last child expands to occupy unused layout space. |
Remarks
When set to true
, any unoccupied space in the layout is automatically assigned to the last visible child.
This is useful for creating responsive and adaptive layouts that scale gracefully to different screen sizes.
Examples
<dx:SfDockLayout ShouldExpandLastChild="True">
<Label Text="Header" dx:SfDockLayout.Dock="Top" />
<Label Text="Footer" dx:SfDockLayout.Dock="Bottom" />
<Label Text="Sidebar" dx:SfDockLayout.Dock="Left" />
<Label Text="Content Area" />
</dx:SfDockLayout>
VerticalSpacing
Gets or sets the vertical gap between child elements within the layout.
Declaration
public double VerticalSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A System.Double value that specifies the spacing between elements vertically. |
Remarks
This property controls the amount of vertical space between elements in the layout.
It ensures proper visual separation and improves the readability and usability of the interface.
Examples
<dx:SfDockLayout VerticalSpacing="8">
</dx:SfDockLayout>
Methods
CreateLayoutManager()
Initializes a layout manager to control the arrangement of children within a DockLayout.
Declaration
protected override ILayoutManager CreateLayoutManager()
Returns
Type | Description |
---|---|
Microsoft.Maui.Layouts.ILayoutManager | An instance of SfDockLayoutManager to manage layout logic. |
GetDock(BindableObject)
Retrieves the docking position for a specified view within the layout.
Declaration
public static Dock GetDock(BindableObject view)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Maui.Controls.BindableObject | view | The targeted child view for docking evaluation. |
Returns
Type | Description |
---|---|
Dock | The current docking position of the child view. |
SetDock(BindableObject, Dock)
Assigns a specific docking position to a child element within the layout.
Declaration
public static void SetDock(BindableObject view, Dock position)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Maui.Controls.BindableObject | view | The targeted child view for docking adjustment. |
Dock | position | The designated docking position to assign. |