Dialog Responsibility

by Jon Sigfusson 17. March 2011 07:34

Last night I was working on my favorite hobby project Campaign Planner when I came across a situation where I wanted to handle some user interaction in a user control. When editing a path the user needs to be able to set the precise time of a path point. Now the question I posed myself was: How does the control (or the view model class) initiate a dialog with the user?

I did come up with a solution the next day. Say you wanted the dialog with the user to occur in a modal window then the solution must be: The view model (MVVM) must be the initiator. The user control must handle the creation of the dialog window. You can make this happen with a public event on the view model class and having the user control handle the event by creating a modal dialog window.
Another solution would be to expose a property on the view model class that the user control is bound to and can change visual appearance to support a dialog with the user.

In the case of the modal dialog window I did ponder other options, such as letting the view model class event bubble up the view model hierarchy to the main window view model class where I already handle several other user interaction events. But I must admit that while a little code is required in the view (user control) the simplicity of the solution outweighs the cost.

More to come…

Tags:

Programming

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Gl. Hellebækvej 47, DK-3000 Helsingør | info@jonesproductions.dk | +45 3211 8346 | CVR: 30 67 93 26
A BlogEngine.NET 1.6.1.0 driven website.
Automotive theme from N3O modified by Jones Productions.
 

RecentPosts


BizSpark Logo