3

I would like to know when any input element on my Window has its Binding source updated.

The input elements could be TextBox, RadioButton, Slider, ComboBox etc, and may be nested within UserControls or Panels.

Catching SourceUpdated would be nice, but it is not a routed event so is not bubbled to the parent.

Is there a simple way to do this?

Greg Sansom
  • 20,442
  • 6
  • 58
  • 76

1 Answers1

2

SourceUpdated does bubble up from nested children, but NotifyOnSourceUpdated needs to be set on the Binding expression:

<StackPanel SourceUpdated="StackPanel_SourceUpdated">
    <TextBox Text="{Binding Path=Val1, NotifyOnSourceUpdated=True}" ></TextBox>
</StackPanel>

I'd still love to hear about a method which does not require setting NotifyOnSourceUpdated for every binding expression.

Greg Sansom
  • 20,442
  • 6
  • 58
  • 76
  • Maybe you should write a class which derives from Binding and sets NotifyOnSourceUpdated in it's constructor. But as for me, I think that the right way is to set NotifyOnSourceUpdated in a Binding explicitly, without any sugar. – Marat Khasanov Jan 21 '11 at 07:42