Take the 2-minute tour ×

I have looked at several code snippets where people suggest that the AcceptsReturn property of a textbox in Silverlight will enable multiple lines.

My problem however is when I add a textbox with said property and explicity set the height or allow it to fill the container, the text sits vertically in the middle of the textbox.

<Grid x:Name="LayoutRoot" >
    <TextBox TextWrapping="Wrap" Text="TextBox" AcceptsReturn="True"/>

alt text

I need the text to anchor to the top of the textbox.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Ensure there is not an implicit style for the text box which is overriding the default expected behavior in this case. IN my case I was using the Cosmopolitan Theme from Microsoft and it had an implicit style for TextBox elements that did not produce the proper behavior.

In the resources from that theme if you look at the DefaultTextBoxStyle in the CoreStyles.xaml file, at line 448 you will find the ScrollViewer with a VerticalAlignment set to Center. Adjusting this to top solved my problem.

share|improve this answer

Try this:

<Grid x:Name="LayoutRoot">
    <TextBox VerticalAlignment="Stretch" VerticalContentAlignment="Top"

The text is at the top of the box, and the the box stretches to fill the whole page.

share|improve this answer

Your Answer


