private void ListView_DragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args)
        {
            Logger.Instance.Debug($"ListView_DragItemsCompleted. Drop result: {args.DropResult}. Items count: {args.Items.Count}");

            var item = args.Items.FirstOrDefault();

            if (item is TerminalViewModel model)
            {
                if (ItemsSource.Count > 1 && !_itemWasDropped && args.DropResult == DataPackageOperation.None)
                {
                    TabDraggedOutside?.Invoke(sender, args);
                    _itemWasDropped = true;
                }

                if (_itemWasDropped)
                {
                    TabDraggingCompleted?.Invoke(sender, model);
                }

                model.TrayProcessCommunicationService.PauseTerminalOutput(model.Terminal.Id, false);
            }
        }
        private void TabView_DragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args)
        {
            _isDragging = false;

            // args.DropResult == None when outside of area (e.g. create new window)
            if (args.DropResult == DataPackageOperation.None)
            {
                var item = args.Items.FirstOrDefault();
                var tab  = ContainerFromItem(item) as TabViewItem;

                if (tab == null && item is FrameworkElement fe)
                {
                    tab = fe.FindParent <TabViewItem>();
                }

                if (tab == null)
                {
                    // We still don't have a TabViewItem, most likely is a static TabViewItem in the template being dragged and not selected.
                    // This is a fallback scenario for static tabs.
                    // Note: This can be wrong if two TabViewItems share the exact same Content (i.e. a string), this should be unlikely in any practical scenario.
                    for (int i = 0; i < Items.Count; i++)
                    {
                        var tabItem = ContainerFromIndex(i) as TabViewItem;
                        if (ReferenceEquals(tabItem.Content, item))
                        {
                            tab = tabItem;
                            break;
                        }
                    }
                }

                TabDraggedOutside?.Invoke(this, new TabDraggedOutsideEventArgs(item, tab));
            }
            else
            {
                // If dragging the active tab, there's an issue with the CP blanking.
                TabView_SelectionChanged(this, null);
            }
        }