xamarin - 如何从 ViewModel 触发“完成”事件?
问题描述
我有一个完整的动作条目:
<local:BaseEntry Placeholder="Email Address" Keyboard="Email" x:Name="EmailEntry" ReturnType="Next" Completed="{Binding GoToPassword}"/>
当用户从键盘按下完成按钮时,我想专注于下一个条目。那么如何从 ViewModel 执行 Completed 操作呢?
解决方案
那么如何从 ViewModel 执行 Completed 操作呢?
在 Xaml 中使用ReturnCommand
andReturnType
而不是:Completed
<local:BaseEntry Placeholder="Email Address" Keyboard="Email" x:Name="EmailEntry" ReturnType="Next" ReturnCommand="{Binding CommandComplete}" ReturnType="Done"/>
然后在ViewModel添加CommandComplete
属性:
public System.Windows.Input.ICommand CommandComplete { get; set; }
CommandComplete = new Command(() => { Console.WriteLine("Complete method"); });
推荐阅读
- c++ - 以二进制模式 C++ 无法正确读取文件
- python - 如何在 Python 中使时间戳原子/中断安全?
- r - 闪亮测试中的错误。无法检测到我的脚本是 R 文件
- machine-learning - 如何将此 keras cnn 模型转换为 pytorch 版本
- angular - Angular 7 ERROR TypeError:无法读取未定义的属性“管道”
- apache-camel - 如果查询的远程目录中有很多文件(超过 10,000 个),Camel sftp 会失败
- sqlalchemy - 在长时间运行的 Celery 任务中使用 SQLAlchemy 对象
- python - Numpy乘法矩阵(两个以上的矩阵)
- javascript - 在使用 ng-click 指令单击按钮时,如何防止在使用 puppeteer 抓取期间打开新选项卡?
- ios - 在 Swift 中使用货币