在我的Maui XAML中,我有一个最初启用的Entry控件,一旦用户在该控件中输入了正确的值,我希望以编程方式禁用它.
但事实并非如此
我的xaml代码看起来像这样
<Entry
x:Name="InputAnswer"
Margin="0,0,20,0"
FontSize="24"
HorizontalOptions="Start"
IsEnabled="{Binding IsWrong}"
Keyboard="Numeric"
MaxLength="5"
Placeholder=""
Text="{Binding InputAnswer}" />
我的模特班
public class EquationWithInput: Equation, INotifyPropertyChanged
{
public int? InputAnswer { get; set; }
public int CorrectAnswer{ get; set; }
public bool IsWrong { get => InputAnswer == null ? true : InputAnswer != CorrectAnswer; }
...
}
但当我判断结果时,该控件从未被禁用.绑定似乎不起作用,但对于所有其他属性,它在此页面中的其他所有位置都有效.例如,InputAnswer
人.
那么我需要做些什么才能让这件事起作用呢?