problems with IViewAwareStatusWindow

Apr 22, 2012 at 7:30 PM

Hi,

In my application I need to have multiple instances of one VM. Obviously this is not supported with cinch, since the match between view/vm is by an attribute on class level. I wonder that nobody else seems to miss this, or did I oversee a functionality? It is quite common to use tabbed interfaces with, say 3 different orders open which asks for 3 instances of a ordervm.

Anyway, for this reason I have to create my vm´s with the ExportFactory<myVM>.CreateExport() method which is implemented in the latest build of MEF.

I also decorate the VM´s that I need multiple times only with the [Export] attribute, since they get build by the Componsition core, not Cinch or MEFEDMVVM.

But of course I also want to use Cinch functionality like the build in Services, like IMediator etc.

This even works the usual way:

[ImportingConstructor]
public MyVM(IMediator m){
}

only if I try to get the IViewAwareStatusWindow or IViewAwareStatus or IContextAware Service, I get the message:

1) No exports were found that match the constraint:  ExportFactory of: 
ContractName Lemma08.ViewModel.SearchVM
RequiredTypeIdentity Lemma08.ViewModel.SearchVM
RequiredCreationPolicy NonShared

This is fact makes some sense, since I guess IViewAware.... is an implementation of Cinch and I am using ExportFactory<>.CreateExport, which is core MEF. My question now is: can anybody point out to me how I could resolve this? where to look? what to change?

I already tried to decorate the class with [Export] and [ExportViewModel("myVM")] to make it known to cinch or mefedmvvm, but that didn´t help.... 

 

thanks

Joachim

Apr 23, 2012 at 6:45 AM

Hello Joachim,

did you tried to set the PartCreationPolicy also?

 [ExportViewModel("myVM")]
 [PartCreationPolicy(CreationPolicy.NonShared)]

Then it should create a new instance for each view instead to share it with every view.

Another hint could be to implement the IViewStatusAwareInjectionAware interface. This should inject the IViewAwareStatus service, if you create your views with cinch.

best regards,

Helmut