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
ToggleButton
because it can be pressed throughout and can be toggled (unpressed) when you set itsIsChecked
property 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
ToggleButton
is 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 itsPressed
state when you move onto the slider.Further, the
IsChecked
property of theToggleButton
can be two way bound to theIsOpen
property of the slider popup. This way when the user stops sliding and releases the mouse, we can setIsOpen
of the popup as false and that will automatically unpress the togglebutton due to that two way binding.