I have a problem with the TextBox
control.
Be aware of the ScrollViewer
as this makes the difference.
Here is my xaml:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto">
<TextBox HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Margin="20"
Text = "A short text">
</TextBox>
</ScrollViewer>
</Grid>
It results in this:
It looks like expected and it expends/shrinks nicely if the window is resized. So far so good, but what happens if the text is a bit longer?
This happens:
The TextBox
now grows to fit the text inside which is
a) because there is a ScrollView
that allows horizontal scrolling and
b) results in a really ugly UI (as the right margin isn't visible, but a scrollbar is, etc..)
Does anybody know how I could achieve the look from the first screenshot even with the longer text (while keeping the ScrollViewer)?
I thought about setting a maximum width for the TextBox
but it prevented the TextBox
from growing with the window which isn't acceptable.