WPF, notify a child in the element tree about an event in a parent

Posted by jester on Stack Overflow See other posts from Stack Overflow or by jester
Published on 2013-10-31T06:45:43Z Indexed on 2013/11/04 9:55 UTC
Read the original article Hit count: 298

Filed under:
|

I am developing a WPF app and I want an event in a parent to be notified to several of its children in the element tree, so that each of them can take an action accordingly. I know that a custom RoutedEvent can be used to signal in the other direction from a child to one of its ancestors by bubbling the event upwards, so that any of the ancestor elements can handle the event. What I want is the children to be notified about an event in the parent and they handle them appropriately. What is the best strategy to achieve this?

EDIT:

Clarifying the comments : Say I have a parent UserControl. It has a TabControl and its contents are several nested child UserControls. Now consider a scenario where I want the TabControl.SelectionChanged() event to cause some changes in each of the child UserControl. How to achieve this? (The contents of each tab is a UserControl which themselves may contain another few levels of children UserControls. I want the UserControl in the bottom level to know about the SelectionChanged() event and respond accordingly).

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf