Tech Tock

Time is of the essence.

EventToCommand for Attached Property

To propagate events to a view to a ViewModel – use an attached property, not fancy xaml binding, but an attached property.  It says so right here in so many words.  So if you want MouseOver or DoubleClick, AutoComplete.Populating, etc. this is your answer.

Here’s the example everyone points you to.

The all purpose EventToCommand class in the MVVM Light Toolkit looks like the most convenient way to get this job done.

For any type of click, retemplating a button and using a ViewModel ICommand for its Command is the way to go.


August 6, 2010 - Posted by | Uncategorized | ,


  1. What I’ve been wondering lately is how to go the other way… how to handle in a view’s XAML via an EventTrigger an event (other than PropertyChanging or CollectionChanging or a RoutedEvent) raised in the ViewModel.

    Comment by James Webster | August 6, 2010 | Reply

    • I’m wondering what the use case is for handling an event other than property changed event in XAML. It sounds like you’re talking about a WPF Trigger, maybe with an Animation, but I’m not sure.

      Comment by goldmanalpha | August 7, 2010 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: