A core feature of Visual Studio that allows developers to inspect, analyze, and troubleshoot code during execution.
Not able to collapse Root Node under Server Explorer Hierarchy
We have a our custom hierarchy that we are showing in Visual Studio Server Explorer as a part of our extension. We are adding root node in the hierarchy like below (pseudo code)
class VsMyHierarchy : IVsUIHierarchy, IOleCommandTarget, IDisposable
{
private EventSinkCollection hierarchyEventSinks = new EventSinkCollection();
internal void Initialize()
{
imageList = GetImageList();
//Add the root node
AccountsNode rootNode = new AccountsNode(null);
rootNode .Caption = "ROOT ACCOUNTS";
rootNode.Hierarchy = this;
rootNode.ItemId = VSConstants.VSITEMID_ROOT;
rootNode.PopulateItem();
}
internal void AddNodeToHierarchy(VsNode node, bool fNotify)
{
if (this != node.Hierarchy)
node.Hierarchy = this;
if (fNotify)
{
uint itemidParent = (uint)VSConstants.VSITEMID_NIL;
uint itemidSiblingPrev = (uint)VSConstants.VSITEMID_NIL;
uint itemidAdded = node.ItemId;
HierEvts_OnItemAdded(itemidParent, itemidSiblingPrev, itemidAdded);
}
}
private void HierEvts_OnItemAdded(uint itemidParent, uint itemidSiblingPrev, uint itemidAdded)
{
foreach (IVsHierarchyEvents sink in hierarchyEventSinks)
{
sink.OnItemAdded(itemidParent, itemidSiblingPrev, itemidAdded);
}
}
public virtual int AdviseHierarchyEvents(IVsHierarchyEvents pEventSink, out uint pdwCookie)
{
pdwCookie = hierarchyEventSinks.Add(pEventSink) + 1;
return VSConstants.S_OK;
}
}
The class of Accounts and Account node is like below (pseudo code)
class AccountsNode : VsNode
{
void PopulateItem()
{
var accountNode1 = new AccountNode();
accountNode1.ItemId = 0;
accountNode1.Hierarchy.AddNodeToHierarchy(accountNode1,true);
}
}
class AccountNode : VsNode
{
// Code for AccountNode
}
class VsNode
{
// Code for VsNode
}
We are adding the hierarchy in Server Explorer using IVsUIHierarchyWindow.AddUIHierarchy. We can expand the root node "ROOT ACCOUNTS" but we are not able to collapse it. We have added nodes inside Child Node under Root Node and we can expand and collapse it without any issue. Only issue is with the ROOT Node.
Developer technologies | Visual Studio | Debugging
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.