Posted by: Zeeshan Amjad | June 7, 2011

Convert Event into Command in MVVM Model


  1. […] already saw one example how to convert Event into Command here. But if we want to consume more than one event, then we have to write lots of repetitive code. Take […]

  2. Dear Zamjad,
    I am just getting up to speed with WPF programming, and I have needed to address the problem you have solved here so clearly.

    Thank you for your work.

    One question: shouldn’t the SelectionChangedCallBack method call RemoveHandler, rather than AddHandler, when args.OldValue is not null?

    • Hi Noel

      Thanks to llike this. Yes you are right it should be RemoveHandler. Thanks for pointing out the mistake 🙂

  3. Hi Sir , Assalam O Aliakum, i m also the student of Dept of Computer Science and Software Engineering , right now working on .Net tools, very inspired by ur linked in profiles and your blog. I know u r extremely buzy but it would be nice of u if u can tell few great tools or art of computer science to master to become a prolific software engineer. I will really appreciate any tips from u. I m 2nd in overall semesters.

    • Thanks to like my blog. With this generic interest it would be very difficult to give any sugesstion. As far as i understand, good software engineer should know how to balance between science and engineering. In other words he/she should know how much theory knowledge is necessary as well as at the same time able to write a production level code that can handle an enterprise level problems, not a proof of concept lab programs only. He should have a good understanding of Algorithm, data structure as well as programming paradigms, such as object oriented programming, generic programming, functional programming, recursive programming, dynamic programming and have knowledge about modeling language (UML) and design patterns.

      I know it is already a lot, so i can suggest one point only. That is read a lot, weather it is a book, online article, magzine, blogs, other’s code etc and try to understand it by making it yourself. I hope I am more clear now. Please feel free to contact me if you have any problem. I will try my best to solve your problem under my capacity.

      Zeeshan Amjad

      • I m extremely thankful to u for tips and knowledge u share with me. Now a days i m studying computer graphics i have keen interest in mobile programming can u tell me which one is better android or iphone , well i know both are in demand to a great deal but just for a startup in 3rd semester what would u recommend.

        i want to design my Computer Graphics project in mobile platform what will u recommend!

        i m sorry for disturbing u again!

      • Both Andriod and iPhone development are very interesting. I got a chance to work on both and explore both while making some POC (Proof of Concept). To develop iPhone application, there are two major hurdles, one is software and other is hardware. You have to have Mac computer and have to learn Objective-C language. Although it is not very difficult, but little bit different thinking style. However for Andriod you can do programming on Windows based compuer using Java and don’t have to learn a new language (if you already know Java).

        Even if learning a new language is not a big problem, then still Mac book is an important factor to make the decision.

  4. Great article. Wouldn’t I have to modify this a bit more to support events raised by the controls hosted in user controls?

    • Thanks to like it. Maybe, i haven’t done this type of work on user control yet. Once i will do this work with user control, i will post my finding here.

      Zeeshan Amjad

  5. Hi Zeeshan!

    Thank you so much for this Demo. It works perfectly in my WPF app. Now I am trying to convert it to Silverlight(5) BUT, Silverlight doesn’t have ListBox.SelectionChangedEvent(Routed Event). Could you please let us know how to rewrite the code for Silverlight?

    Thank you,

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: