Suspend binding in Silverlight
I have a ChildWindow (Ok, Cancel buttons) that contains binded controls. I want the开发者_JAVA技巧 behind object to be updated only when pressing the 'OK' button. What's the best way to do it?
You need to set the UpdateSourceTrigger property of the bindings to Explicit. Then, on clicking OK, you call UpdateSource() on the Binding:
BindingExpression expression = textBox1.GetBindingExpression(TextBox.TextProperty);
expression.UpdateSource();
Or you don't bind the ChildWindow to the original ViewModel but use a temporary and assign its values to the original on OK
精彩评论