tags:

views:

76

answers:

3

Hi,

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?

+1  A: 

it works :)

this.GetBindingExpression(SomeProperty).ParentBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
gimalay
A: 

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);

More information here.

Drew Noakes
A: 

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;
Trainee4Life