Question

What is the best way to link a method when the mouse over event is fired?

An example.

when a mouse hovers over a button. A method fires such as count.

So as long as the mouse is over the button, the count will keep on incrementing.

How will i connect a mouse over event to a method? Using Xaml?!

ANY IDEAS?!

Was it helpful?

Solution

One way to do this is via an attached property, especially if you want to reuse this capability.

Expression Blend's Behavior<T> class makes this simple. You'll need the the Blend SDK, but then you can use behaviors directly. Here's a blog post showing an example.

This allows you to assign an attached behavior in XAML. Many MVVM frameworks have an implementation that uses this approach, such as the LifetimeEvents in Cinch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top