Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Helle everyone,
I am using WPF forms for desktop application. I need to open one user control from the button click of another user control and I need to pass data from one user control to another. How do I do it ?
Thanks !

What I have tried:

Tried to open the user control from the other, but the showdialogue method does not open the user control.
Posted
Updated 3-Apr-16 2:24am

1 solution

Create an event in the control holding the button.
The container holding the two controls handles the event, reads the data via a property, and passes it to the other control via its properties.
That way, neither control needs to know about the existence of the other and the container decides what happend to the data, as is good OOPs practice.
There is an example here: Transferring information between two forms, Part 3: Child to Child[^]. It's concerned with forms in a WinForms application, but the principles - and even the code - is exactly the same.
 
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