开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜