Tip: Readable Markup
In my WPF and XAML Coding Guidelines page (which I’ll be updating soon) I discussed a little rule I follow to keep my markup looking nice. Daniel Crenna has provided a nice VS addin that reformats XAML by lining up the attributes. His post has a nice animation that shows what the tool does. The Ctrl+K, Ctrl+Z shortcuts are now permanently mapped to my brain
My only complaint is that the XAML is formatted according to the position of the first attribute, rather than putting the first attribute on the next line ensuring a constant indentation level. I’m sick of formatting XAML manually though, so I’m more than happy to follow his convention given it is automated.
Filed under: WPF


I’ve been using the same formatting as you, and I’ve been annoyed by the way markup is indented when pasting.
You may want to vote for the following:
“Pasting XAML does not indent attributes”
https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=345939&SiteID=470
See also Laurent Bugnion’s post about XMAL formatting: http://geekswithblogs.net/lbugnion/archive/2007/09/29/Cleaning-up-XAML-code-and-improving-parsing-time-with-Blend.aspx
Visual Studio can do most of the work without any additional add-in.
Paul,
I found this in my travels and thought your readers might like it..
http://www.dimebrain.com/2008/05/automating-read.html