Ejemplo n.º 1
0
        public ListBox GetHierarchyListBox()
        {
            SolutionHierarchy = VsShellUtilities.GetUIHierarchyWindow(ServiceLocator.GetInstance <IServiceProvider>(), VSConstants.StandardToolWindows.SolutionExplorer);

            ContentGrid = SolutionHierarchy.GetValue("Content") as Panel;
            if (ContentGrid == null || ContentGrid.Children.Count == 0)
            {
                return(null);
            }

            ContentPresenter = ContentGrid.Children[0] as ContentPresenter;
            if (ContentPresenter == null)
            {
                return(null);
            }

            ListBox listBox = null;

            switch (ContentPresenter.Content.GetType().FullName)
            {
            case SolutionPivotNavigator:
                listBox = ContentPresenter.Content.GetType().GetProperties()
                          .Single(p => p.Name == "TreeView" && p.PropertyType.FullName == SolutionPivotTreeView)
                          .GetValue(ContentPresenter.Content) as ListBox;
                break;

            case WorkspaceTreeView:
                listBox = ContentPresenter.Content as ListBox;
                break;
            }

            return(listBox);
        }