Iām looking for a way to make parts of the text of an Xamarin label interactive with various functions and ideally have different formatting. I understand that a clickable label is simple and can be done something like this:
Label label = new Label { Text = "Click me" }; label.Click += () => { label.Text = "Clicked"; };
Essentially, I am trying to simulate the behavior in an application that I did in native Android. My application should run on Android and iOS and ideally UWP. On Android, CharSequence objects can be added to a TextView (a control similar to a Label). In Android, I could create a CharSequence object like this:
Runnable doSomething; //equivalent to C
As you can see, it performs a function and has style attributes. Then I can add this to the TextView (Spannable implements Spanned, which implements CharSequence). I can add a few CharSequence in addition to the non-clickable rows as I wish.
I hope I can do this in Xamarin, but have not yet found a solution. I considered the possibility of custom rendering tools, although I believe that a cross-platform solution would be preferable, if possible. I'm much less familiar with iOS, but it seems like it's possible to add NSMutableAttributedString objects to UILabel for a similar effect. I also saw the FancyLabel object. I'm not quite sure how I would do this for UWP, as I really have not found much in my research.
Any help would be greatly appreciated!
source share