View inside a view

May 12, 2012 at 7:27 AM
Edited May 12, 2012 at 7:29 AM

Still learning the framework, and starting getting my head around it. thank you for your work Tony.

I have a new question, and I wish you could point me in some direction.

Let's say I have a HouseView with its HouseViewModel. The view is divided into two area :
- the first one to enter details about the house such as type of house (flat, detached, semi detached, loft etc), address...
- the second part shows details of the house and must change depending on the type of house choosen in the first part.

I was first thnking creating a single with, but the View model could be very large to handle all possibilities.

Would it be better to create two different Views in my HouseView (such as HouseCommunView and HouseDetailView) with their view models, and if so, how do I enable the modification of the HouseDetailView when the user changes the type of house in the HouseCommonView.

Also, how does the HouseViewModel communicate with the two child view model to enable saving and verification?

Thank you for your answer, and I am sorry if this question seems trivial to you, but I am still in the learning process of the framework...

May 12, 2012 at 5:05 PM
You're on the right track: two views each with its own view model. The way to keep things in sync is to send messages between the two view models using the MessageBus. ViewModelBase class has two methods for this: SendMessage and RegisterToReceiveMessages. For help in getting started, there is a blog post, documentation, and a sample in the samples folder created by the toolkit installer.



May 13, 2012 at 7:59 AM

Thank you for your answer Tony, I shall go and have a good look on that right now.