private static void AddClosingByRequest <TView>(TView view, LayoutContent layoutDocument) where TView : class, IView { if (!(view.ViewModel is ViewModelBase baseViewModel)) { return; } Observable .FromEventPattern <ViewModelCloseQueryArgs>( x => baseViewModel.CloseQuery += x, x => baseViewModel.CloseQuery -= x) .Subscribe(x => { layoutDocument.Close(); }) .DisposeWith(baseViewModel.Disposables); Observable .FromEventPattern <CancelEventArgs>( x => layoutDocument.Closing += x, x => layoutDocument.Closing -= x) .Subscribe(x => { var vcq = new ViewModelCloseQueryArgs { IsCanceled = false }; baseViewModel.Closing(vcq); if (vcq.IsCanceled) { x.EventArgs.Cancel = true; } }) .DisposeWith(baseViewModel.Disposables); Observable .FromEventPattern( x => layoutDocument.Closed += x, x => layoutDocument.Closed -= x) .Subscribe(_ => baseViewModel.Closed(new ViewModelCloseQueryArgs { IsCanceled = false })) .DisposeWith(baseViewModel.Disposables); }
public void CloseWindowByContent(object obj) { LayoutContent layoutContent = dockingManager.Layout.ActiveContent; layoutContent.Close(); }
private void Close_Executed(object sender, ExecutedRoutedEventArgs e) { LayoutContent activeContent = dockManager.Layout.ActiveContent; activeContent.Close(); }