Element, UIElement, FrameworkElement, Control markup reference
Extensions every element or control accepts: layout, alignment, visibility, input events, attached-property helpers, and control appearance.
Element
Section titled “Element”Receiver: Element and derived types (where T : Element).
| Method | Sets | Summary |
|---|---|---|
CanvasBottom(double bottom) |
Sets the canvas bottom position. | |
CanvasLeft(double left) |
Sets the canvas left position. | |
CanvasPosition(double left, double top) |
Sets the canvas position. | |
CanvasRight(double right) |
Sets the canvas right position. | |
CanvasTop(double top) |
Sets the canvas top position. | |
Column(int column) |
Sets the grid column. | |
ColumnSpan(int columnSpan) |
Sets the grid column span. | |
DockBottom() |
Docks the element to the bottom. | |
DockLeft() |
Docks the element to the left. | |
DockRight() |
Docks the element to the right. | |
DockTo(Dock dock) |
Sets the dock position. | |
DockTop() |
Docks the element to the top. | |
GridPosition(int row, int column) |
Sets the grid position. | |
GridPosition(int row, int column, int rowSpan, int columnSpan) |
Sets the grid position with spans. | |
Row(int row) |
Sets the grid row. | |
RowSpan(int rowSpan) |
Sets the grid row span. |
UIElement
Section titled “UIElement”Receiver: UIElement and derived types (where T : UIElement).
| Method | Sets | Summary |
|---|---|---|
AllowDrop(bool value = true) |
AllowDrop |
Sets whether the element accepts drops, taking part in drop-target hit testing and receiving DragEnter, DragOver, DragLeave and Drop. |
BackdropFallbackBrush(Brush value) |
BackdropFallbackBrush |
Sets the brush drawn in place of the backdrop where what is behind the element cannot be read; null draws nothing there. |
BackdropFilter(ImageFilter value) |
BackdropFilter |
Sets the filter applied to what is drawn behind the element, such as a blur for frosted glass. The element’s own background and content are drawn over the result. |
BindIsEnabled(ObservableValue<TSource> source, Func<TSource, bool> convert) |
bind IsEnabled |
Binds the enabled state to a converted observable value. |
BindIsEnabled(ObservableValue<bool> source) |
bind IsEnabled |
Binds the enabled state to an observable value. |
BindIsVisible(ObservableValue<TSource> source, Func<TSource, bool> convert) |
bind IsVisible |
Binds the visibility state to a converted observable value. |
BindIsVisible(ObservableValue<bool> source) |
bind IsVisible |
Binds the visibility state to an observable value. |
CacheMode(CacheMode value) |
CacheMode |
Sets how this element’s rendering is cached, or null for no cache. |
Cached(bool cached = true) |
Enables (or disables) bitmap caching of the element’s rendered output. The cached bitmap is blitted each frame until the element’s content, size, or DPI changes; the visual tree stays live. Equivalent to assigning a BitmapCache to CacheMode. | |
CanDrag(bool value = true) |
CanDrag |
Sets whether the element initiates drag sessions via a mouse gesture. |
Cursor(CursorType cursor) |
Cursor |
Sets the cursor type. |
Cursor(CursorType? value) |
Cursor |
Sets the cursor shown while the mouse is over this element; null inherits from the parent or the platform default, and None hides the cursor. |
Disable() |
IsEnabled = false |
Sets IsEnabled to false. |
Enable() |
IsEnabled = true |
Sets IsEnabled to true. |
Focusable(bool value = true) |
Focusable |
Sets whether this element can receive keyboard focus. |
IsEnabled(bool value = true) |
IsEnabled |
Sets whether the element is enabled for input. |
IsHitTestVisible(bool value = true) |
IsHitTestVisible |
Sets whether the element participates in hit testing. |
IsTabStop(bool value = true) |
IsTabStop |
Sets whether the element participates in Tab traversal. |
IsVisible(bool value = true) |
IsVisible |
Sets whether the element is visible. |
OnDragCompleted(Action<DragCompletedEventArgs> handler) |
event DragCompleted |
Subscribes handler to DragCompleted. Occurs once a drag session originating from this element has ended (drop, reject, or cancel). |
OnDragEnter(Action<DragEventArgs> handler) |
event DragEnter |
Subscribes handler to DragEnter. Occurs when a drag enters the element’s hit-test bounds. |
OnDragLeave(Action<DragEventArgs> handler) |
event DragLeave |
Subscribes handler to DragLeave. Occurs when a drag leaves the element’s hit-test bounds. |
OnDragOver(Action<DragEventArgs> handler) |
event DragOver |
Subscribes handler to DragOver. Occurs while a drag is over the element. |
OnDragStarting(Action<DragStartingEventArgs> handler) |
event DragStarting |
Subscribes handler to DragStarting. Occurs after a drag gesture is detected on this element; handlers populate Data and AllowedEffects to start the session, or set Cancel. |
OnDrop(Action<DragEventArgs> handler) |
event Drop |
Subscribes handler to Drop. Occurs when data is dropped onto the element. |
OnGotFocus(Action handler) |
event GotFocus |
Subscribes handler to GotFocus. Occurs when the element receives keyboard focus. |
OnKeyDown(Action<KeyEventArgs> handler) |
event KeyDown |
Subscribes handler to KeyDown. Occurs when a key is pressed while the element has focus; marking it handled also drops the text input the keystroke would produce. |
OnKeyUp(Action<KeyEventArgs> handler) |
event KeyUp |
Subscribes handler to KeyUp. Occurs when a key is released while the element has focus. |
OnLostFocus(Action handler) |
event LostFocus |
Subscribes handler to LostFocus. Occurs when the element loses keyboard focus. |
OnMouseDoubleClick(Action<MouseEventArgs> handler) |
event MouseDoubleClick |
Subscribes handler to MouseDoubleClick. Occurs when the user double-clicks a mouse button over the element. |
OnMouseDown(Action<MouseEventArgs> handler) |
event MouseDown |
Subscribes handler to MouseDown. Occurs when a mouse button is pressed over the element. |
OnMouseEnter(Action handler) |
event MouseEnter |
Subscribes handler to MouseEnter. Occurs when the mouse enters the element. |
OnMouseLeave(Action handler) |
event MouseLeave |
Subscribes handler to MouseLeave. Occurs when the mouse leaves the element. |
OnMouseMove(Action<MouseEventArgs> handler) |
event MouseMove |
Subscribes handler to MouseMove. Occurs when the mouse moves over the element. |
OnMouseUp(Action<MouseEventArgs> handler) |
event MouseUp |
Subscribes handler to MouseUp. Occurs when a mouse button is released over the element. |
OnMouseWheel(Action<MouseWheelEventArgs> handler) |
event MouseWheel |
Subscribes handler to MouseWheel. Occurs when the mouse wheel is scrolled over the element. |
Opacity(double value) |
Opacity |
Sets the opacity of the element and its subtree, from 0 to 1. |
Register(TemplateContext ctx, string name) |
Registers an element by name in a template context. | |
SkipViewportCull(bool value = true) |
SkipViewportCull |
Sets whether the element is drawn even when it lies outside the viewport; inherited by descendants. |
TabIndex(double value) |
TabIndex |
Sets the position in the Tab order. |
FrameworkElement
Section titled “FrameworkElement”Receiver: FrameworkElement and derived types (where T : FrameworkElement).
| Method | Sets | Summary |
|---|---|---|
Bottom() |
VerticalAlignment = Bottom |
Aligns the element to the bottom. |
Center() |
HorizontalAlignment = Center, VerticalAlignment = Center |
Centers the element horizontally and vertically. |
CenterHorizontal() |
HorizontalAlignment = Center |
Centers the element horizontally. |
CenterVertical() |
VerticalAlignment = Center |
Centers the element vertically. |
ContextMenu(ContextMenu value) |
ContextMenu |
Sets the menu shown when the pointer is right-pressed over this element. |
Height(double value) |
Height |
Sets the explicit height; NaN means automatic sizing. |
HorizontalAlignment(HorizontalAlignment value) |
HorizontalAlignment |
Sets the horizontal alignment within the parent. |
Left() |
HorizontalAlignment = Left |
Aligns the element to the left. |
Margin(Thickness value) |
Margin |
Sets the outer margin. |
Margin(double horizontal, double vertical) |
Sets the margin with horizontal and vertical values. | |
Margin(double left, double top, double right, double bottom) |
Sets the margin with individual values. | |
Margin(double uniform) |
Margin |
Sets the margin uniformly. |
MaxHeight(double value) |
MaxHeight |
Sets the maximum height in DIPs; the default is no bound. |
MaxWidth(double value) |
MaxWidth |
Sets the maximum width in DIPs; the default is no bound. |
MinHeight(double value) |
MinHeight |
Sets the minimum height in DIPs. |
MinWidth(double value) |
MinWidth |
Sets the minimum width in DIPs. |
OnLayoutSizeChanged(Action<SizeChangedEventArgs> handler) |
event SizeChanged |
Adds a size change handler. |
Right() |
HorizontalAlignment = Right |
Aligns the element to the right. |
Size(double size) |
Sets the size uniformly. | |
Size(double width, double height) |
Width, Height |
Sets the size. |
StretchHorizontal() |
HorizontalAlignment = Stretch |
Stretches the element horizontally. |
StretchVertical() |
VerticalAlignment = Stretch |
Stretches the element vertically. |
StyleSheet(StyleSheet value) |
StyleSheet |
Sets a StyleSheet that provides named styles and type-based style rules for descendant controls. |
Tag(object value) |
Tag |
Sets an arbitrary object value for custom use. |
ToolTip(Element value) |
ToolTip |
Sets what to show when the pointer rests on this element. |
ToolTip(string text) |
ToolTip |
Sets the tooltip text. |
Top() |
VerticalAlignment = Top |
Aligns the element to the top. |
VerticalAlignment(VerticalAlignment value) |
VerticalAlignment |
Sets the vertical alignment within the parent. |
Width(double value) |
Width |
Sets the explicit width; NaN means automatic sizing. |
WithTheme(Action<Theme, T> apply, bool invokeImmediately = true) |
Registers a theme callback. |
TextElement
Section titled “TextElement”Receiver: TextElement and derived types (where T : TextElement).
| Method | Sets | Summary |
|---|---|---|
FontFamily(string value) |
FontFamily |
Sets the font family; an empty value follows the theme’s font family. |
FontSize(double value) |
FontSize |
Sets the font size. |
FontStyle(FontStyle value) |
FontStyle |
Sets the font style, which selects the family’s italic face. |
FontWeight(FontWeight value) |
FontWeight |
Sets the font weight. |
Foreground(Color value) |
Foreground |
Sets the foreground (text) color. |
Receiver: Track.
| Method | Sets | Summary |
|---|---|---|
DecreaseElement(Element value) |
DecreaseElement |
Sets the element filling the region between the minimum end and the thumb. |
IncreaseElement(Element value) |
IncreaseElement |
Sets the element filling the region between the thumb and the maximum end. |
IsDirectionReversed(bool value = true) |
IsDirectionReversed |
Sets whether the minimum sits at the far end, as it does on a vertical slider. |
Maximum(double value) |
Maximum |
Sets the maximum value. |
Minimum(double value) |
Minimum |
Sets the minimum value. |
Orientation(Orientation value) |
Orientation |
Sets the axis the thumb travels along. |
Thumb(Thumb value) |
Thumb |
Sets the thumb element. |
ThumbLength(double value) |
ThumbLength |
Sets the thumb’s length along the axis; NaN takes the thumb element’s desired length. |
Value(double value) |
Value |
Sets the value the thumb is placed for. |
ViewportSize(double value) |
ViewportSize |
Sets the viewport size in value units, which sizes the thumb like a scroll bar; NaN keeps the thumb at ThumbLength, as a slider does. |
Control
Section titled “Control”Receiver: Control and derived types (where T : Control).
| Method | Sets | Summary |
|---|---|---|
Background(Color value) |
Background |
Sets the background color. |
Bold() |
FontWeight = Bold |
Sets the font weight to bold. |
BorderBrush(Color value) |
BorderBrush |
Sets the border color. |
BorderThickness(double value) |
BorderThickness |
Sets the border thickness. |
CornerRadius(double value) |
CornerRadius |
Sets the corner radius for background/border rendering. |
FontSize(ThemeFontSize size) |
FontSize |
Sets the font size resolved once from the current theme’s ThemeMetrics; themes with per-variant metrics re-resolve by calling this inside a WithTheme callback. |
Italic(bool italic = true) |
Sets the font style to italic, or back to upright. | |
Padding(Thickness value) |
Padding |
Sets the inner padding. |
Padding(double horizontal, double vertical) |
Sets the padding with horizontal and vertical values. | |
Padding(double left, double top, double right, double bottom) |
Sets the padding with individual values. | |
Padding(double uniform) |
Padding |
Sets the padding uniformly. |
SemiBold() |
FontWeight = SemiBold |
Sets the font weight to semi-bold. |
StyleName(string value) |
StyleName |
Sets the named style key, resolved from the nearest StyleSheet up the tree and taking priority over StyleSheet type rules and the theme style. |
Template(ControlTemplate value) |
Template |
Sets the template that provides this control’s visual tree; null keeps the control’s own drawn visuals. |
TextBlockBase
Section titled “TextBlockBase”Receiver: TextBlockBase and derived types (where T : TextBlockBase).
| Method | Sets | Summary |
|---|---|---|
LineBoxTrim(LineBoxTrim value) |
LineBoxTrim |
Sets cap-height trimming of the outer line boxes; ink may paint outside the trimmed bounds. |
LineSpacing(double value) |
LineSpacing |
Sets the extra gap between lines (in DIPs); 0 keeps the natural leading and negative values tighten. |
TextAlignment(TextAlignment value) |
TextAlignment |
Sets the horizontal text alignment. |
TextTrimming(TextTrimming value) |
TextTrimming |
Sets the text trimming mode. |
TextWrapping(TextWrapping value) |
TextWrapping |
Sets the text wrapping mode. |
VerticalTextAlignment(TextAlignment value) |
VerticalTextAlignment |
Sets the vertical text alignment. |
PopupOwnerBase
Section titled “PopupOwnerBase”Receiver: PopupOwnerBase and derived types (where T : PopupOwnerBase).
| Method | Sets | Summary |
|---|---|---|
IsDropDownOpen(bool value = true) |
IsDropDownOpen |
Sets whether the popup is open. |
MaxDropDownHeight(double value) |
MaxDropDownHeight |
Sets the maximum height of the popup. |
SyntaxViewer
Section titled “SyntaxViewer”Receiver: SyntaxViewer.
| Method | Sets | Summary |
|---|---|---|
SelectionBackground(Color value) |
SelectionBackground |
Sets the color painted behind the selected text; the default style dims it while the control does not have focus. |
SelectionForeground(Color? value) |
SelectionForeground |
Sets the color the selected glyphs are painted in; null keeps their own colors, so a colorized document stays readable through a selection. |
TabSize(int value) |
TabSize |
Sets the tab width in space characters. |
Text(string value) |
Text |
Sets the text presented. |
Wrap(bool value = true) |
Wrap |
Sets whether lines wrap at the viewport width. |
Receiver: Thumb.
| Method | Sets | Summary |
|---|---|---|
OnDragDelta(Action<Vector> handler) |
event DragDelta |
Subscribes handler to DragDelta. Occurs on each pointer move during a drag, with the total distance from the press point. |
OnDragEnded(Action<bool> handler) |
event DragEnded |
Subscribes handler to DragEnded. Occurs when the drag ends; true when the capture was taken away instead of released. |
OnDragStarted(Action handler) |
event DragStarted |
Subscribes handler to DragStarted. Occurs when a press takes the mouse capture and a drag begins. |
CommandSourceControl
Section titled “CommandSourceControl”Receiver: CommandSourceControl and derived types (where T : CommandSourceControl).
| Method | Sets | Summary |
|---|---|---|
Command(Command value) |
Command |
Sets the semantic command this control invokes. |
CommandData(object value) |
CommandData |
Sets CommandData. The value this control hands its command as the invocation argument. Null lets the nearest ICommandArgumentSource above the control supply the argument instead. |
CommandToolTipMode(CommandToolTipMode value) |
CommandToolTipMode |
Sets CommandToolTipMode. Which parts of the command this control builds a tooltip from when it has no ToolTip of its own. Defaults to none: a control that shows its command’s text and icon has already said what a tooltip would say. |