This time I have a hard one for you :-)
Currently I am about to develop a usercontrol in wpf. I want this control to open up a slider as soon as one presses the mousebutton on a specific button within this control. The user should be able to move this slider as long as the mousebutton is still pressed.
As soon as the user releases the mousebutton the slider should disappear.
I already have a solution for this, but it's a very hacky one, because I am doing it through screen coordinates.
Is there any way to do this in a pleasant way with WPF?
Any help is highly apprechated!
Regards, Michael
Please answer these questions first
ToggleButtonbecause it can be pressed throughout and can be toggled (unpressed) when you set itsIsCheckedproperty to false (i.e. when user releases mousebutton).Pressed(from button event argse) when mouse moves, being dragged, over some element such as the slider here?e.g.
EDIT
Related to point no. 2....
The reason why I suggest
ToggleButtonis because only that can be kept pressed while you slide on the slider. Otherwise with normal button, you can open the slider popup on button click but the button will loose itsPressedstate when you move onto the slider.Further, the
IsCheckedproperty of theToggleButtoncan be two way bound to theIsOpenproperty of the slider popup. This way when the user stops sliding and releases the mouse, we can setIsOpenof the popup as false and that will automatically unpress the togglebutton due to that two way binding.