public static Tuple <bool, T> Show <T>(string questionText, string title, T defaultValue, NumTextBox.Type type = NumTextBox.Type.Int) { var res = true; T t = default(T); Application.Current.Dispatcher.Invoke(new Action(() => { InputBoxX nb = new InputBoxX { Title = title, QuestionText = questionText, Type = type, NumText = defaultValue.ToString(), Owner = ControlHelper.GetTopWindow() }; nb.ShowDialog(); try { t = (T)Convert.ChangeType(nb.NumText, typeof(T)); } catch (FormatException) {} res = nb.Result; })); return(new Tuple <bool, T>(res, t)); }