Wednesday, 7 August 2013

One ViewModel containing a collection of Models, different Views depending in value of object property

One ViewModel containing a collection of Models, different Views depending
in value of object property

I am new to the MVVM-pattern, and am trying out Caliburn.Micro on a project.
I want to have one ViewModel (which contains a collection of ViewModels)
shared by multiple Views, where each view only displays items which have a
certain value on one of it's properties.
To get specific, I am using a service which allows me to monitor different
values that update frequently. I then get an object of type MonitoredItem,
which contains a property of type DataValue, which in turn contains an
object for the Value and a property for the value's datatype.
So far I have a MonitoredItemView which uses this service's MonitoredItem
class as it's model, and a MonitoredItemsViewModel which contains
BindableCollection MonitoredItems, and commands for adding/removing items.
I also have a MonitoredItemsView where I can see all the items I am
currently monitoring.
How do I go about splitting up the view, so that I can have all
MonitoredItems where DataValue is an integer/float/double displayed in one
area in my window, boolean values displayed somewhere else etc?

No comments:

Post a Comment