locked
How to change the color of text in a textblock. RRS feed

  • Question

  • Hello,

    I had submitted my second app for windows phone and failed the submission process because the text is unreadable in the light theme. This is because of the background I had chosen for my app. I would like to keep the background and was wondering if I could change the color of the text in my textblocks this would allow it to be more visible. I already know how to check what the theme is and have that implemented. Also if you can think of a better way to approach this please let me know. This is part of my High School curriculum at a local vocational school.

    Thanks for any suggestions.

    Matthias

    Monday, November 11, 2013 8:49 PM

Answers

  • I'd let the user's choice win and select a different background if the user choose a light theme. Remove the background completely in high contrast themes. It is always wise to set either both the foreground and the background or to set neither. Setting one and hoping it works with the other will run into problems like you describe.

    You can set the TextBlock's foreground colour to a resource and then change the resource based on the theme:

              <TextBlock Foreground="{StaticResource TextBlockForegroundColour}" Text="{Binding MyText}" TextWrapping="Wrap"></TextBlock>
      
    --Rob

    Monday, November 11, 2013 9:55 PM

All replies

  • I'd let the user's choice win and select a different background if the user choose a light theme. Remove the background completely in high contrast themes. It is always wise to set either both the foreground and the background or to set neither. Setting one and hoping it works with the other will run into problems like you describe.

    You can set the TextBlock's foreground colour to a resource and then change the resource based on the theme:

              <TextBlock Foreground="{StaticResource TextBlockForegroundColour}" Text="{Binding MyText}" TextWrapping="Wrap"></TextBlock>
      
    --Rob

    Monday, November 11, 2013 9:55 PM
  • Thanks for the information.

    Matthias

    Saturday, January 11, 2014 1:56 AM