Aracılığıyla paylaş


Binding.UpdateSourceTrigger Property

Definition

Gets or sets a value that determines the timing of binding source updates for two-way bindings.

public:
 property UpdateSourceTrigger UpdateSourceTrigger { UpdateSourceTrigger get(); void set(UpdateSourceTrigger value); };
UpdateSourceTrigger UpdateSourceTrigger();

void UpdateSourceTrigger(UpdateSourceTrigger value);
public UpdateSourceTrigger UpdateSourceTrigger { get; set; }
var updateSourceTrigger = binding.updateSourceTrigger;
binding.updateSourceTrigger = updateSourceTrigger;
Public Property UpdateSourceTrigger As UpdateSourceTrigger
<Binding UpdateSourceTrigger="updateSourceTriggerMemberName"/>

Property Value

One of the UpdateSourceTrigger values. The default is Default, which evaluates as a PropertyChanged update behavior for most dependency properties, but evaluates as LostFocus for the TextBox.Text property.

Remarks

The default behavior for most dependency properties is PropertyChanged. However, the default behavior for the TextBox.Text property is LostFocus. For a Binding to TextBox.Text, you can change the UpdateSourceTrigger like this:

<TextBox Text="{x:Bind MyProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

However, it won’t have any effect on a TextBox in the control template of another control, such as NumberBox. For example, this UpdateSourceTrigger setting has no effect.

<!-- This UpdateSourceTrigger setting has no effect. -->
<muxc:NumberBox Text="{x:Bind MyProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

Your other choice for an UpdateSourceTrigger behavior is to set the value to be Explicit. When a two-way binding has its UpdateSourceTrigger value as Explicit, you must explicitly call UpdateSource on the relevant BindingExpression to cause the changed target values to update the data source. Use GetBindingExpression to get a BindingExpression from an object where a Binding to a dependency property exists and that binding is a two-way binding with UpdateSourceTrigger="Explicit".

You can't set the property values of a Binding object after that binding has been attached to a target element and target property. If you attempt this you'll get a run-time exception.

Applies to

See also