Search code examples
c#xamlwindows-store-appswinrt-xaml

TextBox vertical alignment in Windows Store App


I'm trying to do something that seems quite simple but that I haven't been able to do so far : Vertically align the text in a TextBox in Windows Store App (XAML).

VerticalContentAlignment doesn't work (although it works well in WPF). I've even tried to extract the template and change it. Still couldn't do it.

Does anyone know how to do it ?


Solution

  • Unfortunately there is no simple way. However if your TextBox has a fixed size then you can adjust the Padding Property in a custom style, it can be done dynamically too, but it is a bit more work.

     <Style TargetType="TextBox" x:Key="CustomTextBoxStyle">
            <Setter Property="Padding"
                    Value="25" />
     </Style>
    <TextBox Text="TestText"
                 Height="80"
                 Style="{StaticResource CustomTextBoxStyle}" />
    

    enter image description here