xaml - Xamarin - 将 textchange 和 unfocus 事件分配给文本框(密码)
问题描述
我的 XAML 文件看起来像这样
<local:PlainEntry IsPassword="True" Placeholder="Pwd"
x:Name="contrasenaEntry" HorizontalOptions="Fill"
VerticalOptions="Center" Text="{Binding Password, Mode=TwoWay}" Margin="0"/>
有没有办法在我尝试使用 Password.myElement.IsFocused 的文本字段 Password 上触发 Onchange 和 unfocus 事件,但它不起作用。我试过了
private void PasswordEditText_TextChanged(object sender, TextChangedEventArgs e)
{
Console.WriteLine("text has changed!");
// this is not working!
}
解决方案
它显示您正在绑定到属性“密码”,这看起来像是您正在使用 MVVM,但是您编写的那个方法看起来像是一个代码隐藏方法。
如果你在后面使用代码,你会想要使用这样的东西..
<local:PlainEntry IsPassword="True" Placeholder="Pwd"
x:Name="contrasenaEntry" HorizontalOptions="Fill"
VerticalOptions="Center" TextChanged="PasswordEditText_TextChanged"
Margin="0"/>
然后调用你已有的方法
private void PasswordEditText_TextChanged(object sender, TextChangedEventArgs e)
{
Console.WriteLine("text has changed!");
// this is not working!
}
推荐阅读
- python - python中的“int类型的对象没有长度”是什么意思?
- python - 带有 if/elif/else 语句的 While 循环
- mysql - 使用 DENSE_RANK() MySQL 缺少右括号
- postgresql - Asp Net Boilerplate - 设置 Schema-Per-Tenant Multitenancy (EntityFrameworkCore & PostgreSQL)
- c# - SerialDataReceivedEventHandler 不工作 c#
- java - 警报管理器未设置特定日期或超过 24 小时的警报
- python - Python并发日志记录以避免代码中的磁盘瓶颈
- apache-spark - 当数据帧按单列分区时,高效的 Spark 在多列上左连接
- python - Postman、Python 以及将图像和元数据传递给 Web 服务
- python - 未找到“”的反向。'' 不是有效的视图函数或模式名称