8

I have a binding that works. The GUI updates.

<DataGridTextColumn Binding="{Binding Path=Value, 
                              NotifyOnTargetUpdated=True, 
                              NotifyOnSourceUpdated=True, 
                              Mode=OneWay}"/>

The binding source object implements INotifyPropertyChanged and the binding property is a normal clr property.

The Binding.TargetUpdated event fires, but not the Binding.SourceUpdated event.

For example, the following works

<EventTrigger RoutedEvent="Binding.TargetUpdated"> ...

but

<EventTrigger RoutedEvent="Binding.SourceUpdated"> ...

does not.

It makes no difference if I create the binding in code or XAML, use EventTrigger in the Triggers collection or an EventSetter. As far as I can tell the event is just not firing.

Does anyone know how to make Binding.SourceUpdated fire?

Zero
  • 11,593
  • 9
  • 52
  • 70
  • The reason is I would like to be able to access the Source object when the binding changes. Even better, I would like to easily get the source property (that is `obj.Value` in the above example). I can do this using reflection and the binding object from the target, but htat is very painful. – Zero May 28 '12 at 12:39
  • 1
    You have to change Mode=TwoWay... – Chibueze Opata Jul 26 '12 at 18:34

1 Answers1

9

Could it be that 'TargetUpdated' is fired when the source changes and 'SourceUpdated' is fired when the target changes?

(@black-stallion gave me a hint to what might be going on, but I'm hoping people will comment / edit if this is correct or incorrect!)

Zero
  • 11,593
  • 9
  • 52
  • 70
  • 2
    [Binding.SourceUpdated](http://msdn.microsoft.com/en-us/library/system.windows.data.binding.sourceupdated.aspx) Attached Event Occurs when a value is transferred from the binding target to the binding source. – akjoshi Jun 12 '12 at 07:13
  • 1
    I get it. So confusing the name is! – Gqqnbig Feb 20 '13 at 09:01
  • for me, this was the solution: https://stackoverflow.com/a/5619557/9258504 – SamBerk Dec 31 '20 at 16:11