Xamarin.forms INotifyPropertyChanged不适用于xamarin表单中的静态属性
我已经在代码中为静态属性实现了INotifyPropertyChanged。但这并不影响用户界面。这里我添加了我的代码。任何人对此都有想法。提前谢谢Xamarin.forms INotifyPropertyChanged不适用于xamarin表单中的静态属性,xamarin.forms,inotifypropertychanged,Xamarin.forms,Inotifypropertychanged,我已经在代码中为静态属性实现了INotifyPropertyChanged。但这并不影响用户界面。这里我添加了我的代码。任何人对此都有想法。提前谢谢 private static string dateTimeValue; public static string DateTimeValue { get { return dateTimeValue; } set { dateTimeValue = value; RaisedPropertyChanged("
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}">
我假设您的“LoginPageModel”类也是静态的,因为您使用的是“x:static”标记扩展,在这种情况下,您的代码似乎是正确的,只是不需要“UpdateSourceEventName=PropertyChanged”,这可能会导致您的UI不更新