locked
TextBox FontWeight affects Foreground color??

    Question

  • Here is a simple app that works as expected:

        <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <TextBox x:Name="txResult" Height="20" HorizontalAlignment="Center"/>
            <Button Content="Red"  Click="Button_Red_Click" />
            <Button Content="Blue" Margin="100" Click="Button_Blue_Click" />
        </Grid>
    void App1::MainPage::Button_Red_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	txResult->Foreground = ref new Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::Red);
    	txResult->Text = "Red";
    }
    
    void App1::MainPage::Button_Blue_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	txResult->Foreground = ref new Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::Blue);
    	txResult->Text = "Blue";
    }

    But if you add FontWeight="Bold" to the TextBox, the app behaves in a totally different way.  The change to Foreground color is no longer honored, unless you click the button twice.  You have to change the text BEFORE you change the Foreground, or it won't be applied.  You can change the FontWeight in code instead of XAML, and still get the quirky behavior.  What's going on?
    Wednesday, September 11, 2013 2:54 AM

Answers

  • This definitely seems like a bug here.  It also repros in 8.1

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, September 11, 2013 8:05 PM
    Moderator