English 中文(简体)
Wpf Thumb Drag 不发射拖车进入其他部件
原标题:Wpf Thumb Drag not firing drag enter on other component

我有一刀切的申请,有些Thumb控制把物品放在车上。 我想发现,当这些umb子被拖到另一部分时。 然而,拖拉进入被拖走的部件并未发射。 我知道,这部法典是作为拖拉式的物品而设计的,这些物品并不th火。

th的拖拉事件难道不是其他组成部分所听到的一场拖拉事件吗?

如何做到这一点的想法?

最佳回答

如果 object子在另一部分被移动,则模拟拖拉机进入活动,就必须这样做:

th rag

EventManager.RegisterClassHandler(typeof(Thumb), Thumb.DragDeltaEvent, new RoutedEventHandler(Thumb_DragDeltaEvent), true);

接着,手里看看,拖拉的元件是否超过了聆听移动部分的内容。

void Thumb_DragDeltaEvent(object sender, RoutedEventArgs e)
    {
        UIElement src = e.Source as UIElement ;
        if (src != null)
        {                
            Point srcPositionTopLeft = new Point(Canvas.GetLeft(src), Canvas.GetTop(src));
            Point srcPositionBottomRight = new Point(srcPositionTopLeft.X + src.ActualWidth, srcPositionTopLeft.Y + ActualHeight);
            Rect srcRect = new Rect(srcPositionTopLeft, srcPositionBottomRight);
            Rect transformedSrcRect = src.TransformToAncestor(this.Parent).TransformBounds(srcRect);

            Point trgPositionTopLeft = new Point(Canvas.GetLeft(this), Canvas.GetTop(this));
            Point trgPositionBottomRight = new Point(trgPositionTopLeft.X + this.ActualWidth, trgPositionTopLeft.Y + this.ActualHeight);
            Rect trgRect = new Rect(srcPositionTopLeft, srcPositionBottomRight);
            Rect transformedTrgRect = this.TransformToAncestor(this.Parent).TransformBounds(trgRect);

            if (transformedSrcRect.Contains(transformedTrgRect) ||
                transformedSrcRect.IntersectsWith(transformedTrgRect))
            {
                //drag is over element
            }
        }
    }

之后再去除事件处理员等。

希望有助于未来的人。

问题回答

显然没有。 唯一与Thumb有关的事件是DragStarted、DragCompleted和DragDelta。 其他事件是Drag和下降,如你的德拉克·恩特活动。 这些事件特别针对Drag和下游,例如从勘探者手中拖到与Thumb毫无关系的申请中。 姓名相似,但事实上差别很大。

您可以尝试的一件事是使用。 在拖拉时进行手工试验,但记住,拖拉、下 drop和拖umb花 takes,占用了花.,使其他课堂上的投入活动脱节。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签