Drag & Drop WPF-object inside boundaries
I want to create a user-control where I can move an object (like a rectangle) within certain boundaries via drag & drop.
The 开发者_如何学Cdrag shall be limited to the x-axis only (think of a slider).
How do I do this?
You can make use of Canvas as a base control and then add any number of WPF control to the base Canvas. Then capture the MouseX position and reset the selected child control's Left position using Canvas.SetLeft when user click and drag the control.
Here is one good article link which will help you get started.
精彩评论