namespace-viewbase.md 2.5 KB


uid: Terminal.Gui.ViewBase

summary: The ViewBase namespace contains the foundational view system and core UI building blocks.

@Terminal.Gui.ViewBase.View provides the fundamental view architecture that forms the foundation of all Terminal.Gui user interface elements. This namespace contains the base View class, adornment system, layout primitives, and core view behaviors that enable the rich UI capabilities of Terminal.Gui.

The View system implements the complete view lifecycle, coordinate systems, event handling, focus management, and the innovative adornment system that separates content from visual decoration.

Key Components

View Architecture

  • Hierarchy: SuperView/SubView relationships with automatic lifecycle management
  • Coordinate Systems: Multiple coordinate spaces (Frame, Viewport, Content, Screen)
  • Layout Engine: Automatic positioning and sizing with constraint-based layout
  • Event System: Comprehensive event handling with cancellation support
  • Focus Management: Built-in keyboard navigation and focus chain management

Example Usage

// Create a view with a Border adornment and Title
var view = new View()
{
    X = Pos.Center(),
    Y = Pos.Center(),
    Width = Dim.Percent(50),
    Height = Dim.Percent(30),
    Title = "My View",
    BorderStyle = LineStyle.Rounded
};

// Enable user arrangement
view.Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable;

// Add to SuperView 
superView.Add(view);

See Also