I’m trying to get my head round MVVM, and have a fairly simple requirement that i’m struggling with.
I’m using RIA services, and in my model, i’ve got 3 entities that represent views from a DB.
In my XAML view at the moment, I have a combobox which allows the user to select a particular view from the DB, and I have a datagrid that should display the results from the users selection. The problem I am having, is that the DomainContext.Load method (called when the user selects an item from the ComboBox) returns an EntitySet of a specific type (I.E EntitySet<Servers> or EntitySet<Apps>), depending on which view is selected.
I need to bind the grid to a property in my ViewModel, but can’t declare just one property to hold the EntitySet from the Load operation, as each Load operation returns a different type of EntitySet (<Apps>,<Servers> for instance).
Is there a generic type that I can bind my grid to, and also convert the EntitySets to?
Or, am I doing this completely wrong? All suggestions welcome as i’m floundering 🙂
Thanks
Mick
Use 2 different DataGrid controls (one for
Appsand one forServers) and hide/show when needed. Chances are you may want to customise them independently anyway.Never overcomplicate things, e.g. by sharing controls, just because the GUI elements appear similar. Think of them as a ServerDataGrid control and AppDataGrid control.