You can use MEF by exporting the settings view from each view model and importing them as a list of views that you add to the stack panel, or some of them in your main settings view.
A good source of information on using MEF is: http://mef.codeplex.com/wikipage?title=Guide
Here is an example of a program that I would like to get up earlier:
using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.Reflection;
namespace zTestConsole { public interface ISimple { string Message { get; } } [Export("SimpleHello",typeof(ISimple))] public class SimpleHello : ISimple { [Export("Message")] public string Message { get { return "Silverlight rocks!"; } } } [Export("SimpleBello",typeof(ISimple))] public class SimpleBello : ISimple { [Export("Message")] public string Message { get { return "C# rocks!"; } } } public class SimpleMultiCat { [ImportMany("Message")] public IEnumerable<string> Messages { get; set; } } public class SimpleCat { [Import("SimpleHello")] public ISimple simple { get; set; } } class Program { private static CompositionContainer container; static void Main(string[] args) { AggregateCatalog catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly())); SimpleMultiCat cats = new SimpleMultiCat(); SimpleCat cat = new SimpleCat(); Program.container = new CompositionContainer(catalog); try { Program.container.ComposeParts(cats); foreach (string message in cats.Messages) { Console.WriteLine(message); } } catch (CompositionException ex) { Console.WriteLine(ex.ToString()); } Console.WriteLine(); try { container.ComposeParts(cat); Console.WriteLine(cat.simple.Message); } catch (CompositionException ex) { Console.WriteLine(ex.ToString()); } } } }
source share