Executing viewmodels command on enter in TextBox

后端 未结 5 1370
深忆病人
深忆病人 2020-12-24 00:23

I want to execute a command in my viewmodel when the user presses enter in a TextBox. The command works when bound to a button.

5条回答
  •  鱼传尺愫
    2020-12-24 01:13

    You have probably not made the command a property, but a field. It only works to bind to properties. Change your AddCommand to a property and it will work. (Your XAML works fine for me with a property instead of a field for the command -> no need for any code behind!)

提交回复
热议问题