E. A. Bagby
E. A. Bagby

Reputation: 930

Change the Height of a TextBox input area in WinUI 3 XAML

I've noticed when I change the height of a TextBox control in WinUI 3 XAML, the overall control height changes (not just the input area) and it will cut off bottom of the input area if I make the height less than around 56 if there is a header. For example:

        <TextBox
            x:Name="MyTextBox"
            Height="45"
            Width="Stretch"
            Header="A Text Box" />

Any way around this? It's easy to make the text box taller, but I want the input area shorter than the default.

Upvotes: 2

Views: 282

Answers (1)

Andrew KeepCoding
Andrew KeepCoding

Reputation: 13666

In the DefaultTextBoxStyle,

  • MinHeight is set to TextControlThemeMinHeight (default: 32)
  • Padding is set to TextControlThemePadding (default: 10,5,6,6)

Try setting both MinHeight and Padding to 0:

<TextBox
    x:Name="MyTextBox"
    Height="45"
    MinHeight="0"
    Padding="0"
    Header="A Text Box"
    Text="ABCDE" />

enter image description here

If you are not familiar with DefaultTextBoxStyle, check the generic.xaml file.

Upvotes: 2

Related Questions