/// <summary> /// Renders this view. /// </summary> public override void Render() { var dispatcher = ControllerContext.Request.Navigator.Dispatcher; dispatcher.Dispatch( delegate { TraceSources.MagellanSource.TraceInformation("The WindowViewEngine is instantiating the window '{0}'.", viewType); // Prepare the window RenderedInstance = (Window)viewActivator.Instantiate(viewType); ViewInitializer.Prepare(RenderedInstance, Model, ControllerContext.Request); RenderedInstance.Loaded += (s, e) => ViewInitializer.NotifyActivated(RenderedInstance); RenderedInstance.Closing += (s, e) => ViewInitializer.NotifyDeactivating(RenderedInstance, e); RenderedInstance.Closed += (s, e) => ViewInitializer.NotifyDeactivated(RenderedInstance); // Decide how to show it var dialog = Options.GetViewType() == "Dialog"; if (dialog) { TraceSources.MagellanSource.TraceVerbose("The WindowViewEngine is rendering the window '{0}' as a dialog.", viewType); RenderedInstance.ShowDialog(); } else { TraceSources.MagellanSource.TraceVerbose("The WindowViewEngine is rendering the window '{0}' as a normal window.", viewType); RenderedInstance.Show(); } }); }
/// <summary> /// Renders this view. /// </summary> public override void Render() { var dispatcher = ControllerContext.Request.Navigator.Dispatcher; dispatcher.Dispatch( delegate { TraceSources.MagellanSource.TraceInformation("CompositeViewResult is rendering the view '{0}'.", type.FullName); // Create the view var instance = (FrameworkElement)viewActivator.Instantiate(type); ViewInitializer.Prepare(instance, Model, ControllerContext.Request); // Figure out which region to use var region = Options.GetRegion(); if (region == null) { var regionName = Options.GetRegionName(); if (regionName == null) { throw new RegionNotProvidedException("No region nor region name was specified. Please use the InRegion methods on the CompositeView return value to indicate the region the view should be added to."); } var regionManager = Options.GetRegionManager() ?? ServiceLocator.Current.GetInstance <IRegionManager>(); region = regionManager.Regions[regionName]; } // Show the view region.Add(instance); }); }
/// <summary> /// Renders this view. /// </summary> public override void Render() { var dispatcher = ControllerContext.Request.Navigator.Dispatcher; dispatcher.Dispatch( delegate { TraceSources.MagellanSource.TraceInformation("The WindowViewEngine is instantiating the window '{0}'.", _type); // Prepare the window RenderedInstance = (ChildWindow)_viewActivator.Instantiate(_type); WireModelToView(RenderedInstance); TraceSources.MagellanSource.TraceVerbose("The ChildWindowViewEngine is rendering the window '{0}' as a dialog.", _type); RenderedInstance.Show(); }); }