Click here to Skip to main content
15,941,973 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I want to open a user control on click of a button which is on another user control.

please help and suggest.
Sergey Alexandrovich Kryukov 17-Oct-14 1:07am    
What's the difference where the button is?
There is no such concept, "open a control". So far, the question makes no sense.
Member 10217610 17-Oct-14 1:14am    
Hi SA...

well i am new to this WPF. i dont know why you are saying that qiestion dosnt make any sense.

if you can do then if there is no difference then please tell me how to open an uc on click of a button.


1 solution

The control should not do it, unless the new control is fully within the control opening it.
Normally, this is not the case: both controls are within a form, and should not know of the existence of each other. In this case, the control with the button (call it Child1) signals an event which the form handles, causing the form to create a new control (call it Child2) and add it to the Controls collection.

It's simpler than it sounds: Transferring information between two forms, Part 3: Child to Child[^] covers it pretty much for forms, but the principles (and even the code) is the same for controls within a form.
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