tags:

views:

361

answers:

2

Hi Guys,

I am having a WPF dataentry form which has got 3 comboboxes which needs to be filled with Master Details like Department, Job Title and Pay Type & other information. All these 3 master information needs to be fetched from the database. I am using LINQ to SQL as my data layer. I have already built the maintenance pages for these master information(i.e. 3 Viewmodels).

Now My Question:

Is it advisable to use these 3 view models for the comboboxes (which defeats the MVVM since there is more than one view model being used for a view) and directly bind them or is it ok if I just use 3 observablecollection of prime classes (Department, JobTitle & PayType).

I would really appreciate any help in this regard. I have lots of form with the same scenario and I am not able to decide on which route to take.

Thanks in advance.

Raja

+1  A: 

I think it is fine to use three ObservableCollections in your ViewModel class. This way you can use it as the DataContext of the view itself, which will make setting up the bindings much easier.

Andy
Thanks Andy. I was also of the same impression. You just made my decision simple :-)
A: 

As a slight variation on this I might have used ObservableCollections of ViewModels.

This might not might not make sense in your case, but I've been finding it helpful in cases where the combo/list uses a fairly complex datatemplate and the user can interact with elements in the listitem...

Scrappydog