Follow Up. I discovered ReSharper can format XAML too. Details at the end.
This post describes how to set up Visual Studio 2010 to format “Attribute Hide & Seek” XAML like this
into the one-attribute-per-line format I prefer.
Adding the two formatting commands to the XAML editor context menu makes reformatting easy and convenient.
First, setup VS’s XAML format per this blog post (found via stackoverflow). Then reformat all or just the selected XAML from the Edit | Advanced submenu:
Notice that the menu commands are Format Document and Format Selection. The word “Format” is first in both.
Adding these commands to the XAML editor context menu was more of a hassle than it should have been, IMO. I looked for “Format Document” and “Format Selection” without success in all the Categories in the Add Command dialog. I found the commands quickly using the searchable Options / Keyboard dialog box. Note they are “Edit.Format*”.
However, in the UNsearchable, UNfilterable Add Command dialog they are inconveniently listed as “Document Format” and “Selection Format”.
Here is my updated popup menu shown on some XAML whose top line is about 3 monitors long. (I put Format Selection first because I think it will get used most often.)
I like the formatted XAML better.
ReSharper formats XAML with its (duh!) XML Formatting Style.
A keyboard shortcut to ReSharper _Silent Cleanup Code works well.
No comments:
Post a Comment