I need a thumb control that can be sized using a mouse. When the user hovers the mouse over one of the ends a size cursor should be displayed and when the user clicks and drags the end of the control it will be re-sized.
I started out thinking I should create a custom control that is created from three thumb controls. There would be a main thumb and then one for each end that would handle the re-sizing, but I decided that wasn't a good solution.
I'm thinking that a better approach would be to use a single Thumb control and then have a re-size Adorner popup on the end of the control the mouse is hovering over. With this approach how would you detect the mouse is hovering over a specific region of the control? Examples of how to do this or any help would be greatly appreciated.
Here is one I made a while ago, it allows
Move
andResize
, but you can remove theMove
logic and it should work fine (the style is still a bit messy, but it works pretty well)Its based on
ContentControl
so you can add anyElement
inside and Move/Resize on aCanvas
, It uses 3Adorners
, one for Resize, one for Move and one to display information (current size)Here is a full working example if you want to test/use/modify/improve :)
Code:
Xaml:
Result:
With content inside (Button)
Sorry the cursors do not show when using SnipTool