Xamarin Forms is Multicolored Text possible?

othello7 1 Reputation point
2021-11-23T16:31:21.967+00:00

I'm porting a text based game that uses RTF to color each character of text individually. On windows forms I use the Rich Text Box. On the .net core console port I made, I convert the colors to ConsoleColor and print each character individually. On Xamarin, I haven't found a way to display multicolor text. Is there something I'm missing? The research I did said that there wasn't a Rich Text Box on Xamarin Forms, but maybe there is some other way to achieve my goal. Thank you

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-11-24T07:39:20.027+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    You can use Formatted text to achieve color each character of text individually. Here is simple about it.

       <Label LineBreakMode="WordWrap">  
                           <Label.FormattedText>  
                               <FormattedString>  
                                   <Span Text="R" TextColor="Red"  />  
                                   <Span Text="G" TextColor="Green"  />  
                                   <Span Text="B" TextColor="Blue"  >  
                                   </Span>  
                               </FormattedString>  
                           </Label.FormattedText>  
                       </Label>  
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.