@vlad is on the right track.
Here are a couple of options. Both are related to the handling of routed events.
To handle the routed event, you use the name of the owner class, followed by the name of the event.
The first option is to simply handle the selected event changes (or another ListBox event) in the Window class:
<Window ... ListBox.SelectionChanged="OnChildListboxSelectionChanged"> ... </Window>
The second option (a more typical approach) is to process ListBox events inside the UserControl, and then somehow aggregate them and fire the event at this level. This event is then handled by Window . This event can be a routed event or a standard .NET event.
<UserControl ... ListBox.SelectionChanged="OnChildListBoxSelectionChanged"> ... </UserControl>
User Management Code:
public event EventHandler<MyArgTypeEventArgs> ListBoxUpdated; private void OnChildListBoxSelectionChanged(object sender, SelectionChangedEventArgs e) {
Window handles this event:
<Window ... ListBoxUpdated="OnListBoxUpdated"> ... </Window>
This should give you something to start with.
source share