c# - How to close the previous window when a new window shows -


this scenario:

my first window contains listview, each items in listview contain button, if user click button, detail window shows.

i don't want application shows many window, 1 enough, if user click item, window shows, , when user click item, content of window changes, doesn't create new window show. make window singleton, of content using databinding (mvvm pattern), if close window, resource disposed, not show again, override closing method, let window cancel, not closed, in way, close application, window still not been disposed, there's process can see in task manager.

anybody has more sensible idea? thanks.

edit:

 private void window_closing(object sender, system.componentmodel.canceleventargs e)     {         e.cancel = true;         this.visibility = visibility.hidden;     } 

try making custom user control can loaded dynamically in run-time. example:

//constructor builds customer user control using form argument itemcontrol control = new itemcontrol(controlform2); //clear , load user control panel of form displayed this.controlpanel.controls.clear(); this.controlpanel.controls.add(controlform2); 

however, not appropriate way of handling kind of control. should make form receives parameters click event generate corresponding form based on has user clicked in list view.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -