I want to bind an attributed string to a UILabel using MVVMCross. To bind a regular string I would just do:
set.Bind(MyLabel).To(vm => vm.MyString);
But I need a string where part of the text will use one color and one font size and another part will use a different color and a different font size. If this was static, no problem, I'd add a label in interface builder and set it "attributed" and then set whatever font options I want on which ever parts of the string I need.
So I thought with Mvvmcross, I'd probably need a converter to turn my source string into an attributed string, so I tried creating a converter from MvxValueConverter<string,NSMutableAttributedString>
that just does this in its Convert
method:
return new NSMutableAttributedString(value);
Eventually I'll actually add some different attributes. Unfortunately, this doesn't work. If I set my binding like this:
set.Bind(MyLabel).To(vm => vm.MyString).WithConversion("MyConverter");
It appears that MvvmCross just does a .ToString
on the attributed string and it displays as:
Some Text {}
Note the {}
aren't part of the original string.
Is there a way to bind an attributed string in MVVMCross?