Daniel Benedykt
Daniel Benedykt

Reputation: 6553

How to Change heigth and font size of TextBox in Windows Phone 8.1 RT?

How to Change heigth and font size of TextBox in Windows Phone 8.1 RT?

this is my code:

<TextBox Name="textNumber" Grid.Row="1" PlaceholderText="placeholder text" FontSize="48" Height="80" MinHeight="38"/>

The problem is that the Font size is only for the input of the user, but not for the placeholder text, so placeholder text looks very small.

Upvotes: 2

Views: 584

Answers (1)

Rob Caplan - MSFT
Rob Caplan - MSFT

Reputation: 21919

The PlaceholderText always pulls its font from the ContentControlFontSize resource. If you want to change this globally you can override that resource. If you want to override it just for a specific control you'll need to retemplate the TextBox. Select it in the designer, right click, and choose Edit Template... The placeholder is defined in the following Xaml, and you can update it as you'd like:

<ContentControl x:Name="PlaceholderTextContentPresenter" Content="{TemplateBinding PlaceholderText}" Foreground="{ThemeResource TextBoxPlaceholderTextThemeBrush}" FontSize="{ThemeResource ContentControlFontSize}" IsTabStop="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.Row="1"/>

If you want the Placeholder's font size to match the FontSize set on the TextBox then change the ContentControl's FontSize to "{TemplateBinding FontSize}"

<ContentControl x:Name="PlaceholderTextContentPresenter" Content="{TemplateBinding PlaceholderText}" Foreground="{ThemeResource TextBoxPlaceholderTextThemeBrush}" FontSize="{TemplateBinding FontSize}" IsTabStop="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.Row="1"/>

Upvotes: 2

Related Questions