Item 120 of 902 Previous | Next

2
Vote

PhoneTextBox uses wrong brush with hint and empty text

description

Just create a PhoneTextBox with a Hint and you can see this when you start typing into an empty text box. The text is drawn with the hint brush, not the standard foreground brush. I've worked around this issue by adding a TextChanged listener and calling this code:

public static void OnPhoneTextBoxTextChanged(PhoneTextBox textBox)
{
if (!string.IsNullOrEmpty(textBox.Text))
{
Brush foregroundBrush = (Brush)Application.Current.Resources["PhoneTextBoxForegroundBrush"];
if (textBox.Foreground != foregroundBrush)
textBox.Foreground = foregroundBrush;
}
}

This is definitely a bug

No files are attached

comments

AlexSorokoletov wrote Dec 13 2011 at 8:02 AM

Sorry, my comment is wrong.

AlexSorokoletov wrote Dec 13 2011 at 7:58 AM

Or fix that in template

<TextBlock x:Name="MeasurementTextBlock"
Margin="8"
IsHitTestVisible="False"
Opacity="0"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}"
TextAlignment="{TemplateBinding TextAlignment}"
FontWeight="{TemplateBinding FontWeight}"
FontStyle="{TemplateBinding FontStyle}"
TextWrapping="{TemplateBinding TextWrapping}"
----->>> Foreground={StaticResource PhoneTextBoxForegroundBrush}
Text="{TemplateBinding Text}" />

nedelman wrote Dec 3 2011 at 4:26 PM

Made a correction, from "PhoneForegroundBrush" to "PhoneTextBoxForegroundBrush"