Prism MEF Export / Import Problem
I´m trying to inject an existing instance of a class into my view, but the view only receive a default instance of my class.
Here is my export in a view model class
[Export("BLA", typeof(vmObject))]
public vmObject VMObject
{
get
{
r开发者_运维百科eturn vmObject;
}
set
{
if (value != vmObject)
{
vmObject = value;
this.RaisePropertyChanged<vmObject>(() => this.VMObject);
}
}
}
On demand, my view model loads another view which should receive the exported class. I already have checked that class vmObject has been initialized as expected
tRegionManager.RequestNavigate("vInfoAuthorizationField", new Uri("/vInfoAuthorizationField", UriKind.Relative));
My import
[Import("BLA", AllowRecomposition = true, AllowDefault = false)]
public vmObject VMObject { get; set; }
How can i fix this?
Update I could solve the problem by myself
I added the following line to the bootstrapper
this.Container.ComposeExportedValue(this.Container);
After that, I could import the CompositionContainer into my view model and following method solved the import / export problem
this.container.ComposeExportedValue("BLA",this.VMObject);
精彩评论