Search code examples
xamlwindows-phonewindows-phone-toolkit

Wrap Hint in PhoneTextBox


is it possible to make the Hint text in the PhoneTextBox of the Windows Phone Toolkit wrap? I have looked into the code and it seems that this is only possible by changing the whole ControlTemplate. Have I missed something? Is there an easier solution?

Thanks in advance, Christoph


Solution

  • I found out that I can replace the ContentControl via the hint style without re-styling the whole control like this:

    <Style x:Key="HintContentControlStyle" TargetType="ContentControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <Grid>
                        <TextBlock Text="{TemplateBinding Content}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    and then apply it to the PhoneTextBox:

    <tk:PhoneTextBox Text="{Binding Text, Mode=TwoWay}" TextWrapping="Wrap" HintStyle="{StaticResource HintContentControlStyle}" Hint="{Binding LocalizedResources.Hint, Mode=OneWay, Source={StaticResource LocalizedStrings}}" />