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

DxWindow.DragCompleted Event

Fires after the Window is dragged.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public EventCallback<WindowDragCompletedEventArgs> DragCompleted { get; set; }

#Event Data

The DragCompleted event's data class is WindowDragCompletedEventArgs. The following properties provide information specific to this event:

Property Description
CancellationToken Specifies an object that propagates a cancellation notification.
End Returns the end window position.
Start Returns the initial window position.

#Remarks

When the AllowDrag property is set to true, users can drag the Window. Handle the DragCompleted event to be notified when a user finishes dragging the window. The event argument’s End parameter returns the new window position.

The following code snippet prevents users from dropping the component outside the browser’s viewport:

Razor
<DxButton RenderStyle="ButtonRenderStyle.Secondary" 
          Click="() => windowVisible = !windowVisible">SHOW A WINDOW</DxButton>
<DxWindow @bind-Visible=windowVisible
          PositionX="positionX"
          PositionY="positionY" 
          AllowDrag=true
          DragCompleted="OnWindowDragCompleted"
          ShowCloseButton="true"
          HeaderText="Header"
          BodyText="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet metus vel
             nisi blandit tincidunt vel efficitur purus. Nunc nec turpis tempus, accumsan orci auctor,
             imperdiet mauris. Fusce id purus magna."
          Width="max(25vw, 250px)">
</DxWindow>

@code {
    int positionX = 250, positionY = 250;
    bool windowVisible;
    void OnWindowDragCompleted(WindowDragCompletedEventArgs args) {
        positionX = Math.Max(0, args.End.X);
        positionY = Math.Max(0, args.End.Y);
    }
}
See Also