iOS Development

android – Add Motion on a part of Attributed Textual content in Xamarin C# MVVMCross

I’m making a Cross Platform utility in Xamarin MVVMCross by which I’m utilizing an Attributed Textual content for displaying a clickable hyperlink on some a part of a textual content.

I’ve created my customized class with MvxValueConverter and utilized a Binding in my iOS class.

Under is my code.

public class FreeShippingConverter : MvxValueConverter<string, NSAttributedString>
    {
        protected override NSAttributedString Convert(string worth, Kind targetType, object parameter, CultureInfo tradition)
        {
            var outcome = new NSMutableAttributedString(worth);
            var startIndex = worth.IndexOf(Strings.Take a look at, StringComparison.InvariantCultureIgnoreCase);
            if (startIndex < 0)
            {
                return outcome;
            }

            var vary = new NSRange(startIndex, Strings.Take a look at.Size);
            outcome.AddAttribute(UIStringAttributeKey.Font, TextStyle.B2Bold.Font(), vary);
            outcome.AddAttribute(UIStringAttributeKey.ForegroundColor, Colours.Bluescale4.ToNativeColor(), vary);
            return outcome;
        }
    }

Under is the Binding code from TableViewCell.

this.CreateBinding(FreeShippingText).For(v => v.AttributedText).To((FulfilmentOptionsCellViewModel vm) => vm.FreeShippingText).WithConversion<FreeShippingConverter>().Apply();

Output

Now I need to create an Motion when consumer clicks on “Perks Members“.

Easy methods to bind that in iOS and Android?

Please assist me.

Credit: www.ismmailgsm.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button