2
Vote

Default composition doesn't work

description

I use PRISM.
 
This works:
[Export]
public class ShellViewModel : NotificationObject
{
[ImportingConstructor]
public ShellViewModel(IServiceLocator serviceLocator)
}
[Export]
public partial class ShellView : UserControl
{
[ImportingConstructor]
public ShellView(ShellViewModel vm)
}
 
And this doesn't:
[ExportViewModel("ShellViewModel")]
public class ShellViewModel : NotificationObject
{
[ImportingConstructor]
public ShellViewModel(IServiceLocator serviceLocator)
}
[Export]
public partial class ShellView : UserControl
{
public ShellView()
}
 
You can try in demo application.
Why can't container resolve IServiceLocator and ICompositionContainer in that case?
IRegionManager works.
But how can I get instances myself without IServiceLocator or ICompositionContainer?

file attachments

comments

marlongrech wrote Jan 13, 2012 at 3:00 PM

Did you create a custom IComposer for this ? MEFedMVVM needs to be linked with PRISM http://mefedmvvm.codeplex.com/workitem/15391

wrote Jan 13, 2012 at 4:09 PM

xperiandri wrote Jan 13, 2012 at 4:09 PM

Yes.
I've attached your example.
The only change is:
[ImportingConstructor]
public ShellViewModel(IServiceLocator serviceLocator)

You can try, it doesn't work :(

JReuben wrote Nov 21, 2012 at 4:15 PM

I have the same problem Export works, but ExportViewModel doesnt - I get:
No exports were found that match the constraint:
ContractName    WFDesignerRehosting.Modules.WFDesignerModule.ViewModels.TestViewModel
RequiredTypeIdentity    WFDesignerRehosting.Modules.WFDesignerModule.ViewModels.TestViewModel
how can I troubleshoot this ?

wrote Nov 21, 2012 at 4:17 PM

wrote Feb 14, 2013 at 7:47 PM