views:

499

answers:

1

Hi

I want to set the UpdateSourceTrigger to an event of a control:

<TextBox Text="{Binding Field, UpdateSourceMode=btnOK.Click}">
<Button Name="btnOK">
    <Button.Triggers>
        <Trigger>
            <!-- Update source -->
        </Trigger>
    </Button.Triggers>
</Button>

I thought about two ways:

  1. Set UpdateSourceMode or some other stuff in the binding.
  2. Set an EventTrigger that updates source on button click.

Possible, or I have to do it with code?

+1  A: 

You'll have to use code. Specifically:

  1. Set UpdateSourceTrigger=Explicit on the TextBox.
  2. Call UpdateSource when the user clicks the Button.

However, you can put the code in the code behind or in an attached behavior.

HTH, Kent

Kent Boogaart
Kent, I there a way to do it Xamly? Because I have a gazillion TextBoxes in my form, and I want that when the user clicks 'Save' it should update source, I don't want to get all the BEs and update one by one.
Shimmy
I guess I am gonna use BindingGroup.UpdateSources().
Shimmy
No built-in way that I know of. But like I stated, you could write your own attached behavior that does it.
Kent Boogaart