TerminalPanel

April 9, 2026 · View on GitHub

A terminal-style panel with a scrollable output area and a command input line. Maintains a configurable output buffer and raises events for command submission.

Basic usage

<TerminalPanel Title="Terminal"
              Prompt="$"
              IsRunning="True" />

Properties

PropertyTypeDefaultDescription
Titlestring"Terminal"Panel title shown in the header
IsRunningboolWhether the terminal session is active
StatusTextstring?Status text shown in the header
StatusColorIBrush?Brush used for the status indicator dot
InputTextstring?Current input line text
OutputTextstring?Full output text displayed in the terminal
Promptstring"$"Prompt string shown before the input box
MaxOutputLinesint5000Maximum number of output lines to retain
ShowCloseButtonbooltrueWhether the close button is visible

Events

EventDescription
CommandSubmittedRaised when the user submits a command (presses Enter)
CloseRequestedRaised when the user clicks the close button

Appending output

Add text to the terminal output:

terminalPanel.AppendOutput("Hello, World!\n");
terminalPanel.AppendOutput("Command completed successfully.\n");

Clearing output

Clear all output:

terminalPanel.ClearOutput();

Command handling

Handle command submissions:

terminalPanel.CommandSubmitted += (sender, command) =>
{
    // Process the command
    terminalPanel.AppendOutput($"Executing: {command}\n");
    
    // Simulate command execution
    var result = ProcessCommand(command);
    terminalPanel.AppendOutput($"{result}\n");
};

Prompt

Customize the prompt string:

<TerminalPanel Prompt=">" />
terminalPanel.Prompt = "#";

Status

Set status text and color:

<TerminalPanel StatusText="Connected"
              StatusColor="Green" />
terminalPanel.StatusText = "Disconnected";
terminalPanel.StatusColor = Brushes.Red;

Running state

Control whether the terminal is active:

<TerminalPanel IsRunning="True" />
terminalPanel.IsRunning = false;

Max output lines

Set the maximum number of lines to retain (older lines are removed):

<TerminalPanel MaxOutputLines="10000" />

Close button

Control the visibility of the close button:

<TerminalPanel ShowCloseButton="False" />

Focus input

Focus the input box programmatically:

terminalPanel.FocusInput();

Example

var terminal = new TerminalPanel
{
    Title = "Command Line",
    Prompt = ">",
    IsRunning = true
};

terminal.CommandSubmitted += (sender, cmd) =>
{
    terminal.AppendOutput($"{terminal.Prompt} {cmd}\n");
    
    switch (cmd.ToLower())
    {
        case "help":
            terminal.AppendOutput("Available commands: help, clear, echo [text]\n");
            break;
        case "clear":
            terminal.ClearOutput();
            break;
        default:
            terminal.AppendOutput($"Unknown command: {cmd}\n");
            break;
    }
};

Pseudo-classes

The control applies pseudo-classes based on state:

  • :running - Applied when the terminal is running
  • :hasOutput - Applied when there is output text

Template parts

The control template must provide:

  • PART_OutputBox - TextBox that displays output
  • PART_InputBox - TextBox for command input
  • PART_ClearButton - Button to clear output
  • PART_CloseButton - Button to close the panel
  • PART_ScrollViewer - SmoothScrollViewer for output scrolling