Can anybody give me a simple wpf application using mef and following mvvm pattern. I have looked a lot on the internet but i found very few examples and those example are very complex to understand. some examples are wpf, mef but dont follow mvvm pattern.
here is what i am trying to do.
There will a main wpf application. This will load all the modules (plugins) and show it to user. A module will contain 2 or 3 pages with next back buttons (used for navigation). Now when in main application i select a module, module opens or what you can say it replaces current window and on button navigation it changes views of the module.
Main Window -> Module 1 -> Page 1
Page 2 Page 3 Module 2 -> Page 1 Page 2 Page 3
So it look clean now. Module 1 is a seperate project, module 2 is a seperate project. main window reads modules from dll and show them. clicking a module will go through its pages.
i did 2 projects these days which do that what you want. what i have done is to set up a main project which does nothing more than collecting the modules via MEF and handle the selection of the module. you also need a component project where you set up the interfaces and export attributes.
here some sample code pieces:
MainProject app.xaml.cs
Component.dll
Modul example
or viewmodel export --> (if you do this you have to export a datatemplate to the mainapp, i can show this if you want)
Microsoft has a few reference implementations lying around that you may find useful. they are a good showcase of MVVM / MEF and WPF. here's the very first blog about the StockTrader RI implementation with the download link pointing here. the Microsoft overview of the StockTrader RI and MVVM RI implementations are here, and here's the StockTrader RI implementation specifically. hth.