private void InitializeModelInternal(string modelProperty, object model)
{
if (model != null)
{
ViewModelManager.RegisterModel(this, model);
}
_modelsDirtyFlags[modelProperty] = false;
_modelErrorInfo[modelProperty] = new ModelErrorInfo(model);
_modelErrorInfo[modelProperty].Updated += OnModelErrorInfoUpdated;
var modelAsINotifyPropertyChanged = model as INotifyPropertyChanged;
if (modelAsINotifyPropertyChanged != null)
{
modelAsINotifyPropertyChanged.PropertyChanged += OnModelPropertyChangedInternal;
}
if (SupportIEditableObject)
{
if (_modelObjectsInfo[modelProperty].SupportIEditableObject)
{
if (model != null)
{
EditableObjectHelper.BeginEditObject(model);
}
}
}
#if (NET || SL5) && !NET35
if (ValidateModelsOnInitialization)
{
var validationResults = new List<System.ComponentModel.DataAnnotations.ValidationResult>();
var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(model, null, null);
System.ComponentModel.DataAnnotations.Validator.TryValidateObject(model, validationContext, validationResults, true);
_modelErrorInfo[modelProperty].InitializeDefaultErrors(validationResults);
}
#endif
InitializeModel(modelProperty, model);
}