public MainWindow(IAvalonDockLayoutViewModel av, IApplicationViewModel appVm) { InitializeComponent(); dockView.SetTemplates(av.ViewProperties.SelectPanesTemplate, av.ViewProperties.DocumentHeaderTemplate, av.ViewProperties.SelectPanesStyle, av.ViewProperties.LayoutInitializer, av.LayoutId); // Register these methods to receive PRISM event notifications about load and save of avalondock layouts LoadLayoutEvent.Instance.Subscribe(dockView.OnLoadLayout, ThreadOption.PublisherThread, true, s => s.LayoutId == av.LayoutId); // subscribe to close event messing to application viewmodel Closing += appVm.OnClosing; // When the ViewModel asks to be closed, close the window. // Source: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx appVm.RequestClose += delegate { // Save session data and close application appVm.OnClosed(this); }; }
/// <summary> /// Class constructor /// </summary> /// <param name="av"></param> /// <param name="appVm"></param> public MainWindow(IAvalonDockLayoutViewModel av, IApplicationViewModel appVm ) : this() { if (DesignerProperties.GetIsInDesignMode(this)) { return; } _av = av; dockView.InitTemplates(_av.ViewProperties.SelectPanesTemplate, _av.ViewProperties.DocumentHeaderTemplate, _av.ViewProperties.SelectPanesStyle, _av.ViewProperties.LayoutInitializer, _av.LayoutId); // Register this methods to receive event notifications about // load and save of avalondock layouts _av.LoadLayout += dockView.OnLoadLayout; // subscribe to close event messing to application viewmodel Closing += appVm.OnClosing; // When the ViewModel asks to be closed, close the window. // Source: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx appVm.RequestClose += delegate { // Save session data and close application appVm.OnClosed(this); }; }