TabControl hosts multiple tab pages with clickable headers.
Tab headers are visuals, enabling rich header content (icons, counters, dynamic text, etc.).
TabPage is now a bindable model, so you can update a page's Header, Content, IsEnabled, ShowCloseButton, or Data
without removing and recreating the tab.
var logs = new TabPage("Logs", "Tail -f output")
{
ShowCloseButton = true,
Data = "logs",
};
logs.RequestClosing += (_, e) =>
{
if (HasPendingSave())
{
e.Cancel = true;
}
};
var tabs = new TabControl(
new TabPage("Status", "Ready"),
logs,
new TabPage("Metrics", "42 req/s") { ShowCloseButton = true });
HorizontalAlignment = Align.Stretch, VerticalAlignment = Align.StretchTabPage exposes bindable state:
Header : VisualContent : VisualIsEnabled : boolShowCloseButton : boolData : object?Close lifecycle:
RequestClosing lets a page cancel a close request.Closed is raised after the page has been removed.TabControl.TryCloseTab(...) closes a page programmatically and uses the same lifecycle as the close button.TabControlStyle controls header rendering, close buttons, overflow buttons, and the content wrapper.
By default:
new TabControl(
new TabPage("Status", "Ready"),
new TabPage("Logs", "…") { ShowCloseButton = true })
.Style(TabControlStyle.Rounded with
{
CloseButtonRune = new Rune('x'),
OverflowPreviousRune = new Rune('<'),
OverflowNextRune = new Rune('>'),
});
Left / Right arrow keys switch between enabled tabs when the control is focused.