问题描述
在我的Xamarin应用程序中,尝试确认密码(密码和确认密码)时,将IsVisible
的{{1}}和Frame
的{{1}}更改为应该有相同的文字),但没有任何改变。
具有讽刺意味的是,当应用程序打开时,默认情况下(未输入任何值),IsEnabled
为True。
当两个Button
字段的值相同时,我想更改它。谢谢。
.xml代码
Password.Text == ConfirmPassword.Text
.xml.cs代码
Entry
解决方法
将您的if条件更改为此
ID | Sentence
1 This is very nice
1 Yes,very nice indeed
2 Hi,my name is John
,
使用以下linq:
sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
,
Xaml代码
<Entry
x:Name="Password"
IsPassword="True"
Keyboard="Numeric"
MaxLength="8"
ReturnType="Next" Unfocused="Password_Unfocused" />
<Entry
x:Name="ConfirmPassword"
IsPassword="True"
Keyboard="Numeric"
MaxLength="8"
ReturnType="Done" Unfocused="ConfirmPassword_Unfocused"/>
<Frame x:Name="RedBar" BackgroundColor="#E1444D" IsVisible="true">
<BoxView />
</Frame>
<Frame x:Name="GreenBar" BackgroundColor="#24D27F" IsVisible="false">
<BoxView />
</Frame>
<Button
x:Name="PasswordButton"
Clicked="PasswordButton_Clicked"
IsEnabled="False"
Text="Submit">
</Button>
隐藏代码
public PasswordPage()
{
InitializeComponent();
ValidatePassword();
}
private void Password_Unfocused(object sender,FocusEventArgs e)
{
ValidatePassword();
}
private void ConfirmPassword_Unfocused(object sender,FocusEventArgs e)
{
ValidatePassword();
}
private void ValidatePassword()
{
if (!string.IsNullOrEmpty(Password.Text) && !string.IsNullOrEmpty(ConfirmPassword.Text))
{
if (Password.Text == ConfirmPassword.Text)
{
RedBar.IsVisible = false;
GreenBar.IsVisible = true;
PasswordButton.IsEnabled = true;
}
else
{
RedBar.IsVisible = true;
GreenBar.IsVisible = false;
PasswordButton.IsEnabled = false;
}
}
else
{
RedBar.IsVisible = true;
GreenBar.IsVisible = false;
PasswordButton.IsEnabled = false;
}
}