Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Trigger on IsMouseOver for DragDrop Operation

I do a drag&drop operation and want to trigger a image element to change its source when the ismouseover property is true. Now i realize that the ismouseover property is not updatet when the drag&drop operation works.

Is there a other way to change the image source on mouseover while drag&drop is active?

like image 614
user2025830 Avatar asked Feb 28 '13 09:02

user2025830


1 Answers

I had the same issue and ended up creating a new boolean in my Custom control called IsDragMouseOver and referencing that in my control template.

In the code behind of the control I added the following:

protected override void OnDragEnter(DragEventArgs e)
    {
        base.OnDragEnter(e);
        IsDragMouseOver = true;
    }

    protected override void OnDragLeave(DragEventArgs e)
    {
        base.OnDragLeave(e);
        IsDragMouseOver = false;
    }

    protected override void OnDragOver(DragEventArgs e)
    {
        base.OnDragOver(e);
        IsDragMouseOver = true;
    }

    protected override void OnDrop(DragEventArgs e)
    {
        base.OnDrop(e);
        IsDragMouseOver = false;
    }

Hope that helps.

like image 73
John Taylor Avatar answered Sep 28 '22 14:09

John Taylor