To return an object from the ShowDialog()
method in a WPF application, you can create a new window and define a property to hold the return value.
Here's an example:
main.cs378 chars16 lines
In DialogWindow
class, you can define a property ReturnValue
to hold the return value :
main.cs657 chars24 lines
In this example, the OkButton
click event handler sets the ReturnValue
property with the desired object and closes the dialog. The CancelButton
click event handler cancels the dialog without setting the return value.
gistlibby LogSnag