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.

3 Responses to “Tip: Readable Markup”

  1. 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

  2. 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.

  3. Paul,
    I found this in my travels and thought your readers might like it..

    http://www.dimebrain.com/2008/05/automating-read.html

Leave a Reply