sergun

Does some WPF controls handle PropertyChanged event with empty string property name

I need refresh all controls bound to "complex" properties of some object, for example:

building.Location.Address.Street.Name (1)

building.MainContact.Phone (2)

Can I just fire PropertyChanged event for bulding object with "" param

Or should I fire event with "Name" param in building.Location.Address.Street object

and with "Phone" property name in building.MainContact object

Can I use "Location.Address.Street.Name" and "MainContact.Phone" instead for building object

Does the logic of handling change notification depend on what is

Source and Path of binding, for example

Source=building and Path=Location.Address.Street.Name or

Source=street object and Path=Name

Please advise!



Re: Windows Presentation Foundation (WPF) Empty string as property name for PropertyChanged event

Sam Bent - MSFT

In the PropertyChanged event, an empty (or null) property name means "all properties have changed".

You should raise the event to describe what really changed. If you're changing the name of a street, raise the event from the Street object with property name = "Name". A binding with a complex path like "Location.Address.Street".Name" will listen for this event and update correctly.

If you raise an event at the "building" level with empty property name, you'll encounter two kinds of problems.

1. Bindings like your last example (Source=street, Path=Name) won't get the event.

2. All bindings involving the building will update, causing a lot of unnecessary work. A binding that doesn't even use the street name will update anyway. Even the binding to Location.Address.Street.Name will refetch the value of the Location property (and Address and Street), even though they haven't changed.