# areas in XAML

I really don't like #region in my code. BUT for some reason they called me, I would like to have them in my XAML. I would like entire sections to have # area-like things and collapse them (e.g. my <Window.CommandBindings>, <Grid. * Definitions>, <Menu>, <Toolbar> etc.

Does it exist? If not, what about <RegionCollapse>

+44
visual-studio wpf xaml
May 22 '10 at 1:59 p.m.
source share
8 answers

I may miss the point of your request, but the XAML editor automatically places folding areas around the elements. Notice the nodes in the left guide of the editor window. Press "-" and the related item will fall on one line, like #region.

+20
May 22 '10 at 14:18
source share
+49
Mar 02 '11 at 3:13
source share

Visual Studio 2015 finally adds support for regions in XAML. You attach your area code as follows:

<!--#region RegionName--> All Your XAML In Here <!--#endregion--> 

This will add a collapse icon to the left of the start line, with which you can expand / collapse the region.

I do not know how convenient this would be, since we can already collapse / expand any node in the XAML editor. It is there if you want to use.

+49
Oct 26 '15 at 5:38
source share

No, but according to this answer from Microsoft:

This is a great offer. Thank you very much. We will consider it for a future release.

+8
May 22, '10 at 14:11
source share

FYI: this one has been updated to work well with VS 2012 http://visualstudiogallery.msdn.microsoft.com/3c534623-bb05-417f-afc0-c9e26bf0e177

And this VS2012 extension does a good job of decorating XAML, so attributes automatically sort and align, etc. http://xamlstyler.codeplex.com/documentation

+4
Nov 06 '12 at 17:20
source share

In Visual Studio 2012 Update 4, I was able to select a very large section of XAML code, right-click and select "hide selection". (basically collapses this section with the record [...], and after its expansion the system โ€œremembersโ€ that I wanted to collapse this part with [-] notation next to line numbers.

+4
Dec 04 '13 at 6:17
source share

You can add comments to the XAML file using SSI formatting:

 <!-- Grid Styles --> <style...> <style...> <!-- Window Styles --> <style...> <style...> <style...> 

This, at the very least, gives you some sort of โ€œheaderโ€ if you are using XML built-in failure.

+1
May 03 '11 at 3:47 a.m.
source share

Yes,

VS2010 will remember the collapsed areas, but be careful that this stopped working when I applied SP1 (as well as much more). After removing VS2010 (and any extensions) and following the installation procedure, the XAML elements that were collapsed seem to be well remembered:

  • Install VS2010 (Pro in my case)
  • Install Windows VS2010 Updates (including XML Editor One, 200 MB +)
  • Install Service Pack 1 (SP1) Installation
  • Install Windows VS2010 SP1 Updates

May help someone.

+1
Jan 06 '12 at 15:03
source share



All Articles