Jun 1, 2012 at 9:11 AM
Edited Jun 8, 2012 at 3:45 PM
|
You can extend the IDashbaord with an enum that define the type of dashboard... it could be even decorated with the flags attribute, so that you can define what combination of grid/chart or whathever type of view you want to display:
[Flags]
public enum ContentType
{
Grid,
Chart,
RadGrid
}
this way you can re-use the same Dashboard view model to define different kind of representation.
Another option, could be to define a list of Dashboard content view-models (and I would prefer this approach):
public interface IDashboard
{
BindableCollection<IDashboardContent> Contents { get; }
}
Then you could build the content of the dashboard dynamically, depending either on the enum value or the collection of contents.
Using a collection of contents would allow you to define the views for such contents indipendently, you could have three different view-models and views associated to the chart, datagrid or radgrid.
This approach is probably the most flexible, and you would be able to switch at runtime the representation of the dahsboard, if needed.
Consider creating an IDashboard view like this:
<UserControl ...>
<ItemsControl x:Name="Contents"/>
</UserControl>
and every IDashboardContent view as something like
<UserControl ...>
<Chart .../> <!-- Customized depending on your needs -->
</Usercontrol>
as you can see, the container for contents is completely unaware of what is inside it, and everything is completely driven by the actual view-model. This means that the concept of dashboard is completely decoupled from the concept of its content.
And one more thing, if all contents share the same conceptual model (e.g. all of them have just the collection of data items, and all required properties are shared among different representations, like the time boundaries...), you could just define one
IDashboardContent implementation, and use an enum to define the specific view that could be bound to the context of the view, so that same view model can be associated to different views.
I hope I was clear enugh... :)
|