XAMLRegion2013_3

XAML Regions & Visual Studio 2013

I have recently posted an update to my XAML Regions plugin that adds compatibility for Visual Studio 2013. Check it out on the Visual Studio Code Gallery.

This version still maintains support for Visual Studio 2010 & 2012, along with .NET 4.0.

VS2013

This will probably be the last release that supports Visual Studio 2010 and .NET 4.0. When Visual Studio v13.X comes out (Visual Studio 2014 or whatever they will call it), I will probably drop support for Visual Studio 2010 and .NET 4.0. Compatibility with 2010 and 4.0 are a little burdensome to maintain because Microsoft’s newest extension framework doesn’t support them as clearly as newer versions. If you’re still using 2010 and think this is a big mistake, I’d love to hear from you.

XAML Regions: A Visual Studio 2010 Extension

If you’re like me, dealing with giant XAML files is problematic. I don’t seem to possess the mental stack that some XAMLers have that allows them to deal with pages upon pages of disorganized XAML code. I frequently run into this dilemma when I deal with WPF themes. They’re usually colors, brushes, styles and templates for every single WPF control in existence all crammed into one file. I have to rely on text searches for terms like “Button” to find what I’m looking for. I found myself pleading to the markup language gods for the regioning system I had grown so accustomed to in C#. My prayers combined with my Internet searches lacked the fecundity to bare any useful results, so I was on my own. Luckily, Visual Studio 2010 has a pretty easy-to-use Extension Framework. As such, I whipped up a plugin that allows XAML regions. Like most things of this nature, I see no pressing reason to hoard it all to myself.

XAML Regions Extension For Visual Studio 2010

XAML Regions Extension For Visual Studio 2010

Using The Extension

There’s nothing particularly complex about using this extension. I wanted to make it so that people without this extension didn’t have trouble working with code from people who did have the extension. I chose to make it so that XAML regions were defined in XML comments. One would start a XAML region by having a few lines that consist of

1
2
3
<!-- Region (Any Text You Want) -->
Your Code
<!-- EndRegion -->

Spacing, prefix hash characters, and description text are all generally optional. All of the following uses are supported:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!-- Region Hello World -->
Your code
<!-- End Region -->
 
<!-- RegionHello World -->
Your code
<!-- EndRegion -->
 
<!-- #Region Hello World -->
Your code
<!-- #End Region -->
 
<!-- #Region Hello World -->
Your code
<!-- #EndRegion -->
 
<!-- Region Hello World -->
Your code
<!-- End Region Hello World -->

That’s really all there is to it!

Grab it at the Visual Studio Gallery

Updated in 0.4

  1. Added the ability to have hash character prefixes (e.g., <!– #Region –>)
  2. IAdded the ability to have description text in the EndRegion area (e.g., <!– End Region (Your Text) –>)

Enjoy!