Click here to Skip to main content
15,881,588 members
Articles / Desktop Programming / WPF
Alternative
Tip/Trick

TIP: Handling WPF DialogResult with simplicity

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
7 Sep 2010CPOL 7.4K   1   1
what about this one :if (new frm().ShowDialog().Equals(true)) { //do something }
what about this one :
if (new frm().ShowDialog().Equals(true))
      {
         //do something
      }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 3 That's basically the same as my orig... Pin
Jaime Olivares5-Sep-10 22:12
Jaime Olivares5-Sep-10 22:12 
Reason for my vote of 3
That's basically the same as my original proposal: to use .Equals(true)

The problem with using constructor in the same line as ShowDialog is that you don't have any reference to the dialog inside the "if" block, so you cannot gather any data from it. This will work just in dialogs like messageBox with yes/no or ok/cancel.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.