简体   繁体   中英

Conditional binding using mvvm light on wp7

手动收件人输入

Hi, Please consider the custom wp7 message box above. 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.

What about catching the click event and sending the changed text from View to ViewModel via Messenger. On ViewModel the property would be only a getter.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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