0
在silverlight 4中,我有組合框和其他控件。 ValidationSummary can和does顯示控件的驗證錯誤,但組合框錯誤除外。 這是我的XAMLValidationSummary不顯示組合框驗證錯誤
<ComboBox x:Name="cmbGender" Grid.Row="6" Grid.Column="1" Margin="5,5,0,0" Width="100"
HorizontalAlignment="Left" VerticalAlignment="Center"
sdk:ValidationSummary.ShowErrorsInSummary="True"
ItemTemplate="{StaticResource cmbGenderItemTemplate}"
IsEnabled="{Binding IsAddingOrEditing}"
ItemsSource="{Binding Genders}"
SelectedItem="{Binding EmployeeDetails.Gender, Mode=TwoWay,
ValidatesOnDataErrors=True, ValidatesOnNotifyDataErrors=True,
ValidatesOnExceptions=True, NotifyOnValidationError=True}"
/>
而在我的VM我有這樣的元數據綁定到的SelectedItem
[Display(Name = "LabelGender", ResourceType = typeof(AnnotationResources))]
[Required(ErrorMessageResourceName = "ValidationGenderRequired",
ErrorMessageResourceType = typeof(AnnotationResources))]
public GenderData Gender
{
get
{
return _gender;
}
set
{
if (value != _gender)
{
_gender = value;
this.RaisePropertyChanged("Gender");
Validator.ValidateProperty(
_gender,
new ValidationContext(this, null, null) { MemberName = "Gender" });
}
}
}
這是我的ValidationSummary
<sdk:ValidationSummary Margin="0,5,0,0" Target="{Binding ElementName=gridDetails}" />
XAML但是,如果我打電話驗證。 TryValidateObject,那些錯誤(comboBoxes錯誤)在那裏。
請幫忙,已經花了幾天的時間搜索這個問題,沒有運氣。