I don't know of any direct way to do that. And i personally never had the desire to do so. When you only use the OnXYZChanged
methods to register to events (which is imo the most common case) you could register to an event which better suits the order of your desired code execution. For example, in the OnXYZChanged
register to Loaded
event and handle that, the order of these should be afair from Root to child, and therefore in the correct order.
Another way would be to test which one was called second, and do your logic in there.
Another idea would be to use the Dispatcher
and do all the logic at a later time where its sure that everything is loaded.
And a final idea, You could traverse with the VisualTreeHelper
from the child element in the OnXYZChanged
to the underlying window and set the property on the window first and then handle the logic for the child.
@Your edit:
If you think about it, it makes sense. The visual tree must be created and everything must be chained before the Binding can traverse the tree to find the appropiate DataContext.