views:

284

answers:

1

In a framework for an app that I'm creating, I can have multiple "plug-in" 's added to a "workspace", where they can be rearranged and re-sized as necessary. I want each plug-in to be able to register WorkspaceParameters (global parameters shared by all plug-ins) with a WorkspaceManager (exposed through IWorkspaceManager interface) class. When the plug-in registers a global parameter, the WorkspaceManager first checks if one with the same name as already been registered and if it has, the plugin just subscribes to be notified if it changes. If it one has not been created already with the given name, a new one is created. The WorkspaceParameter class currently looks like this:

public class WorkspaceParameter
{
    public string Label { get; set; }
    public Type ParameterType { get; set; }
    public object Value { get; set; }
}

I then have a view in the app that I want to display each WorkspaceParameter for the user to be able to change the value. The UI should be based on the ParameterType member of each WorkspaceParameter and all of the parameters should be displayed in a StackPanel. For example, if the Type is DateTime, I want to display a textbox with a calendar selector next to it. If it's a string, a simple Textbox with the label next to it, and lastly for now, if it's an enum type, a dropdown with the available enum options.

How can I implement this dynamic view using the principles of PRISM and MVVM?

A: 

I would recommend to look at a series of Blogpost by Glenn Block. In the last article he refactored his solution to use the mvvm pattern. He uses MEF heavily this is a framework for extensibilty.

This is No. 5 of a sequal please read all of them it could be basically what you were looking for.

http://msmvps.com/blogs/theproblemsolver/archive/2009/02/18/getting-started-with-the-repository-pattern-in-silverlight.aspx

silverfighter