4
就像標題所說,我想驗證我的形式,但我有一個問題越來越組合框的值:確認所選的值在WPF組合框
<ComboBox Name="ComboBox_Country"
Validation.Error="Validation_Error"
Text="{Binding UpdateSourceTrigger=PropertyChanged,
Path=Form_Country,
ValidatesOnDataErrors=true,
NotifyOnValidationError=true}"/>
,然後用我的課FormValidation像驗證所以:
public string this[string columnName]
{
get
{
string result = null;
if (columnName == "Form_Country")
{
if (string.IsNullOrEmpty(Form_Country) || !verifyNumericValue(Form_Country))
result = "Please choose a correct option.";
}
}
我使用這些函數來調用我的表單中的驗證。
private void Confirm_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = _errors == 0;
e.Handled = true;
}
private void Confirm_Executed(object sender, ExecutedRoutedEventArgs e)
{
_generic = new UnidadValidation();
grid_UnidadData.DataContext = _generic;
e.Handled = true;
}
private void Validation_Error(object sender, ValidationErrorEventArgs e)
{
if (e.Action == ValidationErrorEventAction.Added)
_errors++;
else
_errors--;
}
我希望得到選定的值,而不是選定的文本。我最好的選擇是什麼?