且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我应如何将用户控件的文本属性绑定到其他属性

更新时间:2021-12-18 03:21:44

触发事件怎么办?在TextBox的TextChanged事件上,将父级属性的值设置为TextBox中的值吗?
What about firing an event? On the TextBox''s TextChanged event, set the value of the property in your parent to what is in the TextBox?


您不能将相同的UI属性绑定到两个模型属性.这里有两个选项:要么将文本框的VM和父级VM绑定到相同的模型属性,要么将文本框绑定到父级的VM(好吧,文本属性,但是那个''可能就是您从文本框中绑定的所有内容.)
You can''t bind the same UI property to two model properties. There are two options here: either have the VM for the text box and the VM for the parent bind to the same model property, or bind the text box to the parent''s VM (well, the text property, but that''s probably all you''re binding from a text box).