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.
<TerminalPanel Title="Terminal"
Prompt="$"
IsRunning="True" />| Property | Type | Default | Description |
|---|---|---|---|
Title |
string |
"Terminal" |
Panel title shown in the header |
IsRunning |
bool |
— | Whether the terminal session is active |
StatusText |
string? |
— | Status text shown in the header |
StatusColor |
IBrush? |
— | Brush used for the status indicator dot |
InputText |
string? |
— | Current input line text |
OutputText |
string? |
— | Full output text displayed in the terminal |
Prompt |
string |
"$" |
Prompt string shown before the input box |
MaxOutputLines |
int |
5000 |
Maximum number of output lines to retain |
ShowCloseButton |
bool |
true |
Whether the close button is visible |
| Event | Description |
|---|---|
CommandSubmitted |
Raised when the user submits a command (presses Enter) |
CloseRequested |
Raised when the user clicks the close button |
Add text to the terminal output:
terminalPanel.AppendOutput("Hello, World!\n");
terminalPanel.AppendOutput("Command completed successfully.\n");Clear all output:
terminalPanel.ClearOutput();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");
};Customize the prompt string:
<TerminalPanel Prompt=">" />terminalPanel.Prompt = "#";Set status text and color:
<TerminalPanel StatusText="Connected"
StatusColor="Green" />terminalPanel.StatusText = "Disconnected";
terminalPanel.StatusColor = Brushes.Red;Control whether the terminal is active:
<TerminalPanel IsRunning="True" />terminalPanel.IsRunning = false;Set the maximum number of lines to retain (older lines are removed):
<TerminalPanel MaxOutputLines="10000" />Control the visibility of the close button:
<TerminalPanel ShowCloseButton="False" />Focus the input box programmatically:
terminalPanel.FocusInput();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;
}
};The control applies pseudo-classes based on state:
:running- Applied when the terminal is running:hasOutput- Applied when there is output text
The control template must provide:
PART_OutputBox- TextBox that displays outputPART_InputBox- TextBox for command inputPART_ClearButton- Button to clear outputPART_CloseButton- Button to close the panelPART_ScrollViewer- SmoothScrollViewer for output scrolling