Harjeet Singh
Harjeet Singh

Reputation: 396

How we make window draggable without mouse down in wpf?

I have different scenario here I want to make my wpf application drag able with window Style none. If I use following code it works, but I stops the other events on halt. Like I put an custom close and minimize image, this method stop its Mouse_up event. Please help me.

private void Canvas_Loaded_1(object sender, RoutedEventArgs e)
{
     this.MouseDown += delegate 
     {
          DragMove(); 
     };
} 

Upvotes: 0

Views: 129

Answers (1)

Sheridan
Sheridan

Reputation: 69959

Firstly, try attaching this handler to the Window and not the Canvas. Secondly, try attaching to the MouseLeftButtonDown or PreviewMouseLeftButtonDown events instead. Try this:

private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    DragMove();
}

Upvotes: 1

Related Questions