通过 MVVM 命令的 TextBox.TextChanged 事件/ComboBox.TextInput 事件
我最近 2 天发现有关通过命令触发 TextBox.TextChanged 事件或 ComboBox.TextInput 事件的附加命令行为。但是,我无法为此找到任何适当的解决方案。
我得到的解决方案之一是通过将 Text 绑定到 ViewModel 属性来调用 UpdateSourceTrigger=PropertyChanged 上所需的方法。
但是,根据 MVVM 的研究结果,除了包括 OnPropertyChanged 在内的私有成员的 getter 和 setter 之外,属性不应包含任何其他代码。
所以,任何人都可以帮助我,指导我是否朝着正确的方向前进。或者在某个地方遗漏了一些东西。
详细的解释或链接或示例代码将受到高度赞赏。
享受编码, 维杰
I'm finding for last 2 days about the attached-command-behaviour firing TextBox.TextChanged Event or ComboBox.TextInput Event through Commanding. But, I can't get any proper solution for this.
One of the solution, I got was calling the desired method on UpdateSourceTrigger=PropertyChanged by binding the Text to ViewModel property.
But, according to the findings on MVVM, property should not hold anyother code other than getter and setter of private member including OnPropertyChanged.
so, can anyone help me on this, guide me whether i'm going in a right direction or not. Or missing something somewhere.
A detailed explanation or links or sample code will be highly appreciated.
Enjoy Coding,
VJ
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是什么让你这么想?在 setter 中包含任何您想要的代码都可以...无论如何,这比使用附加行为要容易得多
What makes you think that? It's fine to have any code you want in the setter... Anyway, it's much easier than using an attached behavior