Back to Devexpress

WindowClosingEventArgs Class

blazor-devexpress-dot-blazor-e8759a32.md

latest3.8 KB
Original Source

WindowClosingEventArgs Class

Contains data for the Closing event.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public class WindowClosingEventArgs :
    CancelEventArgs

WindowClosingEventArgs is the data class for the following events:

Remarks

The Closing event is raised before the Window is closed. Use the event argument’s CloseReason property to identify which action closes the Window. You can set the Cancel property to true to cancel a close action.

Close ReasonDescription
CloseButtonClickA user clicks a custom Close button (if you called the predefined CloseCallback to create this button).
EscapePressA user presses Escape.
ProgrammaticallyYou set the Visible property to false or call the CloseAsync method.

You can also handle the Closed event that fires after the Window is closed.

In the following example, neither the Close button in the header nor the custom OK button closes the Window until a user enables the checkbox in the footer:

razor
<DxButton Id="showDDbtton" Click="() => IsOpen = true">SHOW A WINDOW</DxButton>
<DxWindow Width="400"
            @bind-IsOpen="@IsOpen"
            ShowFooter="true"
            HeaderText="DevExpress EULA"
            Closing="EulaClosing"
            Closed="EulaClosed">
    <BodyTextTemplate>
        <p>
            The terms of our license are fully outlined/described in the Developer Express Inc End User
            License Agreement (EULA) included with our product installations. Before you can install and use
            a Developer Express Inc product, you must read, understand and accept the terms/conditions of
            our EULAs. <a target="" _blank"" rel="" noopener noreferrer"" href="" https: //www.devexpress.com/support/eulas/"">More info...</a>
        </p>
    </BodyTextTemplate>
    <FooterTextTemplate>
        <DxCheckBox class="my-margin" @bind-Checked="@EulaAccepted">
            I accept the terms of the EULA
        </DxCheckBox>
        <DxButton RenderStyle="ButtonRenderStyle.Primary" Text="OK" Click="context.CloseCallback" />
    </FooterTextTemplate>
</DxWindow>

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

    void EulaClosing(WindowClosingEventArgs args) {
        if (args.CloseReason == WindowCloseReason.Programmatically) {
            args.Cancel = !EulaAccepted;
        }
    }
    void EulaClosed(WindowClosedEventArgs args) {
        EulaAccepted = false;
    }
}
css
.my-margin {
    margin-left: 0; 
    margin-right: auto;
}

Inheritance

Object EventArgs CancelEventArgs WindowClosingEventArgs

See Also

WindowClosingEventArgs Members

DevExpress.Blazor Namespace