tags:

views:

138

answers:

1
+1  Q: 

WPF Mouse Over

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?!

+1  A: 

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.

Reed Copsey
Can you give me an example? I kinda don't understand how that works..
Here's another link: http://blog.kirupa.com/?p=378 I walks through how to do this in more detail, using the Expression SDK options (InvokeCommandAction and a custom Behavior<T>)
Reed Copsey