简体   繁体   English

在wp7上使用mvvm light进行条件绑定

[英]Conditional binding using mvvm light on wp7

手动收件人输入

Hi, Please consider the custom wp7 message box above. 嗨,请考虑上面的自定义wp7消息框。 I am looking to see what is the cleanest way to bind a views textbox to a property on the view model only after a button is clicked. 我正在寻找仅在单击按钮后将视图文本框绑定到视图模型上的属性的最干净的方法是什么。 The only way I can work out is to have two properties and use a command on the button to assign the value of the first prop to the main prop. 我能解决的唯一方法是拥有两个属性,并在按钮上使用命令将第一个道具的值分配给主道具。 The main prop should only receive the value from the textbox only if the user clicks the tick button and not if they cancel (by pressing the back button). 仅当用户单击对勾按钮时,主道具才应从文本框中接收值,而不是在取消(通过按后退按钮)的情况下,则不会。

I am using MVVM Light. 我正在使用MVVM Light。

What about catching the click event and sending the changed text from View to ViewModel via Messenger. 如何捕获单击事件并通过Messenger将更改后的文本从View发送到ViewModel。 On ViewModel the property would be only a getter. 在ViewModel上,该属性将只是一个吸气剂。

I think that the way you do it is ok. 我认为您的操作方式还可以。 Have a temporary binded property and main property synced with the temporary one only when messagebox is accepted. 仅当接受消息框时,才使临时绑定属性和主属性与临时属性同步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM