我应如何将用户控件的文本属性绑定到其他属性 [英] How shall i bind a text property of a usercontrol to different properties

查看:67
本文介绍了我应如何将用户控件的文本属性绑定到其他属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有文本框的子userconrol,并且我已将text属性绑定到相应的视图模型...

但是我想将相同的text属性绑定到我的父级View模型属性

.... ????
在此先感谢

I have a child userconrol with a textbox and i have binded the text property to the respective view model ...

But i would like to bind the same text property to my parent View model property

is it possible.....??
thanks in advance

推荐答案

触发事件怎么办?在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).


这篇关于我应如何将用户控件的文本属性绑定到其他属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆