/// <summary> /// Instantiates a new OptionsDialog. /// </summary> /// <param name="message">string: The caption message to display to the User</param> /// <param name="options">string[]: The List of Option Labels to be Presented to the User</param> /// <param name="mood">System.Windows.MessageBoxImage enum: Used to derive the background color schema</param> /// <param name="title">string: Optional. Title Bar Content</param> public OptionsDialog(string message, string[] options, MessageBoxImage mood, string title = null) : this() { const int ITEMWIDTH = 284; const int ITEMHEIGHT = 20; this.Caption.Content = title; this.Message.Text = message; foreach (string option in options) { if (!string.IsNullOrEmpty(option)) { InlineCheckBox icb = new InlineCheckBox(option) { Margin = new Thickness(4), Width = ITEMWIDTH, Height = ITEMHEIGHT, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; this.Options.Items.Add(icb); } } this.Mood = mood; UpdateLayout(); }
private void BtnOK_Click(object sender, RoutedEventArgs e) { List <string> ret = new List <string>(); foreach (var cntrl in this.Options.Items) { if (typeof(InlineCheckBox) == cntrl.GetType()) { InlineCheckBox chk = cntrl as InlineCheckBox; if (chk.IsChecked == true) { ret.Add(chk.Caption); } } } this.Result = ret; this.DialogResult = true; }