Skip to content

emu2021makuake/XAML-code-snippets-for-VS2019

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

XAML-code-snippets-for-VS2019

XAML code snippets for Visual Studio 2019.

You can enter it with a shortcut like Emmet.

Installation procedure

  1. Select Tools - Code Snippets Manager from the menu.

01

  1. Select the Import button.

02

  1. Select the Xammet.snippet file you downloaded and click the Open button.

03

  1. Select the Finish button.

04

Usage

Enter the shortcut command and type Tab.

05

06

List of snippets

Shortcut Insert code Description
btn <Button Content="Button" Margin="5" /> Button
btn# <Button x:Name="btn1" Content="Button" Margin="5" /> Button with name
check <CheckBox Content="CheckBox" IsChecked="True" Margin="5" /> CheckBox
check# <CheckBox x:Name="check1" Content="CheckBox" IsChecked="True" Margin="5" /> CheckBox with name
radio <RadioButton Content="RadioButton" IsChecked="True" Margin="5" /> RadioButton
radio# <RadioButton x:Name="radio1" Content="RadioButton" IsChecked="True" Margin="5" /> RadioButton with name
lbl <Label Content="Label" Margin="5" /> Label
tblk <TextBlock Text="TextBlock" Margin="5" /> TextBlock
tbx <TextBox Text="TextBox" Margin="5" /> TextBox
tbx# <TextBox x:Name="txt1" Text="TextBox" Margin="5" /> TextBox with name
lbl+tbx <Label Content="Item Name1" Margin="5,5,5,0" Padding="0" />
<TextBox Text="Item Value1" Margin="5,0,5,5" />
Label and TextBox
tblk+tbx <TextBlock Text="Item Name1" Margin="5,5,5,0" />
<TextBox Text="Item Value1" Margin="5,0,5,5" />
TextBlock and TextBox
list <ListBox ItemsSource="{}" SelectedIndex="0" Margin="5" /> ListBox
list# <ListBox x:Name="list1" ItemsSource="{}" SelectedIndex="0" Margin="5" /> ListBox with name
list>li <ListBox SelectedIndex="0" Margin="5">
<ListBoxItem Content="item1" />
</ListBox>
ListBox containing ListBoxItem
combo <ComboBox ItemsSource="{}" SelectedIndex="0" Margin="5" /> ComboBox
combo# <ComboBox x:Name="combo1" ItemsSource="{}" SelectedIndex="0" Margin="5" /> ComboBox with name
combo>ci <ComboBox SelectedIndex="0" Margin="5">
<ComboBoxItem Content="item1" />
</ComboBox>
ComboBox containing ComboBoxItem
border <Border BorderBrush="Black" BorderThickness="1" Height="100" Width="100" /> Border
rect <Rectangle Fill="LightGray" Height="100" Width="100" Stroke="Black" /> Rectangle
img <Image Source="image1.png" /> Image
rds <Grid.RowDefinitions></Grid.RowDefinitions> Grid RowDefinitions
cds <Grid.ColumnDefinitions></Grid.ColumnDefinitions> Grid ColumnDefinitions
grid <Grid></Grid> Grid
stack <StackPanel></StackPanel> StackPanel
stackh <StackPanel Orientation="Horizontal"></StackPanel> Horizontal StackPanel
wrap <WrapPanel></WrapPanel> WrapPanel
dock <DockPanel></DockPanel> DockPanel
stack>btn*3 <StackPanel>
<Button Content="Button1" Margin="5,5,5,0" />
<Button Content="Button2" Margin="5,5,5,0" />
<Button Content="Button3" Margin="5,5,5,0" />
</StackPanel>
StackPanel containing 3 Buttons
stackh>btn*3 <StackPanel Orientation="Horizontal">
<Button Content="Button1" Margin="5,5,0,5" />
<Button Content="Button2" Margin="5,5,0,5" />
<Button Content="Button3" Margin="5,5,0,5" />
</StackPanel>
Horizontal StackPanel containing 3 Buttons
rds>rd*2 <Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
2 rows Grid
rds>rd*3 <Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
3 rows Grid
cds>cd*2 <Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
2 columns Grid
cds>cd*3 <Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
3 columns Grid
style <Style TargetType="Button"></Style> Style
style# <Style x:Key="key1" TargetType="Button"></Style> Style with key
winres <Window.Resources></Window.Resources> Window Resources
pgres <Page.Resources></Page.Resources> Page Resources
ucres <UserControl.Resources></UserControl.Resources> UserControl Resources
menu <Menu></Menu> Menu
menu>mi <Menu>
<MenuItem Header="Item1" />
</Menu>
Menu containing MenuItem
cmenu <ContextMenu></ContextMenu> ContextMenu
cmenu>mi <ContextMenu>
<MenuItem Header="Item1" />
</ContextMenu>
ContextMenu containing MenuItem

FYR Visual Studio 2019 default snippets

Shortcut Insert code Description
#region <!--#region NewRegion -->
<!--#endregion-->
Collapsible XAML regions
ddc d:DataContext="{d:DesignInstance Type=local:MyViewModel, IsDesignTimeCreatable=True}" DataContext attribute at design time
rd <RowDefinition Height="1*" /> Grid row definition
cd <ColumnDefinition Width="1*" /> Grid column definition
set <Setter Property="Background" Value="Red" /> Setter
tag <Grid></Grid> Any tag

Reference link

For Visual Studio Code here.