private void ClosingItemHandlerImpl(ClosingItemCallbackArgs args) { //in here you can dispose stuff or cancel the close //here's your view model: var simpleViewModel = args.DragablzItem.DataContext as SimpleViewModel; Debug.Assert(simpleViewModel != null); //here's how you can cancel stuff: //args.Cancel(); }
/// <summary> /// Callback to handle tab closing. /// </summary> private static void ClosingTabItemHandlerImpl(ClosingItemCallbackArgs <TabablzControl> args) { //in here you can dispose stuff or cancel the close //here's your view model: var viewModel = args.DragablzItem.DataContext as HeaderedItemViewModel; Debug.Assert(viewModel != null); //here's how you can cancel stuff: //args.Cancel(); }
private void ClosingTabItemHandlerImpl(ClosingItemCallbackArgs <TabablzControl> args) { var container = (ViewContainer)args.DragablzItem.DataContext; if (container.Equals(Selected)) { Selected = _data.FirstOrDefault(vc => vc != container); } var disposable = container.Content as IDisposable; if (disposable != null) { disposable.Dispose(); } }
/// <summary> /// Callback to handle floating toolbar/MDI window closing. /// </summary> private static void ClosingFloatingItemHandlerImpl(ClosingItemCallbackArgs <Layout> args) { //in here you can dispose stuff or cancel the close //here's your view model: var disposable = args.DragablzItem.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } //here's how you can cancel stuff: //args.Cancel(); }
private void CloseFloatingItemExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) { var dragablzItem = executedRoutedEventArgs.Parameter as DragablzItem; if (dragablzItem == null) { throw new ApplicationException("Parameter must be a DragablzItem"); } var cancel = false; if (ClosingFloatingItemCallback != null) { var callbackArgs = new ClosingItemCallbackArgs <Layout>(Window.GetWindow(this), this, dragablzItem); ClosingFloatingItemCallback(callbackArgs); cancel = callbackArgs.IsCancelled; } if (cancel) { return; } //TODO ...need a similar tp manual inter tab controlller here for the extra hook var item = _floatingItems.ItemContainerGenerator.ItemFromContainer(dragablzItem); CollectionTeaser collectionTeaser; if (CollectionTeaser.TryCreate(_floatingItems.ItemsSource, out collectionTeaser)) { collectionTeaser.Remove(item); } else { _floatingItems.Items.Remove(item); } }