Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxDropDown.PreventCloseOnPositionTargetClick Property

Specifies whether the drop-down window should be closed when a user clicks the position target element.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public bool PreventCloseOnPositionTargetClick { get; set; }

#Property Value

Type Default Description
Boolean false

false to close the drop-down window on any outside click; true to keep the drop-down window open when the position target element is clicked.

#Remarks

If the CloseOnOutsideClick property is set to true, the drop-down window is closed when a user clicks outside the window’s boundaries. Set the PreventCloseOnPositionTargetClick property to true to prevent the window from closing when a user clicks an element specified by the PositionTarget property. This behavior allows you to change window visibility on a position target element click in the following way:

Razor
<div id="dropdown-overview-target-container">
    <DxButton Click="() => IsOpen = !IsOpen">SHOW A DROPDOWN</DxButton>
</div>
<DxDropDown
    @bind-IsOpen="@IsOpen"
    BodyText="@Constants.Content"
    PositionMode="DropDownPositionMode.Bottom"
    Width="max(25vw, 250px)"
    PositionTarget="#dropdown-overview-target-container"
    PreventCloseOnPositionTargetClick="true">
</DxDropDown>

@code {
    bool IsOpen { get; set; } = false;
}

Run Demo: DropDown — Overview

See Also