Skip to main content

Image.HorizontalAlignment Property

Gets the image’s horizontal alignment relative to a horizontal anchor element.

Namespace: DevExpress.Blazor.RichEdit

Assembly: DevExpress.Blazor.RichEdit.v24.1.dll

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public FloatingObjectHorizontalAlignment HorizontalAlignment { get; }

Property Value

Type Description
FloatingObjectHorizontalAlignment

The horizontal alignment.

Available values:

Name Description
None

A floating object is not aligned.

Left

A floating object is aligned to the left side of a horizontal anchor element.

Center

A floating object is aligned to the center of a horizontal anchor element.

Right

A floating object is aligned to the right side of a horizontal anchor element.

Inside

Currently not supported and is displayed as the Left alignment type. Floating objects are aligned to the left side of a horizontal anchor element for odd pages, and the right side of a horizontal anchor element for even pages.

Outside

Currently not supported and is displayed as the Right alignment type. Floating objects are aligned to the right side of a horizontal anchor element for odd pages, and the left side of a horizontal anchor element for even pages.

Remarks

Use any of the following properties to define a horizontal position of an image relative to its horizontal anchor element:

HorizontalAlignment
Horizontally aligns an image. If you set this property to a value different from None, the Rich Text Editor sets the HorizontalOffset and HorizontalRelativeOffset properties to 0.
HorizontalOffset
Defines an image’s horizontal offset in twips. If you set this property to a value different from 0, the Rich Text Editor sets the HorizontalRelativeOffset property to 0.
HorizontalRelativeOffset
Defines an image’s horizontal offset in percentage.

Use the ChangePropertiesAsync method to change the horizontal alignment of the image.

<DxRichEdit @ref="richEdit" />

@code {
    DxRichEdit richEdit;
    Document documentAPI;
    @* ... *@
    /* Surround the code that contains an asynchronous operation with a try-catch block to handle
    the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
        try {
            documentAPI = richEdit.DocumentAPI;
            @* ... *@
            Image firstImage = await documentAPI.Images.GetAsync(0);
            @* ... *@
            await firstImage.ChangePropertiesAsync(properties => {
                if (firstImage.HorizontalAlignment != FloatingObjectHorizontalAlignment.Center)
                    properties.HorizontalAlignment = FloatingObjectHorizontalAlignment.Center;
            });
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}
See Also