Class DiagramMargin
Represents the extra space around the outer boundaries of diagram elements in the SfDiagramComponent.
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class DiagramMargin : OwningComponentBase
Remarks
The DiagramMargin class provides properties to define spacing on all four sides of diagram elements such as nodes, connectors, and user handles. This margin creates additional space between the element's content and its boundaries.
All margin values are specified in pixels and default to 0.
Examples
This example demonstrates how to create and configure margin settings for a diagram element.
// Create a new margin with specific values
DiagramMargin margin = new DiagramMargin();
margin.Left = 10;
margin.Right = 15;
margin.Top = 5;
margin.Bottom = 20;
// Use margin in a connector's fixed user handle
Connector connector = new Connector()
{
FixedUserHandles = new DiagramObjectCollection<ConnectorFixedUserHandle>()
{
new ConnectorFixedUserHandle()
{
Padding = margin
}
}
};
Constructors
DiagramMargin()
Initializes a new instance of the DiagramMargin.
Declaration
public DiagramMargin()
DiagramMargin(DiagramMargin)
Creates a new instance of the DiagramMargin from the given DiagramMargin.
Declaration
public DiagramMargin(DiagramMargin src)
Parameters
Type | Name | Description |
---|---|---|
DiagramMargin | src | The source DiagramMargin instance to copy from. |
Properties
Bottom
Gets or sets the extra space at the bottom side of the diagram element.
Declaration
public double Bottom { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A System.Double representing the bottom margin in pixels. The default value is |
Remarks
The bottom margin creates additional space between the element's bottom boundary and its content.
Examples
Connector connector = new Connector()
{
FixedUserHandles = new DiagramObjectCollection<ConnectorFixedUserHandle>()
{
new ConnectorFixedUserHandle()
{
Padding = new DiagramMargin() { Bottom = 20 }
}
}
};
BottomChanged
Gets or sets the callback that is invoked when the Bottom margin value changes.
Declaration
public EventCallback<double> BottomChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Double> | An Microsoft.AspNetCore.Components.EventCallback<> of type System.Double that handles notifications when the bottom margin value is modified. The default value is an empty callback. |
Remarks
This property allows parent components to receive notifications when the bottom margin value changes, enabling two-way data binding scenarios.
Left
Gets or sets the extra space at the left side of the diagram element.
Declaration
public double Left { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A System.Double representing the left margin in pixels. The default value is |
Remarks
The left margin creates additional space between the element's left boundary and its content.
Examples
Connector connector = new Connector()
{
FixedUserHandles = new DiagramObjectCollection<ConnectorFixedUserHandle>()
{
new ConnectorFixedUserHandle()
{
Padding = new DiagramMargin() { Left = 10 }
}
}
};
LeftChanged
Gets or sets the callback that is invoked when the Left margin value changes.
Declaration
public EventCallback<double> LeftChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Double> | An Microsoft.AspNetCore.Components.EventCallback<> of type System.Double that handles notifications when the left margin value is modified. The default value is an empty callback. |
Remarks
This property allows parent components to receive notifications when the left margin value changes, enabling two-way data binding scenarios.
Right
Gets or sets the extra space at the right side of the diagram element.
Declaration
public double Right { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A System.Double representing the right margin in pixels. The default value is |
Remarks
The right margin creates additional space between the element's right boundary and its content.
Examples
Connector connector = new Connector()
{
FixedUserHandles = new DiagramObjectCollection<ConnectorFixedUserHandle>()
{
new ConnectorFixedUserHandle()
{
Padding = new DiagramMargin() { Right = 15 }
}
}
};
RightChanged
Gets or sets the callback that is invoked when the Right margin value changes.
Declaration
public EventCallback<double> RightChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Double> | An Microsoft.AspNetCore.Components.EventCallback<> of type System.Double that handles notifications when the right margin value is modified. The default value is an empty callback. |
Remarks
This property allows parent components to receive notifications when the right margin value changes, enabling two-way data binding scenarios.
Top
Gets or sets the extra space at the top side of the diagram element.
Declaration
public double Top { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A System.Double representing the top margin in pixels. The default value is |
Remarks
The top margin creates additional space between the element's top boundary and its content. This value affects the overall height calculation of the element.
Negative values are not recommended as they may cause layout issues.
Examples
Connector connector = new Connector()
{
FixedUserHandles = new DiagramObjectCollection<ConnectorFixedUserHandle>()
{
new ConnectorFixedUserHandle()
{
Padding = new DiagramMargin() { Top = 5 }
}
}
};
TopChanged
Gets or sets the callback that is invoked when the Top margin value changes.
Declaration
public EventCallback<double> TopChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Double> | An Microsoft.AspNetCore.Components.EventCallback<> of type System.Double that handles notifications when the top margin value is modified. The default value is an empty callback. |
Remarks
This property allows parent components to receive notifications when the top margin value changes, enabling two-way data binding scenarios.
Methods
Clone()
Creates a new DiagramMargin that is a copy of the current instance.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object | A new DiagramMargin object that is a deep copy of the current instance, containing identical property values and configuration settings. |
Dispose()
This method releasing all unmanaged resources.
Declaration
public void Dispose()
OnInitializedAsync()
Method invoked when the component is ready to start.
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing any asynchronous operation. |
OnParametersSetAsync()
Method invoked when any changes in component state occurs.
Declaration
protected override Task OnParametersSetAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | ="Task". |