static int GetEmptyCount(VariablesWindowKind windowKind)
        {
            switch (windowKind)
            {
            case VariablesWindowKind.Watch:
                // The edit text box is always present when the window is open
                return(1);

            case VariablesWindowKind.None:
            case VariablesWindowKind.Locals:
            case VariablesWindowKind.Autos:
                return(0);

            default:
                Debug.Fail($"Unknown vars window kind: {windowKind}");
                return(0);
            }
        }
        public void SetTreeView(ITreeView treeView, VariablesWindowKind windowKind)
        {
            var listView = (ListView)treeView?.UIObject;

            if (treeViewContentPresenter.Content == listView)
            {
                return;
            }
            if (treeViewContentPresenter.Content is UIElement oldElem)
            {
                oldElem.PreviewTextInput -= TreeView_PreviewTextInput;
            }
            if (listView != null)
            {
                listView.PreviewTextInput += TreeView_PreviewTextInput;
            }
            treeViewContentPresenter.Content = listView;
            AutomationPeerMemoryLeakWorkaround.SetEmptyCount(listView, GetEmptyCount(windowKind));
            if (listView != null)
            {
                var gridView = (GridView)FindResource("GridView");
                listView.View = gridView;
            }
        }