Validate the selected value in a WPF combobox

前端 未结 1 1969
-上瘾入骨i
-上瘾入骨i 2021-02-15 15:28

Like the title says, I am trying to validate my form, but I have an issue getting the combobox value:



        
相关标签:
1条回答
  • 2021-02-15 16:02

    Stupid, stupid stupid lack of observation on my part. If you were to change the ComboBox's Text to SelectedValue instead like so:

    <ComboBox Name="ComboBox_Pais" 
              Validation.Error="Validation_Error"
              SelectedValue="{Binding UpdateSourceTrigger=PropertyChanged, 
                                      Path=Escuela_Pais,
                                      ValidatesOnDataErrors=true, 
                                      NotifyOnValidationError=true}"/>
    

    One will get the selected value and NOT the text.

    For those of you who might want to read on it, I found the original tutorial here.

    WPF TextBox Validation with IDataErrorInfo

    0 讨论(0)
提交回复
热议问题