private void DialogOkClicked(object sender, RoutedEventArgs e) { string opStr = TypeValueOperator.SelectedItem as string; _operator = FilterValue.GetOpFromDescr(opStr); if (TypeExtractor.IsString(_kind)) { _valStr = TbTypeValue.Text; _valObj = _valStr; if ((bool)TypeValueCase.IsChecked) { _operator |= FilterValue.Op.IGNORECASE; } if ((bool)TypeValueRegex.IsChecked) { _operator |= FilterValue.Op.REGEX; try { Regex regex = new Regex(_valStr); } catch (ArgumentException ex) { GuiUtils.ShowError(ex, this); return; } } DialogResult = true; return; } _valStr = TbTypeValue.Text.Trim(); if (TypeExtractor.GetTypeFromString(_valStr, _kind, out _valObj)) { DialogResult = true; return; } MessageBox.Show("String format of the value is invalid.", "INVALID FORMAT", MessageBoxButton.OK, MessageBoxImage.Error); }