How can I raise an event with its original effect in WPF?
-
06-09-2020 - |
Question
I know that I can use RaiseEvent
to raise an event, like raise a MouseDownEvent on a button.
I use the mouse to click on a Button
. It has a MouseDown
effect (like background change to blue), but I use RaiseEvent
. It just does the MouseDown
function, not triggering the button's MouseDown
effect.
How can I raise an event with its original effect?
Solution
In short, you can't. That effect is bound to the IsPressed property of the Button. Like wise the IsMouseOver is used to determine if the mouse is hovering over the button. You can't really change/set these properties.
You could restyle the Button control to render these effects when one or more custom attached properties are set. But you can't induce the effect by raising events.