-
Notifications
You must be signed in to change notification settings - Fork 0
UI Controls
Cursorial ships a full WPF/Avalonia-style control catalog in the Cursorial.UI.Controls namespace — buttons,
text input, lists, menus, tabs, date pickers, and the layout/presentation primitives they're built from. This page
is the catalog: what each control is, the one or two headline properties you'll set most, and a tiny example for the
common ones. Reach here when you know you want a control and need its API; reach for UI Overview when
you want the bigger picture.
If you've used WPF or Avalonia, the shapes will feel familiar: every control derives from Control, carries a
ControlTemplate, and is restyled with the same selector/setter machinery described in
Styling and themes. Looks come from the built-in theme — you author behavior in C# or XAML
and the theme paints it in a box-drawing idiom that adapts to the terminal's color depth.
Namespace note. Controls,
Panel/panels, and presenters live inCursorial.UI.Controls. The baseUIElement, the property system, and the alignment enums live inCursorial.UI. Brushes and pens are inCursorial.Drawing.Media.
These aren't controls you'd place directly so much as the building blocks every other control extends.
-
Control— the base of every templated control. Headline properties:Template(aControlTemplate),Background/Foreground(IBrush?),BorderPen(Pen?),Padding(Margins),ContextMenu. The visual tree is built fromTemplateat measure time. -
ContentControl— a control with a singleContent(object?) rendered through aContentTemplate(DataTemplate?). SetContentto a string, aUIElement, or any object plus a matching template. Also carriesContentStringFormatandHorizontal/VerticalContentAlignment. (HeaderedContentControladdsHeader/HeaderTemplate.) -
ContentPresenter— the part aContentControl's template uses to actually place itsContent. Picks aDataTemplateby content type when no explicitContentTemplateis set;RecognizesAccessKeyfolds_mnemonics in string content. -
Decorator— a single-Child(UIElement?) wrapper, the base forBorder.
var card = new ContentControl
{
Content = "Hello, terminal",
Padding = new Margins(1),
};-
TextBlock— read-only text. SetText(plain), orMarkupfor inline-styled spans. Tune withTextWrapping(WrapMode),TextAlignment,TextTrimming, and the inheritedForeground. -
Border— aDecoratorthat draws a box around itsChild. Headline properties:BorderPen(Pen?),Background(IBrush?),Padding(Margins), and an optionalTitle/TitlePositionfor a titled panel. -
Label— aContentControlwhose access key (_) moves focus to itsTarget(UIElement?). -
Separator— a thin divider line; setOrientation.
var heading = new TextBlock("Settings") { TextWrapping = WrapMode.Wrap };
var framed = new Border
{
Title = "Details",
Padding = new Margins(1),
Child = heading,
};All of these derive from ButtonBase, which carries Command (ICommand?), CommandParameter, ClickMode, the
read-only IsPressed, and the bubbling Click event (EventHandler<ClickEventArgs>). They activate on the spacebar
and Enter as well as the mouse.
-
Button— the standard push button. AddsIsDefault/IsCancel(Enter/Escape activation hints for dialogs). -
RepeatButton— firesClickrepeatedly while held; tuneDelayandInterval(milliseconds). -
ToggleButton— a two- or three-state toggle.IsCheckedisbool?(the third,null, state is enabled viaIsThreeState); raisesChecked/Unchecked/Indeterminate. -
CheckBox— aToggleButtonrendered as a checkbox. -
RadioButton— aToggleButtonwith mutual exclusion across a sharedGroupName.
var save = new Button { Content = "_Save", Command = saveCommand };
save.Click += (_, _) => Console.Beep();
var wrap = new CheckBox { Content = "Word wrap", IsChecked = true };
var small = new RadioButton { Content = "Small", GroupName = "size" };
var medium = new RadioButton { Content = "Medium", GroupName = "size", IsChecked = true };-
TextBox— single-line editable text. Headline:Text(string), plusIsReadOnly,MaxLength,Placeholder, andSelectionBrush. ExposesSelectedText,SelectAll(),Clear(), and aTextChangedevent. -
PasswordBox— aTextBoxthat masks input.PasswordmirrorsText;PasswordCharis the mask glyph andRevealPasswordun-masks.
var name = new TextBox { Placeholder = "Your name", MaxLength = 40 };
name.TextChanged += (_, _) => Validate(name.Text);
var pin = new PasswordBox { PasswordChar = '•' };RangeBase is the shared base for value-over-a-range controls: Minimum, Maximum, Value (all double), plus
SmallChange/LargeChange.
-
Slider— a draggable thumb over a track. AddsOrientationandFilledPen(the styling of the filled portion);Value/Minimum/Maximumcome fromRangeBase. -
ProgressBar— a determinate bar driven byValue, or setIsIndeterminatefor an animated marquee.Fillstyles the bar brush. -
ScrollBar— usually composed byScrollViewer, but available standalone:Orientation,ViewportSize,ThumbBrush, and aScrollevent.
var volume = new Slider { Minimum = 0, Maximum = 100, Value = 70 };
var progress = new ProgressBar { Minimum = 0, Maximum = 1, Value = 0.4 };
var spinner = new ProgressBar { IsIndeterminate = true };-
ScrollViewer— aContentControlthat scrolls oversizedContent. SetVerticalScrollBarVisibility/HorizontalScrollBarVisibility(ScrollBarVisibility); readHorizontalOffset/VerticalOffset(cells) and theExtent/Viewportsizes. Scrolling within the cached band is a pure composite slide — fast even for tall content.
var viewer = new ScrollViewer
{
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Content = bigTextBlock,
};ItemsControl is the base for everything that displays a collection. Bind a collection to ItemsSource
(IEnumerable?) or add to the inline Items collection — not both. ItemTemplate (DataTemplate?) renders
each item, ItemsPanel (ItemsPanelTemplate?) chooses the layout panel, and ItemContainerStyle styles the
generated containers. IsTextSearchEnabled adds type-to-find.
Selecting variants derive from SelectingItemsControl, which adds SelectedItem (object?), SelectedIndex
(int), SelectedItems, SelectionMode, and the SelectionChanged/ItemActivated events.
-
ListBox— a selectable, scrollable list ofListBoxItems. -
ComboBox— a single-select drop-down. Headline:IsDropDownOpen,IsEditable(withText/PlaceholderTextfor the editable case),MaxDropDownHeight; selection via the inheritedSelectedItem/SelectedIndex. -
TreeView— a hierarchical tree ofTreeViewItems. Tree-wide single selection lives onTreeView.SelectedItem(read-only); eachTreeViewItemexposesIsExpandedandIsSelected. Use aHierarchicalDataTemplateto bind nested data. -
TabControl— a tabbed view ofTabItems. The selected tab is the inheritedSelectedItem;SelectedContent(read-only) is its content. EachTabItemis aHeaderedContentControlwithHeader+Contentand anIsSelected. -
StatusBar— a horizontal strip ofStatusBarItems (anItemsControl), typically docked at the bottom.
var list = new ListBox { ItemsSource = files };
list.SelectionChanged += (_, e) => Open(list.SelectedItem);
var combo = new ComboBox { ItemsSource = themes, SelectedIndex = 0 };
var tabs = new TabControl();
tabs.Items.Add(new TabItem { Header = "_General", Content = generalPage });
tabs.Items.Add(new TabItem { Header = "_Advanced", Content = advancedPage });ItemsControl.ItemContainerGenerator maps between data items and their generated containers — ContainerFromIndex,
IndexFromContainer, and ContainerCount. For long lists, opt a ListBox (or any items control) into a
VirtualizingStackPanel and turn on virtualization with the attached properties on VirtualizingPanel:
VirtualizingPanel.SetIsVirtualizing(control, true) and VirtualizingPanel.SetVirtualizationMode(control, mode)
(VirtualizationMode.Recycling is the default). Only the visible window of containers is realized; selection and
keyboard navigation stay item-indexed even when most containers don't exist.
VirtualizingPanel.SetIsVirtualizing(list, true);
VirtualizingPanel.SetVirtualizationMode(list, VirtualizationMode.Recycling);-
Menu— a horizontal menu bar ofMenuItems; can register as the application main menu. -
MenuItem— aHeaderedItemsControl:Headeris the label, childMenuItems become a submenuPopup. Headline:Command/CommandParameter,Icon,InputGestureText(the right-aligned shortcut hint),IsCheckable/IsChecked, the read-onlyIsSubmenuOpen/IsHighlighted, and aClickevent. -
ContextMenu— a right-click flyout. Attach one to any element withContextMenu.SetMenu(element, menu); it opens on right-click or the Menu key.Open(target, position?)/Close()drive it manually;IsOpenreads state.
var file = new MenuItem { Header = "_File" };
file.Items.Add(new MenuItem { Header = "_Open", InputGestureText = "Ctrl+O", Command = openCommand });
file.Items.Add(new Separator());
file.Items.Add(new MenuItem { Header = "E_xit", Command = exitCommand });
var menuBar = new Menu();
menuBar.Items.Add(file);-
ToolTip— a hit-transparent, never-focused popup shown on hover. -
ToolTipService— the attached-property entry point.ToolTipService.SetTip(element, content)is the common case;SetInitialDelayandSetShowOnFocustune timing and focus behavior. The content can be a string or anyUIElement.
ToolTipService.SetTip(saveButton, "Save the current document (Ctrl+S)");-
Expander— aHeaderedContentControlwhoseContentcollapses behind itsHeader. ToggleIsExpanded; raisesExpanded/Collapsed. -
GridSplitter— a draggable bar that resizes adjacentGridtracks. SetResizeDirection(GridResizeDirection),ResizeBehavior(GridResizeBehavior), andKeyboardIncrement. (Grid layout itself is covered in Layout and panels.)
var details = new Expander { Header = "Advanced options", IsExpanded = false, Content = advancedPanel };-
Calendar— an inline month-view picker. Headline:SelectedDate(DateOnly?),DisplayDate(DateOnly),FirstDayOfWeek,DisplayDateStart/DisplayDateEndbounds,BlackoutDates,IsTodayHighlighted, and aDisplayMode. RaisesSelectedDateChanged/DateCommitted. -
DatePicker— a date field that drops aCalendarpopup.SelectedDate(DateOnly?),DisplayDate,Watermark(placeholder),IsDropDownOpen,IsEditable; raisesSelectedDateChanged.
var picker = new DatePicker
{
Watermark = "yyyy-mm-dd",
SelectedDate = DateOnly.FromDateTime(DateTime.Today),
};
picker.SelectedDateChanged += (_, e) => Schedule(e.NewDate);Every control's look is its ControlTemplate — a tree of elements (often a Border wrapping a ContentPresenter)
that the control instantiates and binds to with TemplateBinding. The default look comes from the built-in theme,
resolved through a control-theme chain so an application Style can override any control wholesale. You rarely
write templates by hand for the basics; you reach for them to reskin a control or build a custom one. Selectors,
setters, pseudo-classes (:pointerover, :focus, :checked, …), and theme dictionaries are all covered in
Styling and themes, and the same trees are expressible in markup — see XAML.
- UI Overview — the element tree, the application loop, and how a control becomes pixels.
-
Layout and panels —
StackPanel,Grid,DockPanel, and how controls are arranged. - Styling and themes — selectors, setters, control templates, and theming.
-
Data binding — wiring
ItemsSource,SelectedItem,Text, andIsCheckedto a view model.
Cursorial.Core
Cursorial.Rendering
Drawing & Animation
Cursorial.UI
- Overview
- Layout & panels
- Controls
- Styling & themes
- Data binding
- Input & focus
- Windowing
- Animation & transitions
Declarative