Skip to content

TextBox with explicit Height doesn't stretch content area for multiline editing #68

@iwatakeshi

Description

@iwatakeshi

Describe the bug
When using a TextBox with AcceptsReturn="True" and an explicit Height set, the editable text area only displays approximately 36px (the MinHeight) instead of filling the full height of the TextBox. This makes the TextBox appear collapsed even though its outer dimensions are correct.

The root cause is that the TextBox template uses StackPanel to wrap the content. StackPanel does not stretch its children to fill available space - it only gives them their desired size. This means the inner Border containing the text area gets its MinHeight (36px) instead of stretching to fill the explicit Height.

To Reproduce

  1. Create a TextBox with explicit dimensions and multiline support:
<TextBox 
    Width="200" 
    Height="150" 
    AcceptsReturn="True" 
    TextWrapping="Wrap" />
  1. Run the application
  2. Observe that the editable text area is only ~36px tall instead of 150px
  3. The outer TextBox bounds are correct (200x150), but the inner content area is collapsed

Expected behavior
The TextBox content area should stretch to fill the entire specified Height, allowing users to see and edit multiple lines of text within the full 150px height.

Screenshots

Image

The issue is visible when inspecting the visual tree: the outer TextBox has correct bounds but the inner Border only has MinHeight.

Desktop (please complete the following information):

  • OS: Windows 11
  • Avalonia Version: 11.3.0+
  • ShadUI Version: Latest (tested against main branch)

Additional context
The fix is to replace StackPanel with Grid using appropriate RowDefinitions so that the content can stretch:

  • Outer StackPanelGrid with RowDefinitions="Auto,*"
  • Inner StackPanel (inside DataValidationErrors) → Grid with RowDefinitions="*,Auto"
  • Add VerticalAlignment="Stretch" to the Border
  • Remove the hard-coded Height="{TemplateBinding shadui:ControlAssist.Height}" binding (let it stretch naturally)

This allows the Border to stretch and fill the available space when an explicit Height is set on the TextBox.

PR with fix: #67

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions