I am creating a WPF/xaml application with
WindowStyle=”None”
So because of this I am having to use
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
// Begin dragging the window
this.DragMove();
To make it so the window can be dragged around the screen. However I also want to make images within the window drag-able which I planned to do using
<Image HorizontalAlignment="Right" Height="65" Width="203" Margin="0,278.271,14.434,82.5" Source="Images/Implementation1.png" Stretch="Fill">
<i:Interaction.Behaviors>
<ei:MouseDragElementBehavior ConstrainToParentBounds="True"/>
</i:Interaction.Behaviors>
</Image>
The issue is that I can’t get them both to work on the same window as they will only function if the other is switched off. Any help would be greatly appreciated.
Your
OnMouseLeftButtonDownis defined on the whole window, thus interfering with the trigger forMouseDragElementBehavior.Add a
Borderto your window, give it aBackground(Transparentis ok, just don’t leave it without a background) and listen toMouseLeftButtonDownevent on the border. Do theDragMove()in the handler for the event.You can put the border as a title of the window, or you can put it behind the content.