I saw this on an internal alias recently thought it would make a useful post. Most of us are aware that many controls in WPF can invoke an ICommand
as a result of their default action. For example, to invoke a Command on the Click of a button we can simply do this:
<Button Command="YourCommand" />
Easy. But what if I want to invoke a command on a Double Click? Also easy...
<MouseBinding Gesture="LeftDoubleClick" Command="YourCommand" />
So now YourCommand
will be invoked when the button is double clicked. What about a CTRL and left button click? Also easy:
<MouseBinding Gesture="CTRL+LeftClick" Command="YourCommand" />
Nice. You can read more about MouseBinding
s and take a look at KeyBinding
s whilst your at it.
01 Apr 2008
» Next Post:
Xaml for Config
« Previous Post:
Workaround for missing ElementName in Silverlight 2.0 Binding
Comments are closed for this post.
06 Apr 2008
What about a command that activates on mouse move and another that activates on mouse up? Examples: zoom rectangle, drag and drop.
07 Dec 2011
Thank you! Worked perfectly.