c# - Is ShowDialog handled differently in WPF than Winforms? -


i have issue in converting winforms program wpf program. in first program, had smaller window open allow user adjust data, , when closed, other form activated again new data.

i used form2.showdialog(); open form, automatically makes parent form deactivated in winforms. way when closed form2, parent form activated, , able use event handler form1_activated reload , re-initialize of settings successfully.

however, when attempt same thing wpf, still able open form2 using form2.showdialog();, when close form, not register form1_activated event handler. instead, in order reload settings, must click on window, , come program register form1_activated event handler.

am doing wrong, or there event handler should using in wpf achieve same thing able in winforms?

calling showdialog() causes dialog box top appear in modal mode don't understand why need event handler process results after dialog box closed. keep in mind can access public variables in dialogbox, well. if understand question, should asking:

mainwindow:

my_dialogbox dlg = new my_dialogbox(); dlg.owner = this; dlg.mypublicvariable = ''; //some value might need pass dialog dlg.showdialog();  //exection of mainwindow suspended until dialog box closed  if (dlg.dialogresult == true) {     //dlg.mypublicvariable still accessible      //call whatever routines need in order refresh main form's data } 

dialogbox:

private void ok_button_click(object sender, routedeventargs e) {     mypublic variable = something;  //accessible after dialog has closed.     this.dialogresult = true; }  private void cancel_button_click(object sender, routedeventargs e) {      this.dialogresult = false; } 

the msdn write-up on dialog boxes pretty good. there may tips might more: http://msdn.microsoft.com/en-us/library/aa969773.aspx

good luck!


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -