【问题标题】:INotifyPropertyChanged not working for static properties in xamarin formsINotifyPropertyChanged 不适用于 xamarin 表单中的静态属性
【发布时间】:2017-11-02 06:13:43
【问题描述】:

我在我的代码中为静态属性实现了INotifyPropertyChanged。但不影响用户界面。在这里,我添加了我的代码。任何人对此都有想法。提前致谢。

     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}">

【问题讨论】:

    标签: xamarin.forms inotifypropertychanged


    【解决方案1】:

    我假设您的“LoginPageModel”类也是静态的,因为您使用的是“x:Static”标记扩展,在这种情况下,您的代码似乎是正确的,但不需要“UpdateSourceEventName=PropertyChanged”这可能会导致您的 UI 无法更新。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-14
      • 2017-05-22
      • 1970-01-01
      • 2017-03-15
      • 1970-01-01
      • 2018-07-01
      • 2011-06-08
      • 1970-01-01
      相关资源
      最近更新 更多