Make Visual Studio 2013 use Self-Closing Tags for XAML - visual-studio

I've just started messing around with WPF, and something I've noticed is that when writing in Visual Studio's XAML editor, tags that I'd like to be formatted as self-closing tags (for example <Setter />) always get auto-completed to have a separate closing tag, like <Setter></Setter>. Is there a way to change this behavior, or am I stuck reformatting those tags by hand?

I do not see one in the Visual Studio options but there is one in the Resharper options.
Resharper menu -> Code Editing -> XAML -> Editor -> Check "Always create self-closed tags in code completion"

Related

Visual Studio extension: How to make editor text behave like a link

I would like to write a Visual Studio extension, that makes a part of the text behave like a link: blue, underlined on hover, open a URL on click. (Like the default editor works for http://... texts.)
I can do classification (coloring) and also custom adornments and commands, so I could probably make this "manually", but I wonder if there is an easier way to do that.
I am interested to do this in normal Visual Studio (2017 or newer), not VS Code.
You can use UrlTag.
On how to use tags see Walkthrough: Highlight text and Visual Studio 2017 Extension development tutorial part 5: Highlight code in Editor.

Is there a feature in VIsual Studio or Resharper that can extract XAML into a separate file?

In ASP.NET Forms and MVC, you can select a block of code and extract it into a separate user control or file using Resharper and possibly Visual Studio. I cannot find such a feature for XAML. Does it exist in either Resharper or Visual Studio? If so, how do you perform this action?
I think you are looking for this:
https://www.jetbrains.com/help/resharper/ReSharper_by_Language__XAML__Refactorings.html
Resharper allows you to extract styles and resources, but you have to select the XAML and go to Resharper->Refactor->Extract in order to find the options, you won't see them if you use ALT+ENTER.

How to add custom HTML Tags to Visual Studio and Avoid Squiggly Lines

I'm using Visual Studio 2013 to create raw HTML pages (i.e. index.html).
In my HTML I am implementing custom HTML tags. As such, Visual Studio underlines my custom tags with squiggly lines (due to the warning of "Unknown element ...").
In hopes to get rid of the squigglies, I added my custom tags to the list of "Tag Specific Options" via Tools > Options > Text Editor > HTML (Web Forms) > Formatting > Tag Specific Options. However, the squiggly lines persist.
Is there a way to inform VS2013 that my custom HTML tags are valid (i.e. keep VS2013 from underlining my custom tags with squigglies)?
Visual Studio 2013 Update 4 removes the validation in .html files, but not in .aspx files.
Support for custom elements, polymer-elements and attributes
We no longer validate unknown attributers for custom elements as there
will be many custom made tags in different frameworks. So there will
no longer be squiggles under the unknown elements.
— Announcing new Web Features in Visual Studio 2013 Update 4 RC
Download Visual Studio 2013 Update 4.
Validation is only removed in the HTML editor, not the HTML (Web Forms) editor. This means that, by default, .html files will not have custom element validation, but .aspx pages will. If, like me, you don't think this makes sense, show your support by voting for custom elements in .aspx files.
Hmm... what are you trying to accomplish? Keep in mind that if you could somehow make visual studio ignore the unknown element, that's no guarantee browsers looking at your page will be able to translate the element too.
Are your pages HTML5? if so you've got a shot at making it work. but you'll have to define it in client code. Here is source.
But most browsers don't support it yet! look at here elements.
In the case of making Visual Studio recognise the tags you could take this approach:
1) Go to: Tools > Options > Text Editor > HTML (Web Forms) > Formatting
2) Press "Tag Specific Options"
3) Select "Client HTML Tags" in the new window's treeview
4) Press "New Tag" below the treeview to add a new tag

How to disable Visual Studio "smart" way to replace IDs in markup

From the hundreds of Visual Studio options, is there one to disable the way VS replace the IDs in markup when copy&paste from other control?
Almost always only need to change a few characters but VS thinks he is being smart replacing all the ID
Go into Tools > Options > Text Editor > HTML > Miscellaneous and uncheck "Auto ID elements on paste in Source view"
source:
How do you customize the copy/paste behavior in Visual Studio 2008?
but in 2010 it is the same

Visual Studio uses XHTML tag closing for HTML5 tags

Whenever I type out tags that don't require an end tag, Visual Studio adds a forward slash to it, as if they were XHTML.
I think this is unclean and annoying, and I'm hoping anyone can tell me how to fix or work around this issue.
It even happens when I complete <!DOCTYPE html with a >, and it'll form <!DOCTYPE html />.
For completeness I'm posting this answer. Although we're in 2014 now, with Visual Studio 2013 and HTML5 is getting more and more supported by the major browsers, Visual Studio still behaves the same as ... like always?
The option is just a bit different than in 2010 I assume (based on accepted answer).
What you could do is disable the auto closing tag option in Visual Studio.
Go to Tools >> Options >> Text Editor >> HTML >> Formatting
Uncheck the "Auto insert close tag" option.
This will now allow you to type <br> (for example) and it won't auto-complete it as <br />
For Visual Studio 2012, go to Tools -> Options -> Text Editor -> HTML -> Formatting and click Tag Specific Options.
Under Default Settings -> Client tag does not support contents, set Closing tag to No closing tag.

Resources