Is there any way to add XAML snippets for XAML editor in Visual Studio 2010? For example I'd like to save my self from some typing and have something like this:
snippet:
gr<TAB>
generates code:
<Grid>
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
</Grid>
Then if I type for example: rd<TAB>
it should generate <RowDefinition />
Similarly, cd<TAB>
should generate <ColumnDefinition />
and similarly for other XAML elements.
I think you get the idea... The point is to make these snippets available only in XAML editor of the Visual Studio. Having them in other code editors inside Visual Studio (eg. when editing .cs files) doesn't have point.
In Visual Studio there are two kinds of code snippet: expansion snippets, which are added at a specified insertion point and may replace a snippet shortcut, and surround-with snippets (C# and C++ only), which are added around a selected block of code.
With a code file open in the editor, choose Snippets > Insert Snippet from the right-click menu, then My Code Snippets. You should see a snippet named Square Root. Double-click it. The snippet code is inserted in the code file.
To create or edit your own snippets, select User Snippets under File > Preferences (Code > Preferences on macOS), and then select the language (by language identifier) for which the snippets should appear, or the New Global Snippets file option if they should appear for all languages.
To open the XAML Designer, right-click a XAML file in Solution Explorer and choose View Designer. to switch which window appears on top: either the artboard or the XAML editor.
If you don't need parameters, then you can use the Toolbox!
Simply drag the code into the Toolbox and insert it wherever you want. This works for C# as well as for XAML.
From: http://blog.wpfwonderland.com/2012/04/16/xaml-snippets-and-visual-studio/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With