Controls
| Control | Prefix | Comments (Equivalent Windows Control) |
| Border | ||
| Button | btn | |
| Canvas | (Panel) | |
| Calendar | ||
| CheckBox | chb | |
| CollectionViewSource | (BindingSource) | |
| ComboBox | cbo | |
| ContentControl | A control controlling a single type of object. | |
| ContextMenu | (ContextMenuStrip) | |
| DataGrid | dgr | (DataGridView) |
| DatePicker | (DateTimePicker) Allows the user to select a specific date and/or time. | |
| DispatchTimer | (Timer) | |
| DocumentViewer | A document viewing control that can host FixedDocument content | |
| Ellipse | ||
| Expander | Represents the control that displays a header that has a collapsible window | |
| Frame | ||
| GridView | ||
| Grid | (TableLayoutPanel) | |
| GridSplitter | (SplitContainer) | |
| GroupBox | ||
| Image | (PictureBox) Allows you to have a repository of images in your assembly. | |
| Label | lbl | |
| ListBox | lsb | (CheckedListBox) |
| ListView | lsv | Allows the user to select a single (or multiple) items from a list with multiple columns. |
| MediaElement | A control containing audio and/or video. | |
| MediaPlayer | (SoundPlayer) | |
| Menu | ||
| PasswordBox | ||
| ProgressBar | Allows the user to indicate progress using a graphical bar. | |
| RadioButton | ||
| Rectangle | ||
| RichTextBox | Allows the user to display text with formatting. | |
| ScrollBar | (HScrollBar, VScrollBar) | |
| ScrollViewer | (ScrollableControl) A scrollable area that can contain other visible elements. | |
| Separator | ||
| Slider | (TrackBar) | |
| StackPanel | ||
| StatusBar | (StatusStrip) | |
| TabControl | ||
| TextBlock | ||
| TextBox | ||
| ToolBar | (ToolStrip, ToolStripPanel) | |
| TreeView | tvw | |
| ViewBox | ||
| WebBrowser | (WebBrowser) Allows the user to include a web browser on a form. | |
| WebView2 |
Border
Draws a border, background or both around an element
<Border Grid.Column="0"
Grid.Row="0"
BorderBrush="OrangeRed"
BorderThickness="2"/>
Button
Allows the user to run a separate subroutine.
<Button Name="btnCancel"
Grid.Column="
Grid.Row=""
Grid.ColumnSpan=""
Grid.RowSpan=""
Content="Cancel"
Click="btnCancel_Click"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsDefault="True"
IsCancel="False"
FontFamily="Microsoft Sans Serif"
FontSize="12">
</Button/>
Sizes
Standard - Height 20, Width ?
Small
Medium
Large - Height 280, Width 322
Closing
System.Windows.Window.GetWindow(this).Close();
Escape to Close
Button IsCancel="True"
Margins
Left, Top, Right, Bottom
Images
Set Build Action to "Resource" not "Embedded Resource"
<Button Name="btnCancel"
<Image Source="Resources/Image.png"
VerticalAlignment="Center"/>
</Button>
Arrows
Webdings 12 pt
Up - 5
Down - 6
Left - 3
Right - 4
size - (H30, W 80)
Calendar
Allows the user to select a date using a visual calendar.
Represents a control that enables a user to select a date using a visual calendar
CheckBox
Allows the user to either select or deselect an option.
ComboBox
Allows the user to either select an item from a drop-down box or enter a different item.
DataGrid
Allows the user to display (and edit) a table of information
<DataGrid Name="dtgProperties"
Grid.Row="0"
Grid.Column="2"
Grid.ColumnSpan="5"
AutoGenerateColumns="False"
RowHeaderWidth="0">
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Height" Value="35"/>
<Setter Property="Foreground" Value="white"/>
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Col1"/>
<DataGridTextColumn Header="Col2"/>
</DataGrid.Columns>
</DataGrid>
GroupBox
Allows you to group other controls together.
<GroupBox Name="GroupBox1"
Margin="0"
Header="text"
Grid.Column="1"
Grid.Row="1"
Grid.ColumnSpan="10"
Grid.RowSpan="10"
</GroupBox>
Label
Allows you to display text to the user.
<Label x:Name="Label_One"
Margin="0"
Padding="0"
Grid.Column="
Grid.Row=""
Grid.ColumnSpan=""
Grid.RowSpan=""
Content="This is some text">
</Label>
ListBox
Allows the user to select an item from a list of items.
<ListBox Name="ListBox_Name"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Grid.Column="1"
Grid.Row="1"
Margin="0">
<ListBoxItem Content="Monday" > </ListBoxItem>
<ListBoxItem Content="Tuesday" > </ListBoxItem>
</ListBox>
ListView
RadioButton
(OptionButton) Allows the user to select from a list of possible distinct options.
ToggleButton
base class for controls that can switch state such as: Checkbox and RadioButton
Rectangle
Displays a rectangle shape
There is no click event but you can achieve this by assigning a method to the MouseLeftButtonDown event handler
<Rectangle x:Name="Rectangle1"
MouseLeftButtonDown="Rectangle_MouseLeftButtonDown">
private void Rectangle_MouseLeftButtonDown(
object sender,
System.Windows.RoutedEventArgs e)
{
}
Slider
Allows the user to select from a range by moving a Thumb control along a track.
Represents a control that lets the user select from a range of values by moving a thumb control along a track
StackPanel
Arranges child elements into a single line horizontal or vertical.
Arranges child elements into a single line that can be either horizontal or vertical
(msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx)
This control measures in the direction of stacking at Double.PositiveInfinity
<stackpanel Name="StackPanel1"
Height=40
Width=200
Orientation="Vertical"
Grid.ColumnSpan="1"
Grid.Row="2"/gt
<Label Content="Single" FontSize="15" />
<Button> Button One</Button>
</stackpanel>
Similar to the WrapPanel except it does not wrap the content
Instead it stretches its content in one direction, allowing you to stack them
This control stretches its content by default, although this can be changed by overridding the HorizontalAlignment or VerticalAlignment properties of the child elements
TabControl
Allows you to display multiple tabs of the same controls.
A control that can contain multiple items that share the same space
<TabControl Name="TabControl1"
Height="Auto"
Width="Auto"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
Margin="10,10,10,31"
Background="Bisque">
<TabItem Header="TabItem">
<Grid Background="#FFE5E5E5"
Margin="10,10,10,10"/>
<TabItem Header="TabItem">
</TabControl>
TabItem Style
Defining a style for your TabItem controls
<Window.Resouces>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border Name="Border"
Background="LightBlue"
BorderBrush="Black"
BorderThickness="1,1,1,1"
CornerRadius="6,6,0,0">
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="12,2,12,2" /gt
</Border>
</Grid>
</ControlTemplate>
</Style>
</Window.Resouces>
Highlight Active Tab
TextBox
(EditBox) Allows you to display text and to allow the user to enter information.
<TextBox Name="TextBox_One"
Margin="0"
Grid.Column="" >
The first line of text
<LineBreak/>
The second line of text
<LineBreak/>
<LineBreak/>
Another line of text
</TextBox>
fontfamily
fontsize
TreeView
Allows you to display a hierarchy of nodes with parents and child.
<TreeView Name="tvwList"
Grid.Column=0
Grid.Row=0
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<TreeViewItem Header="one"/>
<TreeViewItem Header="two"/>
<TreeViewItem Header="three"/>
</TreeView>
System.Windows.Controls.TreeViewItem oTreeViewItem;
oTreeViewItem = new TreeViewItem();
oTreeViewItem.Header = "four";
this.tvwList.Items.Add(oTreeViewItem);
treeviewitem = (System.Windows.Controls.TreeViewItem) this.tvwName.SelectedItem
MouseLeftButtonDown
System.Windows.Control.TreeViewItem treeviewitem;
System.Windows.DependencyObject dependencyobject;
try
{
//identify which node as been selected
treeviewitem = e.Source as System.Windows.Controls.TreeViewItem;
dependencyobject = this.tvwXMLParts.InputHitTest(e.GetPosition(this.tvwXMLParts)) as System.Windows.DependencyObject;
if (dependencyobject is System.Windows.Controls.TextBlock)
{
//initiate the dragging
System.Windows.DragDrop.DoDragDrop(this.txtXMLPart,
this.tvwXMLParts.SelectedValue,
System.WIndows.DragDropEffects.Move);
e.Handled = true;
}
}
MouseRightButtonUp
System.Window.Controls.TreeViewItem treeviewitem;
//identify which node has been selected
treeviewitem = e.Source as System.Windows.Controls.TreeViewItem;
//displays the context menu
if (treeviewitem != null)
{
tvwXMLPartsContextMenu.PlacementTarget = this;
tvwXMLPartsContextMenu.IsOpen = true;
}
System.Windows.Controls.TreeViewItem treeviewitem = (System.Windows.Controls.TreeView)
SearchTreeView<System.Windows.Controls.TreeViewItem>
((System.Windows.DependencyObject)e.OriginalSource);
if (treeviewitem != null)
{
treeviewitem.IsSelected = true;
e.Handled = true;
}
WebBrowser
Allows the user to include a web browser on a form.
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext