I am using Window.ShowDialog()
method to fetch some values from the user. However, the dialog will only return a nullable bool.
How can I get my WPF window to return a Tuple<string,string>
or any other type?
You could add a new method to your Window, something like this:
public Tuple<string, string> ShowTupleDialog()
{
var retTuple = new Tuple<string, string>();
this.ShowDialog();
// values from dialog to retTuple (maybe use
//databinding and return an already defined tuple)
return retTuple;
}
You don't need to return that value from the ShowDialog method, as explained here: "A Nullable<(Of <(T>)>) value of type Boolean that signifies how a window was closed by the user".
You can simply store the value you want to return in a property or field and get it:
window.ShowDialog();
Tuple<string, string> value = window.InputValue;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With