Back to Devexpress

ImageProperties.HorizontalAnchorElement Property

blazor-devexpress-dot-blazor-dot-richedit-dot-imageproperties-903c90f6.md

latest3.7 KB
Original Source

ImageProperties.HorizontalAnchorElement Property

Specifies the element to which an image is horizontally aligned.

Namespace : DevExpress.Blazor.RichEdit

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public FloatingObjectHorizontalAnchorElement HorizontalAnchorElement { get; set; }

Property Value

TypeDescription
FloatingObjectHorizontalAnchorElement

The horizontal anchor element.

|

Available values:

NameDescription
Page

A floating object is aligned to a page.

| | Character |

A floating object is aligned to a character.

| | Column |

A floating object is aligned to a column.

| | Margin |

A floating object is aligned to the left or right page margin, or centered horizontally.

| | LeftMargin |

A floating object is aligned to the left margin.

| | RightMargin |

A floating object is aligned to the right margin.

| | InsideMargin |

Currently not supported and is treated as the LeftMargin anchor element.
Floating objects are aligned to the left margin for odd pages, and the right margin for even pages.

| | OutsideMargin |

Currently not supported and is treated as the RightMargin anchor element.
Floating objects are aligned to the right margin for odd pages, and the left margin for even pages.

|

Remarks

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

HorizontalAlignmentHorizontally 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.HorizontalOffsetDefines 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.HorizontalRelativeOffsetDefines an image’s horizontal offset in percentage.

razor
<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.HorizontalAnchorElement != FloatingObjectHorizontalAnchorElement.Page)
                    properties.HorizontalAnchorElement = FloatingObjectHorizontalAnchorElement.Page;
            });
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

Use the HorizontalAnchorElement property to get the horizontal anchor element of the image.

See Also

ImageProperties Class

ImageProperties Members

DevExpress.Blazor.RichEdit Namespace