Multiple Colors In TextBlock

后端 未结 4 1407
名媛妹妹
名媛妹妹 2020-12-16 21:23

Is it possible to add dynamic colors to a TextBlock ..i.e. have one character in one color and the next in another color.



        
4条回答
  •  再見小時候
    2020-12-16 22:19

    The TextBlock does not support multiple Foreground colors.

    You could recreate this behaviour by using multiple textblocks (one for each letter) and placing them within a wrappanel. You could then change the color of individual characters/letters as you wish.
    Beware of the probable performance impact this may have. The margins around individual letters will need to be adjusted to recreate standard behaviour though. Be especially careful around punctuation.

提交回复
热议问题