IActivate Conductor

Oct 13, 2010 at 4:35 PM

I have a View Model with multiple conductors.  Currently I have to cast the conductors as IActivate to get them to activate properly. Am I doing something wrong ?

  public class MasterViewModel : ViewModelBase {

        public Conductor<IScreen> Region1 { get; set; }

        public Conductor<IScreen> Region2 { get; set; }
        public override void Activate() {

        public override void Deactivate(bool close) {

Oct 13, 2010 at 5:07 PM

No, its ok: IActivate and IDeactivate are implemented explicitly on Screen (the ancestor of Conductor<>) so the corresponding methods are not part of the public interface of the class.
I suppose it was done to descourage erroneous calls to lifecycle interfaces methods, which are usually handled by a conductor.
You scenario is ok, though: MasterViewModel is actually acting as a conductor.

Oct 13, 2010 at 6:53 PM

Marco is correct about the API choice. I know it's a bit nasty in this scenario. If you have this situation occurring a lot...go on over to the full version of Caliburn and grab the source for Conductor<T>.Collection.AllActive  It was designed for your use case. I didn't include it in Micro for size reasons. You also might consider creating some extension methods to handle these scenarios.