Click here to Skip to main content
15,891,903 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am searching for a mechanism to communicate between user controls which are at same hierarchy.

I have a page that has 2 user controls
1) Search Control : This control has a text box and a GO button
2) CustomGrid Control : This control shows data in a Grid.

When user enters a search text and clicks the GO button, the grid inside the CustomGrid
control should display data based on search text.

How will CustomGrid control know that GO button inside the SearchControl has been clicked?
I wanted to make it loosely coupled because of 2 reasons
1) CustomGrid Control is reused in other pages where search feature is not needed.
2) There can be multiple instances of CustomGrid control on the same page. Search should apply to all the CustomGrids.

My gut feel is RoutedCommand is the way to go. But so far i am able to get it working only when target control is up in the visual tree(bubling up).
How to communicate between controls at same hierarchy?

Thanks in advance.
Posted
Comments
Khaniya 29-Jan-11 0:48am    
I am having same question
thanks for asking
Mark Salsbery 21-Jun-11 14:58pm    
Handle it at the next level up - the parent page. There's no reason the two user controls need to know about each other.

Event Aggregation [^]might be useful to you.
 
Share this answer
 
Can anyone respond with a solution? Seems like it would be fairly simple. I have a similar situation and I am too new to WPF to help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900