private static void CloseTab(ItemActionCallbackArgs <TabablzControl> args)
 {
     if (!((TabBase)args.DragablzItem.Content).Cancel())
     {
         args.Cancel();
     }
 }
        //[Obsolete("This is old the code from the MetroTabControl")]
        //private void TabControl_TabItemClosing(object sender, BaseMetroTabControl.TabItemClosingEventArgs e)
        //{
        //    var tab = e.ClosingTabItem as TabItem;
        //    if (tab == null)
        //        return;

        //    e.Cancel = !CloseTab(tab);
        //}


        private void TabControlDragablz_TabItemClosing(ItemActionCallbackArgs <TabablzControl> e)
        {
            var tab = e.DragablzItem.DataContext as TabItem;

            if (tab == null)
            {
                return;
            }

            if (!CloseTab(tab))
            {
                e.Cancel();
            }
        }
Example #3
0
        /// <summary>
        /// Callback to handle tab closing.
        /// </summary>
        private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args)
        {
            //in here you can dispose stuff or cancel the close

            //here's your view model:
            var viewModel = args.DragablzItem.DataContext as TabContent;

            if (viewModel != null)
            {
                string title = Container?.Resolve <ILocalizerService>(ServiceNames.LocalizerService)?.GetLocalizedString("OverviewPageTitle");

                if (viewModel.Header.Equals(title))
                {
                    args.Cancel();
                }
            }

            //Debug.Assert(viewModel != null);

            //here's how you can cancel stuff:
            //args.Cancel();
        }