XAML has no fixed set of elements: each framework supplies its own types. This page lists the elements of WPF that a file most often uses, with the properties and events a markup author writes. The type hierarchy matters for markup in one way: a property or event defined by a base class is available on every derived element, so the properties of FrameworkElement are on every element below.
Properties and events of every element
| Name | Type or values | Meaning |
|---|---|---|
Name / x:Name | XamlName | the name in the scope |
Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight | number, Auto (default NaN) | size in device-independent pixels (1/96 inch); Auto lets the layout decide |
Margin | Thickness | space outside the element |
HorizontalAlignment, VerticalAlignment | Left/Top, Center, Right/Bottom, Stretch | placement in the space the parent gives |
Visibility | Visible, Hidden (takes room), Collapsed (takes none) | whether it is drawn and laid out (UWP, WinUI: Visible, Collapsed) |
Opacity, OpacityMask, Effect, Clip | 0 to 1; a brush; a bitmap effect; a geometry | transparency, masks and clipping |
IsEnabled, IsHitTestVisible, Focusable, TabIndex, IsTabStop | Boolean, integer | input state |
RenderTransform, LayoutTransform, RenderTransformOrigin | Transform; a point from 0,0 to 1,1 | see transforms |
DataContext, Tag, ToolTip, ContextMenu, Cursor, FlowDirection, Language, Style, Resources, Triggers | object, object, object, ContextMenu, Cursor, LeftToRight/RightToLeft, string, Style, dictionary, trigger list | data, help, appearance and the style system |
Loaded, Unloaded, Initialized, SizeChanged, DataContextChanged, IsEnabledChanged, IsVisibleChanged, ToolTipOpening, ContextMenuOpening | events | life cycle and change notification |
MouseDown, MouseUp, MouseMove, MouseEnter, MouseLeave, MouseWheel, MouseLeftButtonDown, MouseLeftButtonUp, MouseRightButtonDown, MouseRightButtonUp and the Preview… forms | events | mouse input |
KeyDown, KeyUp, TextInput, PreviewKeyDown, PreviewKeyUp, PreviewTextInput, GotFocus, LostFocus, GotKeyboardFocus, LostKeyboardFocus | events | keyboard and focus |
TouchDown, TouchUp, TouchMove, StylusDown, StylusUp, ManipulationStarted, ManipulationDelta, ManipulationCompleted, Drop, DragEnter, DragLeave, DragOver | events | touch, pen and drag and drop |
Root and window types
| Element | Main members |
|---|---|
Window | Title, Icon, WindowStartupLocation (Manual, CenterScreen, CenterOwner), WindowState (Normal, Minimized, Maximized), WindowStyle (None, SingleBorderWindow, ThreeDBorderWindow, ToolWindow), ResizeMode, ShowInTaskbar, Topmost, SizeToContent, AllowsTransparency, Left, Top; events Activated, Deactivated, Closing, Closed, ContentRendered, StateChanged, LocationChanged, SourceInitialized |
Page | Title, WindowTitle, ShowsNavigationUI, KeepAlive |
UserControl | content property Content |
Application | StartupUri, ShutdownMode (OnLastWindowClose, OnMainWindowClose, OnExplicitShutdown), Resources; events Startup, Exit, Activated, Deactivated, DispatcherUnhandledException, SessionEnding |
Frame, NavigationWindow | Source, NavigationUIVisibility, JournalOwnership; events Navigating, Navigated, NavigationFailed, LoadCompleted |
Layout panels
| Element | Arrangement | Properties and attached properties |
|---|---|---|
Grid | rows and columns | RowDefinitions (RowDefinition Height MinHeight MaxHeight), ColumnDefinitions (ColumnDefinition Width …), ShowGridLines; attached Grid.Row, Grid.Column, Grid.RowSpan, Grid.ColumnSpan, Grid.IsSharedSizeScope, SharedSizeGroup |
StackPanel | one line | Orientation (Vertical, Horizontal) |
WrapPanel | lines that wrap | Orientation, ItemWidth, ItemHeight |
DockPanel | edges, then the rest | LastChildFill; attached DockPanel.Dock (Left, Top, Right, Bottom) |
Canvas | absolute positions | attached Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom, Panel.ZIndex |
UniformGrid | equal cells | Rows, Columns, FirstColumn |
VirtualizingStackPanel, VirtualizingPanel | a stack that makes only visible items | IsVirtualizing, VirtualizationMode |
Border | one child with a frame | BorderBrush, BorderThickness, CornerRadius, Background, Padding, Child |
Viewbox | scales its child | Stretch (None, Fill, Uniform, UniformToFill), StretchDirection |
ScrollViewer | scrolls its content | HorizontalScrollBarVisibility, VerticalScrollBarVisibility (Disabled, Auto, Hidden, Visible), CanContentScroll |
GridSplitter | a resizer inside a grid | ResizeDirection, ResizeBehavior, ShowsPreview |
Grid in MAUI and Avalonia; RelativePanel, VariableSizedWrapGrid (UWP, WinUI); FlexLayout, AbsoluteLayout, HorizontalStackLayout, VerticalStackLayout (MAUI); RelativePanel, WrapPanel (Avalonia) | the same ideas under other names | see below |
Content controls (one child)
| Element | Main members |
|---|---|
Button | Content, Command, CommandParameter, IsDefault, IsCancel, ClickMode (Release, Press, Hover), Click |
CheckBox, RadioButton, ToggleButton | IsChecked, IsThreeState, GroupName (RadioButton); events Checked, Unchecked, Indeterminate, Click |
Label, ContentControl | Content, ContentTemplate, Target (Label, with an access key _N) |
GroupBox, Expander | Header, IsExpanded, ExpandDirection; events Expanded, Collapsed |
ScrollViewer, Viewbox, Border, Popup | Popup: IsOpen, Placement, PlacementTarget, StaysOpen |
ToolTip, ContextMenu | set through ToolTip="text" or <Control.ToolTip>; ToolTipService.ShowDuration, InitialShowDelay |
Items controls (many children)
| Element | Main members |
|---|---|
ItemsControl | Items, ItemsSource, ItemTemplate, ItemsPanel, ItemContainerStyle, DisplayMemberPath, ItemStringFormat, GroupStyle, AlternationCount |
ListBox, ListView (with View: GridView with GridViewColumn Header DisplayMemberBinding Width), ComboBox, TabControl | SelectedItem, SelectedIndex, SelectedValue, SelectedValuePath, SelectionMode (Single, Multiple, Extended), IsSynchronizedWithCurrentItem; ComboBox: IsEditable, IsDropDownOpen, Text; TabControl: TabStripPlacement, TabItem Header; events SelectionChanged, DropDownOpened, DropDownClosed |
TreeView, TreeViewItem | Header, IsExpanded, IsSelected; events SelectedItemChanged, Expanded, Collapsed |
DataGrid (DataGridTextColumn, DataGridCheckBoxColumn, DataGridComboBoxColumn, DataGridTemplateColumn) | AutoGenerateColumns, Columns, CanUserAddRows, CanUserDeleteRows, IsReadOnly, SelectionUnit, GridLinesVisibility, RowDetailsTemplate |
Menu, MenuItem, ContextMenu, Separator, ToolBar, ToolBarTray, StatusBar, StatusBarItem | MenuItem: Header (_File makes F the access key), Command, InputGestureText, IsCheckable, IsChecked, Icon; event Click |
Text, input and range controls
| Element | Main members |
|---|---|
TextBlock | Text, Inlines (Run, Bold, Italic, Underline, Hyperlink, LineBreak, Span, InlineUIContainer), TextWrapping (NoWrap, Wrap, WrapWithOverflow), TextTrimming, TextAlignment, FontFamily, FontSize, FontWeight, FontStyle, Foreground, TextDecorations, LineHeight |
TextBox | Text, AcceptsReturn, AcceptsTab, MaxLength, IsReadOnly, TextWrapping, SpellCheck.IsEnabled, SelectionStart, SelectionLength, CharacterCasing; events TextChanged, SelectionChanged |
PasswordBox | Password (not bindable), PasswordChar, MaxLength; event PasswordChanged |
RichTextBox | content is a FlowDocument; IsDocumentEnabled, AcceptsTab |
Slider, ScrollBar, ProgressBar | Minimum, Maximum, Value, SmallChange, LargeChange, TickFrequency, IsIndeterminate (ProgressBar), Orientation; event ValueChanged |
Calendar, DatePicker | SelectedDate, DisplayDate, SelectedDates, BlackoutDates; event SelectedDatesChanged |
Image, MediaElement, InkCanvas | Image: Source, Stretch, StretchDirection; MediaElement: Source, LoadedBehavior, UnloadedBehavior, Volume, IsMuted; events MediaOpened, MediaEnded, MediaFailed |
Control (base) | Background, Foreground, BorderBrush, BorderThickness, Padding, FontFamily, FontSize, FontWeight, FontStyle, HorizontalContentAlignment, VerticalContentAlignment, Template, TabIndex; events MouseDoubleClick, PreviewMouseDoubleClick |
Documents
FlowDocument (PageWidth, ColumnWidth, IsOptimalParagraphEnabled) holds blocks: Paragraph, Section, List (ListItem, MarkerStyle), Table (TableRowGroup, TableRow, TableCell with ColumnSpan), BlockUIContainer; its inlines are Run, Span, Bold, Italic, Underline, Hyperlink (NavigateUri, event RequestNavigate), LineBreak, Figure, Floater, InlineUIContainer. Viewers: FlowDocumentReader, FlowDocumentPageViewer, FlowDocumentScrollViewer, DocumentViewer. FixedDocument holds PageContents that point at FixedPages of positioned glyphs, which is the markup of XPS documents.
The same things in other frameworks
| WPF | UWP, WinUI | MAUI | Avalonia |
|---|---|---|---|
Window, Page | Window (WinUI 3), Page | ContentPage, Shell | Window |
TextBlock | TextBlock | Label | TextBlock |
TextBox | TextBox | Entry, Editor | TextBox |
Button | Button | Button, ImageButton | Button |
CheckBox, ToggleButton | CheckBox, ToggleSwitch | CheckBox, Switch | CheckBox, ToggleSwitch |
ListBox, ListView | ListView, GridView | CollectionView, ListView | ListBox, ItemsControl |
StackPanel | StackPanel | VerticalStackLayout, HorizontalStackLayout, StackLayout | StackPanel |
Grid | Grid | Grid (RowDefinitions="Auto,*" as a string) | Grid (RowDefinitions="Auto,*" as a string) |
Margin, Padding | the same | Margin, Padding | the same |
Visibility | Visibility | IsVisible | IsVisible |
Click | Click | Clicked, Command | Click |
Not described
Known, not yet covered
- Reference: the elements of WPF are listed by the properties and events an author most often writes, not every dependency property of every type; the controls of the Ribbon, 3D (
Viewport3D,ModelVisual3D,MeshGeometry3D) and the speech and ink classes are not listed. - Reference: the element sets of WinUI, MAUI and Avalonia are given only as the comparison table above, not type by type.
Unknown
- Reference: none of the names was checked against the assemblies, which are not installed here; they come from Microsoft’s and Avalonia’s documentation.