【发布时间】:2019-04-25 08:24:04
【问题描述】:
我使用以下方法来设置我的变量:
private string _password = "";
public string Password
{
get => _password;
set {
_password = value;
this.OnPropertyChanged("Password");
this.OnPropertyChanged("_password");
}
}
这是在我通过以下方式绑定的 ViewModel 中:
<ContentPage.BindingContext>
<vm:MainPageViewModel/>
</ContentPage.BindingContext>
我的 xaml 中有一个条目:
<Entry Text="{Binding Password,Mode=TwoWay}"
HorizontalOptions="Start"
VerticalOptions="Start">
</Entry>
我在 ViewModel 中访问条目中的信息没有问题,但是当我调用时
Password = "";
在屏幕上的 UI 中显示的条目文本保持不变。如何从我的 ViewModel 中删除条目中的文本? 该行为发生在 Android/iOS 和 UWP 中。
【问题讨论】:
-
你的虚拟机真的实现了 INotifyPropertyChanged 吗?
标签: xamarin xamarin.forms