我有一个完整的操作条目:
<local:BaseEntry Placeholder="Email Address" Keyboard="Email" x:Name="EmailEntry" ReturnType="Next" Completed="{Binding GoToPassword}"/>
当用户按下键盘上的完成按钮时,我想关注下一个条目。 那么如何从ViewModel执行完成的动作?
答案 0 :(得分:1)
那么如何从ViewModel执行完成的动作?
在Xaml中使用ReturnCommand
和ReturnType
代替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"); });