I'm new to MEF, and MVVM, and I'm having some problems.
I've finally got my View and ViewModel binding in my app; I'll explain what I've got and then the problem, hoping someone could help figure out what my problem is.
I have a host app - MVVM, the main view loads plugins from a dir and displays their name across the top. It also loads some items and displays them down the side.
In my main app constructor I get all the resource dictionary types and add them to the app.current.resourcedictionary
then I get all my plugins and do a
In the constructor of each plugin I generate a GUID and console.writeline the new GUID.
when I call the .value of I get an init in the output, when the resourcedictionary is called I get an init as well...
What I want, is when changing the Item on the left, to update a textblock in the view of the plugin, this does not happen. However I have a button on the plugin view which does correctly update the TextBlock.
I think although all my classes have a creationpolicy shared - it still seems to create more than one instance.
Thanks for reading all that, All this MEF / MVVM is heavy going, so I'd be very glad of any assistance!
I've finally got my View and ViewModel binding in my app; I'll explain what I've got and then the problem, hoping someone could help figure out what my problem is.
I have a host app - MVVM, the main view loads plugins from a dir and displays their name across the top. It also loads some items and displays them down the side.
public class Item
{
public Item()
{
}
public int Number { get; set; }
public string Name { get; set; }
}
To correctly load my modules, I was required to expose a public property of ResourceDictionary in the code behind of the view. I also expose the class of the viewmodel.In my main app constructor I get all the resource dictionary types and add them to the app.current.resourcedictionary
then I get all my plugins and do a
foreach( var plugin in _plugins)
{
Plugins.Add(p.value);
}
_plugins is an IEnumerable<Lazy<PlugingViewBase, IPluginMetaData>>;In the constructor of each plugin I generate a GUID and console.writeline the new GUID.
when I call the .value of I get an init in the output, when the resourcedictionary is called I get an init as well...
What I want, is when changing the Item on the left, to update a textblock in the view of the plugin, this does not happen. However I have a button on the plugin view which does correctly update the TextBlock.
I think although all my classes have a creationpolicy shared - it still seems to create more than one instance.
Thanks for reading all that, All this MEF / MVVM is heavy going, so I'd be very glad of any assistance!