Maui for Android label formattedtext issue

Haviv Elbsz 2,071 Reputation points
2024-01-11T17:33:13.1533333+00:00

Hello using ver 17.9 preview 2 android Ver 14. I n my app I use a label with text plain and also with formattedtext. now in some point in the app I want to check if the label is contains plain text or formattedtext. I want to use string. contains function for the label text. any help. Thank you.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,900 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 79,471 Reputation points Microsoft Vendor
    2024-01-12T09:18:53.7833333+00:00

    Hello,

    If know whether the content of a Label is text plain or formattedtext

    You can use following code to check the content of Label is text plain or formattedtext.

    For example, if the content of Label is text plain, you will get null value from label.FormattedText and following method will return false. If the content of Label is formattedtext, the following method will return true value.

      bool ContainsFormattedText(Label label) {
           return label.FormattedText != null;
     }
    

    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.