Back to Devexpress

DxTabBase.AllowClose Property

blazor-devexpress-dot-blazor-dot-base-dot-dxtabbase-8fa4872a.md

latest2.1 KB
Original Source

DxTabBase.AllowClose Property

Specifies whether users can close the tab.

Namespace : DevExpress.Blazor.Base

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(false)]
[Parameter]
public bool AllowClose { get; set; }

Property Value

TypeDefaultDescription
Booleanfalse

true to display the Close button and allow users to close the tab; otherwise, false.

|

Remarks

Set the AllowClose property to true to allow users to close the tab and display the Close button in the tab header. A user can close a tab in the following ways:

  • Click the Close button.
  • Press the Delete key.

When a user clicks the Close button or presses Delete, the TabClosing event fires. You can use event properties to obtain information about the tab being processed and the action that raises the event.

Set the Cancel property to true to cancel the close action.

razor
<DxTabs TabClosing="TabClosing">
    @foreach (var employee in Employees) {
        <DxTabPage Text="@(employee.FirstName + ' ' + employee.LastName)" AllowClose="true" >
            ...
        </DxTabPage>
    }
</DxTabs>

@code {
    void TabClosing(TabCloseEventArgs args) {
        // Prevent disabled tabs from closing 
        // and disable closing tab by pressing the Delete key.
        args.Cancel = !args.TabInfo.Enabled || (args.CloseReason == TabCloseReason.DeletePress);
    }
}

Implements

AllowClose

See Also

DxTabBase Class

DxTabBase Members

DevExpress.Blazor.Base Namespace