Back to Devexpress

DxDropDown.FocusOnOpen Property

blazor-devexpress-dot-blazor-dot-dxdropdown-0fa5ffa0.md

latest1.8 KB
Original Source

DxDropDown.FocusOnOpen Property

Specifies whether the drop-down window receives focus when it opens. Available in v25.2.6+.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(true)]
[Parameter]
public bool FocusOnOpen { get; set; }

Property Value

TypeDefaultDescription
Booleantrue

true to move focus to the drop-down window when it opens; false to keep focus on the current element.

|

Remarks

When FocusOnOpen is true, focus moves to the first interactive element in the drop-down window when it opens.

If you set this property to false, focus stays on the currently focused element.

Note

Users can press Esc to close the drop-down regardless of the FocusOnOpen value.

The following code snippet keeps focus on the trigger button when the drop-down window opens:

razor
<DxButton Id="dropdownButton"
          Text="Open a drop-down window"
          Click="() => isOpen = true" />

<DxDropDown @bind-IsOpen="isOpen"
            PositionTarget="#dropdownButton"
            PositionMode="DropDownPositionMode.Bottom"
            Width="250px"
            BodyText="Are you sure you want to continue?"
            FooterVisible="true"
            FocusOnOpen="false">
    <FooterContentTemplate>
        <DxButton Text="Yes" Click="@context.CloseCallback" />
    </FooterContentTemplate>
</DxDropDown>

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

See Also

DxDropDown Class

DxDropDown Members

DevExpress.Blazor Namespace