/// <summary> /// Renders this view. /// </summary> public override void Render() { var dispatcher = ControllerContext.Request.Navigator.Dispatcher; dispatcher.Dispatch( delegate { TraceSources.MagellanSource.TraceInformation("The PageViewEngine is rendering the page '{0}'.", viewType); // Prepare the page RenderedInstance = (FrameworkElement)viewActivator.Instantiate(viewType); ViewInitializer.Prepare(RenderedInstance, Model, ControllerContext.Request); // Navigate to the page var navigationService = ControllerContext.Request.Navigator; NavigationMonitor.EnsureBound(navigationService, ViewInitializer); navigationService.NavigateDirectToContent(RenderedInstance, ControllerContext.Request); TraceSources.MagellanSource.TraceVerbose("The PageViewEngine has navigated to the page '{0}'.", viewType); // Remove all back entries from the navigation journal if necessary var clearHistory = Options.GetResetHistory(); if (clearHistory) { TraceSources.MagellanSource.TraceVerbose("The PageViewEngine is clearing the navigation history.", viewType); navigationService.ResetHistory(); } }); }
/// <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); }); }
public override void Render() { View = new TView(); ViewInitializer.Prepare(View, Model, ControllerContext.Request); }