Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to set VIEW object to VIEWMODEL entity data

$
0
0

I have a ViewModel that exposes multiple entities within it to a single View, with multiple datagrids on it.

One of the things on the VIEW is a calendar object that I want to create new appointments.  The calendar object has it's own appointment model that I need to map to my entity data in my ViewModel.  However since I cannot expressly expose my entity class directly to my View I am wondering what the best way to do this mapping would be.

Would it be to loop through a list of the entities in the ViewModel and then raise an event so that the View adds a new appointment and sets the properties of the appointment to the properties exposed in my ViewModel that have been set by the looping through the list of entities?

I was hoping to just iterate through my list of entities from within the view (not a problem to loop through the list itself), but since the entity class is not exposed in the View, it does not what the entity looks like as I loop through the list.

Should a viewmodel have multiple entities on it?   Or should I really create a ViewModel for each entity, hook all the different viewmodels up to my view or create one master viewmodel that exposes other viewmodels from within, since I have multiple entities that rely on different entities, but all need to be exposed to the user?

Any ideas, suggestions would be much appreciated.

Thanks.


nlm


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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