Reputation:
I want to set the control binding property "updatesource=Explicit" in cs file (dynamically) not in UI end. Please help me how can i do this?
Upvotes: 0
Views: 151
Reputation: 493
it works :)
this.GetBindingExpression(SomeProperty).ParentBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
Upvotes: 1
Reputation: 2273
I tested it and it works. :-) The code remains the same as Gimalay's.
BindingExpression bindingExpr = this.textBox1.GetBindingExpression(TextBox.TextProperty);
bindingExpr.ParentBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
Upvotes: 0
Reputation: 310822
Are you creating the binding in code manually? If so you can just set it like any other property:
var binding = new Binding("BindingPath")
{
Source = myDataObject,
UpdateSourceTrigger = UpdateSourceTrigger.Explicit
}
textBlock.SetBinding(TextBlock.TextProperty, binding);
Upvotes: 0