2017-11-02 3 views
0

私はコード内でstaticプロパティに対してINotifyPropertyChangedを実装しました。しかし、UIには影響しません。ここで私のコードを追加しました。誰もがこれについて考えている。前もって感謝します。私はあなたが「X:静的」を使用しているので、あなたの「LoginPageModel」クラスが同様に静的であると仮定していINotifyPropertyChangedは、xamarinフォームの静的プロパティでは機能しません。

 private static string dateTimeValue; 
    public static string DateTimeValue { get { return dateTimeValue; } set 
     { dateTimeValue = value; RaisedPropertyChanged("DateTimeValue"); } } 

    static void RaisedPropertyChanged([CallerMemberName] string name = null) 
    { 
     if (PropertyChanged != null) 
      PropertyChanged(null, new PropertyChangedEventArgs(name)); 
    } 
The xaml code is, 
    <Label Text="{Binding Source={x:Static local:LoginPageModel.DateTimeValue}, UpdateSourceEventName=PropertyChanged}"> 

答えて

1

その場合には、マークアップ拡張機能は、あなたのコードは、「UpdateSourceEventName =のPropertyChanged」を除いて正しいと思われますこれは必要ではなく、これによりUIが更新されない可能性があります。

関連する問題