我发生性关系组合框(男,女..):我从用户的需求来选择一个值(组合框没有默认值)。WPF组合框验证
<ComboBox ItemsSource="{x:Static Member=data:Sex.AllTypes}" SelectedItem="{Binding Path=Sex.Value, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}" VerticalAlignment="Top">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Sex.Value是在我的个人类物业:
public class Person : IDataErrorInfo
{
public string this[string columnName]
{
get
{
switch (columnName)
{
case "Sex": return Sex.Value == null ? "Required field" : null;
case "Surname": return string.IsNullOrEmpty(Nachname) ? "Required field" : null;
}
}
}
public string Error
{
get
{
return null;
}
}
}
的问题是,它不会进入此[字符串列名。
当我尝试用名称文本框,它进入这个[字符串列名],一切工作正常:
<TextBox Style="{StaticResource textBoxInError}" Text="{Binding Path=Surname, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}"/>