Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a user control , i'm able to close the whole app... but i want to close only the user control. I have not added the user control in the app, and removed the user control from the app..

this is the code i used in mvvm to open the user contol


Window window = new Window
{
Title = "Sl",
Content = new View,
DataContext = new ViewModel()

};
Posted

1 solution

There is no such concept as "closing a control". And I don't think that such concept, if existed, could be of any use. You can: 1) hide the user control if it is no longer needed, maybe temporarily; 2) permanently remove the control from the logical tree.

Please see:
http://msdn.microsoft.com/en-us/library/system.windows.uielement.isvisible(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.uielement.visibility(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.visibility%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms753391%28v=vs.110%29.aspx[^].

Perhaps you need to understand one thing: the UI notions "open" and "close" are nothing but idioms; and those idioms are not even too precise: you are not really open or close anything: you create a window, show it, hide it temporarily or permanently dispose. I think the only real reason for these idioms is the simple fact: because window is called "window", something with a material life prototype which can really be opened and closed. The analogs of these terms in computer UI are quite far from these original notions.

—SA
 
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