Click here to Skip to main content
15,890,527 members
Home / Discussions / WPF
   

WPF

 
QuestionHow to implement Drag and drop functionality using WPF Pin
Nekkantidivya22-May-09 18:57
Nekkantidivya22-May-09 18:57 
AnswerRe: How to implement Drag and drop functionality using WPF Pin
ABitSmart23-May-09 4:17
ABitSmart23-May-09 4:17 
AnswerRe: How to implement Drag and drop functionality using WPF Pin
derm223-May-09 8:39
derm223-May-09 8:39 
GeneralRe: How to implement Drag and drop functionality using WPF Pin
Mark Salsbery23-May-09 9:18
Mark Salsbery23-May-09 9:18 
GeneralRe: How to implement Drag and drop functionality using WPF Pin
derm224-May-09 5:42
derm224-May-09 5:42 
GeneralRe: How to implement Drag and drop functionality using WPF Pin
Mark Salsbery24-May-09 7:09
Mark Salsbery24-May-09 7:09 
GeneralRe: How to implement Drag and drop functionality using WPF Pin
derm225-May-09 1:44
derm225-May-09 1:44 
GeneralRe: How to implement Drag and drop functionality using WPF Pin
Mark Salsbery25-May-09 6:45
Mark Salsbery25-May-09 6:45 
derm2 wrote:
Put this onto your form, and expand the root node. Mousemove will be fired, and you will start a drag operation if you don't check the position.


That's not random.

Preview events are tunneling events - they go from root towards top of tree.

If you click in the treeview, the treeview gets a peek at the event before
the actual target control. You are responsible for dealing with that.

That's why I stated, and it's documented, that some controls consume the bubbling mouse
events like buttons, for example. Buttons take the bubbling events and convert them to the Click
event....the event is marked handled so an attached handler won't get called. So now one has
to use the tunneling event, which is simple for a standard button, but not so simple for a
treeview, which is a composite control (it is composed of many elements).

In this case you are getting messages meant for "child" elements within the treeview.

That's also why I stated you may have to do your own hittesting in the mousedown handler,
which wasn't necessary in my example, but is necessary in your example.
That hittesting can be as simple as this:
void Tree2_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
    // Note this may not work as desired if you have TreeView(s) embedded in your TreeView :)

    TreeView tv = e.Source as TreeView;
    if (tv != null)
    {
        lastMouseDown = e.GetPosition(this);
        readyToDrag = true;
    }
}

You may need to do the same thing in the mousemove handler, but I personally
would capture the mouse so I know all the move events are mine until the button
is released.

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

QuestionAnother M-V-VM question: lookups Pin
ml_black22-May-09 4:23
ml_black22-May-09 4:23 
AnswerRe: Another M-V-VM question: lookups Pin
Pete O'Hanlon22-May-09 4:36
mvePete O'Hanlon22-May-09 4:36 
GeneralRe: Another M-V-VM question: lookups Pin
ml_black22-May-09 4:48
ml_black22-May-09 4:48 
GeneralRe: Another M-V-VM question: lookups Pin
ml_black22-May-09 6:18
ml_black22-May-09 6:18 
GeneralRe: Another M-V-VM question: lookups Pin
Pete O'Hanlon22-May-09 11:40
mvePete O'Hanlon22-May-09 11:40 
QuestionMaskText box is not scrolling in scrollviewer, in WPF Pin
Asit Kumar Sinha22-May-09 2:28
Asit Kumar Sinha22-May-09 2:28 
AnswerRe: MaskText box is not scrolling in scrollviewer, in WPF Pin
Mark Salsbery22-May-09 6:31
Mark Salsbery22-May-09 6:31 
QuestionCreating this sort of style in WPF/Blend Pin
pancakesOfMassDeliciousness22-May-09 2:15
pancakesOfMassDeliciousness22-May-09 2:15 
AnswerRe: Creating this sort of style in WPF/Blend Pin
Mark Salsbery22-May-09 5:09
Mark Salsbery22-May-09 5:09 
AnswerRe: Creating this sort of style in WPF/Blend Pin
Gideon Engelberth22-May-09 15:12
Gideon Engelberth22-May-09 15:12 
AnswerRe: Creating this sort of style in WPF/Blend Pin
Unagii10-Feb-10 3:22
Unagii10-Feb-10 3:22 
GeneralRe: Creating this sort of style in WPF/Blend Pin
pancakesOfMassDeliciousness10-Feb-10 3:27
pancakesOfMassDeliciousness10-Feb-10 3:27 
GeneralRe: Creating this sort of style in WPF/Blend Pin
Unagii10-Feb-10 3:45
Unagii10-Feb-10 3:45 
GeneralOverview: WPF Pin
Kamal Gurnani22-May-09 0:44
Kamal Gurnani22-May-09 0:44 
GeneralRe: Overview: WPF Pin
Pete O'Hanlon22-May-09 0:58
mvePete O'Hanlon22-May-09 0:58 
GeneralRe: Overview: WPF Pin
Allen Anderson25-May-09 17:49
Allen Anderson25-May-09 17:49 
QuestionInteroperability: Form vs. Window Pin
Kunal Chowdhury «IN»21-May-09 23:24
professionalKunal Chowdhury «IN»21-May-09 23:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.