Binding UI Events from View to commands in ViewModel in Silverlight 4(blog.roboblob.com)

submitted by spavkovspavkov(1708) 2 years, 4 months ago

In previous two posts we covered wiring up the Views and ViewModels and Blendability and showing ModalDialogs in MVVM way. Today we will touch another problem that people starting with MVVM very often fail to address properly: Handling the UI Events of the View in the ViewModel while avoiding placing any logic in code behind of the View. So our design goals for this post are: * We want to be able to wire-up UI Events to the commands in ViewModel via DataBinding in Xaml without any code behind in the View * View should not be aware of the ViewModel’s type or any other details of its existence – View should just use Silverlight’s DataBinding to access its ViewModel public properties (its DataContext) regardless of what is actually set to be there * We want to be able to handle any event that occurs in View (that includes not only Button clicks but also Mouse events, Drag and Drop events, Loaded events etc).

add a comment |category: |Views: 281

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story