C# DragMove()和MousedragelementBehavior赢得';你不能在同一个窗口工作吗?

C# DragMove()和MousedragelementBehavior赢得';你不能在同一个窗口工作吗?,c#,.net,wpf,xaml,drag-and-drop,C#,.net,Wpf,Xaml,Drag And Drop,我正在使用创建一个WPF/xaml应用程序 WindowStyle=“无” 因此,我不得不使用 protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); // Begin dragging the window this.DragMove(); 使窗口可以在屏幕上拖动。然而,我还想使

我正在使用创建一个WPF/xaml应用程序

WindowStyle=“无”

因此,我不得不使用

    protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
    {
        base.OnMouseLeftButtonDown(e);

        // Begin dragging the window
        this.DragMove();
使窗口可以在屏幕上拖动。然而,我还想使窗口内的图像可以拖动,这是我计划使用的

    <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>


问题是,我不能让它们都在同一个窗口上工作,因为它们只有在另一个窗口关闭时才能工作。非常感谢您的帮助。

您的
OnMouseLeftButtonDown
是在整个窗口上定义的,因此会干扰
mouseDrageElementBehavior
的触发器

在窗口中添加一个
边框
,给它一个
背景
透明
可以,只是不要让它没有背景),然后收听边框上的
MouseLeftButtonDown
事件。在事件的处理程序中执行
DragMove()

您可以将边框作为窗口标题,也可以将其放在内容后面