Click here to Skip to main content
13,668,134 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 11 Jun 2010
Licenced CPOL

TIP: Handling WPF DialogResult with simplicity

, 4 Sep 2010
Rate this:
Please Sign up or sign in to vote.
Shorter way to evaluate DialogResult after calling Window.ShowDialog
I have seen many code snippets like:
if (frm.DialogResult.HasValue && frm.DialogResult.Value) 
   // do something here
DialogResult result = frm.ShowDialog();
if (result.HasValue && result.Value)
   // do something here
This double check is done because DialogResult is of nullable type: bool?, but evaluation can be as simple as:
if (frm.DialogResult.Equals(true))
   // do something here


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


About the Author

Jaime Olivares
Peru Peru

Computer Electronics professional, Software Architect and senior Windows C++ and C# developer with experience in many other programming languages, platforms and application areas including communications, simulation systems, PACS/DICOM (radiology), GIS, 3D graphics and HTML5-based web applications.
Currently intensively working with Visual Studio and TFS.

You may also be interested in...


Comments and Discussions

QuestionMy 2 cents Pin
Thomas Polaert14-Dec-12 0:49
memberThomas Polaert14-Dec-12 0:49 
GeneralThanks.. I guess the best way to check for bool? is the make... Pin
Simon Dufour19-Aug-10 3:24
memberSimon Dufour19-Aug-10 3:24 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180820.1 | Last Updated 4 Sep 2010
Article Copyright 2010 by Jaime Olivares
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid