簡體   English   中英

Xamarin 表單 - 帶有綁定的下划線標簽

[英]Xamarin forms - Underline Label with binding

我是learnig xamarin,我想將一些屬性綁定到標簽

我已經設法使用像這樣的模型來處理 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 }"

我想綁定標簽屬性: TextDecorations="Underline, Strikethrough"

謝謝你的幫助

像這樣改變Jason的代碼:

 public TextDecorations Decoration
    {
        get
        {
            return TextDecorations.Underline | TextDecorations.Strikethrough;
        }
    }

  <Label Text="{Binding LabelText}" TextDecorations="{Binding Decoration}" />

順便說一句,當你使用綁定時,不要忘記實現INotifyPropertyChanged來通知數據更改。

在此處輸入圖片說明

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM