c# - WPF Create sibling window and close current one -
c# - WPF Create sibling window and close current one -
what need such event handler in window class.
void someeventhandler(object sender, routedeventargs e) { mynewwindow mnw = new mynewwindow(); mnw.owner = window.getwindow(this); mnw.showdialog(); this.close(); }
window.getwindow(this) returns parent window of current window.
i had thought when owner of new window parent window of current one, wait parent; , not current one. did not work way. current window waits execution of new , closes after.
if utilize show() instead of showdialog() reason window not shown @ all.
probably need delegate methods not sure start.
edit: guess need improve question future references: new window should dialog parent window. if utilize show() parent window becomes accesible , dont want that. if utilize showdialog() becomes dialog current window, meaning current window not close until new window closed, , dont want either.
closing window causes windows owns to closed.
if want owner window not visible, seek this;
void someeventhandler(object sender, routedeventargs e) { mynewwindow mnw = new mynewwindow(); mnw.owner = this; this.hide(); // not required if using kid events below mnw.showdialog(); }
you'll want hook event in parent window acts accordingly when close kid window depending on requirements.
edit
you perhaps command hiding of (multiple parents) child;
void onload(object sender, routedeventargs e) { this.owner.hide(); } void closed(object sender, routedeventargs e) { this.owner.show(); }
c# wpf
Comments
Post a Comment