IContainerStatus + CreationPolicy.Shared

Jun 29, 2010 at 2:52 PM

hi, if my ViewModel is exported via CreationPolicy.Shared IContainerStatus.ContainerLoaded/Unloaded just called once. it would be nice when IContainerStatus.ContainerLoaded/Unloaded would fire every time. is it possible?

Coordinator
Jul 3, 2010 at 8:58 AM
I did not really understood what you mean... IContainerAware is a "UI Service" a service that implements IContextAware. What it is doing is handling the Loaded event for the element (you are setting DataContext for the VM), handle its Loaded event and then raise an event
Jul 5, 2010 at 7:13 AM
Edited Jul 5, 2010 at 7:41 AM
 [PartCreationPolicy(CreationPolicy.Shared)]
    [ExportViewModel("Kadia.ViewModel.Parts.LadeIsnVM")]
    public class LadeIsnVM : ViewModelBase, IDataErrorInfo, IFocusMover
    {
...
}
[ImportingConstructor]
        public LadeIsnVM(IMediator mediator, IContainerStatus containerStatus)
        {
            this.mediator = mediator;
            this.containerStatus = containerStatus;

            this.containerStatus.ContainerLoaded += ContainerStatusContainerLoaded;
            this.containerStatus.ContainerUnloaded += ContainerStatusContainerUnLoaded;

        }
hi marlon the ContainerLoaded is just called once cause PartCreationPolicy is Shared. do you understand my question now?
thx Frank (sry for my bad english ;))
Coordinator
Jul 5, 2010 at 8:13 AM
when using IContainerStatus you cannot have CreationPolicy.Shared...