c# - AttributedText on MvxTableViewCell -
i'm trying set underline on uilabel of mvxtableviewcell.
[register("kittencell")] public class kittencell : mvxtableviewcell { private uiimageview mainimage; private uilabel namelabel; private uilabel pricevaluelabel; private uilabel pricelabel; public static readonly nsstring key = new nsstring ("kittencell"); private mvximageviewloader imageloader; public kittencell () { createlayout (); initializebindings (); } public kittencell(intptr handle) : base(handle) { createlayout (); initializebindings (); } void createlayout () { mainimage = new uiimageview (new rectanglef (0, 0, 160, 100)); namelabel = new uilabel (new rectanglef (168, 15, 144, 21)); namelabel.textalignment = uitextalignment.left; var attrs = new uistringattributes { underlinestyle = nsunderlinestyle.single }; namelabel.attributedtext =new nsattributedstring(namelabel.text,attrs); pricelabel = new uilabel (new rectanglef (168, 59, 57, 21)); pricelabel.text = "price:"; pricelabel.textalignment = uitextalignment.left; pricevaluelabel = new uilabel (new rectanglef (228, 59, 84, 21)); pricevaluelabel.textalignment = uitextalignment.left; pricevaluelabel.textcolor = uicolor.blue; contentview.addsubviews (mainimage, namelabel, pricelabel, pricevaluelabel); } void initializebindings () { imageloader = new mvximageviewloader (() => this.mainimage); this.delaybind (() => { var set = this.createbindingset<kittencell, kitten> (); set.bind (namelabel).to(kitten => kitten.name); set.bind (pricevaluelabel).to(kitten => kitten.price); set.bind (imageloader).to(kitten => kitten.imageurl); set.apply (); }); } }
but when uilabel shown there no underline under it. explanation underline applied on text not binded. how possible set after binding?
you use converter along this:
public class underlinetextvalueconverter : mvxvalueconverter<string, nsattributedstring> { protected override nsattributedstring convert(string value, type targettype, object parameter, cultureinfo cultureinfo) { var attrs = new uistringattributes { underlinestyle = nsunderlinestyle.single }; return new nsattributedstring(value, attrs); } }
and update binding this...
set.bind (namelabel).for(l => l.attributedtext).to(kitten => kitten.name).withconversion("underlinetext", null);
the above code untested, should work no or little modification.
Comments
Post a Comment