public WindowConductor(object model, Window view) { this.model = model; this.view = view; var activatable = model as IActivate; if (activatable != null) { activatable.Activate(); } var deactivatable = model as IDeactivate; if (deactivatable != null) { view.Closed += this.Closed; deactivatable.Deactivated += this.Deactivated; } var guard = model as IGuardClose; if (guard != null) { view.Closing += this.Closing; } }
/// <summary> /// Creates a window. /// </summary> /// <param name="rootModel">The view model.</param> /// <param name="dialog">Whethor or not the window is being shown as a dialog.</param> /// <param name="context">The view context.</param> /// <param name="settings">The optional popup settings.</param> /// <returns>The window.</returns> protected virtual Window CreateWindow(object rootModel, bool dialog, object context, IDictionary<string, object> settings) { var view = new Window(rootModel, dialog, context, settings); var haveDisplayName = rootModel as IHaveDisplayName; if (haveDisplayName != null) { view.DisplayName = haveDisplayName.DisplayName; } var useActions = rootModel as IUseActions; if (useActions != null) { useActions.Actions = this.actionBuilderFactory; } this.ApplySettings(view, settings); new WindowConductor(rootModel, view); return view; }