[英]Xamarin forms - Underline Label with binding
I am learnig xamarin, I would like to bind some propreties to a label我是learnig xamarin,我想将一些属性绑定到标签
I have manage to do with IsVisible , TextColor & Text porprety with model like this :我已经设法使用像这样的模型来处理 IsVisible、TextColor 和 Text porprety:
public Color MyLabelColor { get; set; } = Color.FromHex("#ff6465");
public string LabelText { get; set; }
public bool LabelIsVisibleOrNot { get; set; } = false;
And bind the like this:
IsVisible="{Binding MyLabelColor}"
Text="{Binding LabelText}"
TextColor="{Binding MyLabelColor }"
I would like to bind the label proprety : TextDecorations="Underline, Strikethrough"
我想绑定标签属性:
TextDecorations="Underline, Strikethrough"
Thanks for your help谢谢你的帮助
Changing Jason's code like this:像这样改变Jason的代码:
public TextDecorations Decoration
{
get
{
return TextDecorations.Underline | TextDecorations.Strikethrough;
}
}
<Label Text="{Binding LabelText}" TextDecorations="{Binding Decoration}" />
By the way, when you use binding, don't forget to implement INotifyPropertyChanged to notify data changed.顺便说一句,当你使用绑定时,不要忘记实现INotifyPropertyChanged来通知数据更改。
TextDecorations is an enum TextDecorations是一个枚举
public TextDecorations Decoration { get {
return TextDecorations.Underline & TextDecorations.Strikethrough; } }
<Label Text="{Binding Subject}" TextDecorations="{Binding Decoration}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.