Reputation: 147
I am learnig xamarin, I would like to bind some propreties to a label
I have manage to do with IsVisible , TextColor & Text porprety with model like this :
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"
Thanks for your help
Upvotes: 0
Views: 903
Reputation: 10346
Changing Jason's code like this:
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.
Upvotes: 3
Reputation: 89102
TextDecorations is an enum
public TextDecorations Decoration { get {
return TextDecorations.Underline & TextDecorations.Strikethrough; } }
<Label Text="{Binding Subject}" TextDecorations="{Binding Decoration}" />
Upvotes: 0