Reputation: 321
I am currently learning C# and XAML for UWP apps and have a problem with my TextBoxes.
How do I get the TextBox smaller? Adjusting the font size alone is not enough, even setting the height doesn't bring about any changes. What I noticed is that the Clear button doesn't get smaller, also the X in it doesn't get smaller with the FontSize. And that's probably the problem, because the TextBox probably doesn't want to cut the Clear button and therefore retains the default size, because you can make the box bigger without any problems, but not smaller.
I might add that I use Visual Studio Community 2017 and the TextBox from the existing ToolBox there.
Could someone help me with that? All I've found so far is how to add such a clear button and only on WPF apps.
Upvotes: 1
Views: 3714
Reputation: 32775
As jsmyth886 said the MinHeight
property will limit the minimum height you can set. If you want to make smaller TextBox
, you could create custom style for TextBox
like following
<Style TargetType="TextBox" x:Key="MyTextBoxStyle">
<Setter Property="MinHeight" Value="20"/>
</Style>
When you set the Height
property to more than the MinHeight
, it will take effect.
<TextBox x:Name="MyTextBox" Text="This text box" Style="{StaticResource MyTextBoxStyle}" Height="21" />
The above operation is also suitable to MinWidth
property.
Upvotes: 2