Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
there are examples of prgrams that have done this, autodesk put a button in the dragging part of the window, goold chome put TABS in it!, I want to know how i can do stuff like that, I want to know how to add buttons tabs and more on to the draggable window stuff, can some one help?
Posted

1 solution

Your question is not very clear, but as far as I understand you want to be able to drag "stuff" around in a wpf window.

You'll need to
1) handle the MouseLeftButtonDown event; store the current mouse position and capture the mouse
2) handle the MouseMove event; calculate the horizontal and vertical change and move the item accordingly this is more easily done if the items is in a Canvas, so you can use Canvas.SetLeft and Canvas.SetTop. And finally store the current position of the mouse.
3) handle the MouseLeftButtonUp event; Release the mouse capture.

WPF Draggable Label[^] the article doesn't explain this very well but you might be able to use the code, also it doesn't seem like he uses the approach I just suggested which I beleave to be the best.

Dragging Elements in a Canvas[^] This one is probably better, haven't read it myself but I have the utmost respect for Josh, he knows what he's talking about.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900