locked
How to wire up events in View model

    Question

  • I'm still using VS 2012 on windows 8.

    I have been following a practice to have all my C# code in model and View Model  including the Button click. Now I need to wire up KeyUp/KeyDown event. I can code this event in code behind (MainPage.xaml.cs). I certainly do not want to do that. I try not to have code in code behind file.

    Is there a way to do something like button click event in my ViewModel file?

    Thanks

    Monday, February 24, 2014 1:41 AM

Answers

  • Hi biprism,

    Take a look at Using the MVVM pattern. In the section: Implementing behaviors to supplement the functionality of XAML elements you should be able to see how to attach a KeyUp/KeyDown event with a ComboBox control by using Behaviors SDK.

    Without a specific question, hardly to answer in more detail, but hope this helps.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, February 24, 2014 7:19 AM
    Moderator