public static T ShowComboBoxChoiceDialog <T>(String title, String msg, ImageSource icon, int index, SkinBundle bundle, params T[] items) { if (index < 0) { throw new ArgumentException("The index must be greater than -1!"); } InputDialogEx dlg = new InputDialogEx(); dlg.Title = title; dlg.lblMessage.Text = msg; dlg.imgIcon.Source = icon; dlg.cmbInput.Visibility = Visibility.Visible; dlg.txtInput.Visibility = Visibility.Hidden; dlg.cmbInput.IsEditable = false; foreach (T obj in items) { dlg.cmbInput.Items.Add(obj); } dlg.cmbInput.SelectedIndex = index; if (bundle != null) { bundle.SetBundle(dlg); } if (dlg.ShowDialog().GetValueOrDefault(false)) { return((T)dlg.cmbInput.SelectedItem); } return(default(T)); }
private static String ShowDialog(String title, String msg, String text, MessageIcons icon, ImageSource image, SkinBundle bundle, Func <String, bool> validateFunc) { InputDialogEx dlg = new InputDialogEx(); dlg.Title = title; dlg.txtInput.Text = text; if (validateFunc != null) { dlg.txtInput.TextChanged += (s, e) => { if (!validateFunc(dlg.txtInput.Text)) { dlg.txtInput.Undo(); } } } ; dlg.lblMessage.Text = msg; dlg.imgIcon.Source = MessageIconHelper.GetIcon(icon, bundle); if (dlg.imgIcon.Source == null) { if (image != null) { dlg.imgIcon.Source = image; } } if (bundle != null) { bundle.SetBundle(dlg); } /************************************************************/ if (dlg.ShowDialog().GetValueOrDefault(false)) { return(dlg.txtInput.Text); } else { return(null); } }