Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Re-using Views in view first MVVMC

$
0
0
Hi, I've inherited an application which uses the view-first MVVMC patern

In the application I've created 2 step process which creates a person and assigns them to a group. To do this I've created a view and corresponding view model (all views have a 1-2-1 relationship with a view model, view models are injected into the View constructor and are registered with the container using the TransientLifetimeManager) called CreatePersonMaster, the view simply contains a region (shown by the dashed line) which sub-views can be loaded into and the view model subscribes to two loosely coupled events, "PersonCreated" and "GroupSelected". The "PersonCreated" event saves a Person entity in a field and the "GroupSelected" event takes the saved Person, creates a Group association and saves them to a database.

Obviously this view/view model doesn't do anything until the events get raised so I load the following sub views into my the region.

Image

These views/view models fire the events which get handled by the master view.

I also have an edit view where I want to re-use the select group view.

Image

I can do this by subscribing to the appropriate events in the EditPersonMaster view model.

My question really is, is this the appropriate way to do this?

Because I'm using events I don't get any feedback into the View/ViewModels if there's an error when creating/reassigning? I could probably fire another "ErrorBlah" event for the inner view/model to handle and update the view.

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>