views:

31

answers:

1

I like the grouping and browsability that regions provide in C# code but don't like the manual process of maintaining them (even auto-formatting tools are not perfect as they take awhile for large files), and other developers don't like them at all, so a better solution would be one that is done automatically by the IDE and without touching code. Visual Studio already has something along these lines with the Navigation Bar to browse classes and members alphabetically, but it provides no grouping by code element type. What I'd like to do is have the Navigation Bar have three sections instead of two: the first shows classes, the second shows members sorted alphabetically, and the third would show members nested by element type, like regions provide (e.g. Fields, Properties, Public Methods, Event Handlers, etc.). Can I gain access to this Navigation Bar in any way through the Visual Studio SDK, and if not, could I add a similar graphical element to the code editor and build it from scratch? The alternative is implementing my idea in a tool window and docking it, similar to ReSharper's File Structure window, which would be less ideal. Thanks!

A: 

I don't think you can extend built-in navigation bar for what you want, but in Visual Studio 2010 you can create your own nav bar as a view margin IWpfTextViewMargin. In your implementation you would need to scan current file for classes and members using the Code Model API and synchronize what you show with the caret movement.

Oleg Tkachenko