I am after how I could get the string from the IDataErrorInfo.this[string propertyName] method from my ViewModel.
basically, I have created a new property inside the model so I could validate each row in the model collection, and on my vaildation check, I will say if its valid or not and if not, it will disable the command in my viewmodel
Model
string IDataErrorInfo.this[string propertyName]
{
get
{
// Vaildation logic
if (result != string.Empty)
{
IsValid = false;
}
else
{
IsValid = true;
}
return result;
}
ViewModel
public bool CanSave
{
get
{
if (m_ProductVersion != null && m_ProductVersion.ProductItems != null)
{
foreach (ProductItem item in m_ProductVersion.ProductItems)
{
// I dont want to use isValid any more
if (!item.IsValid)
return false;
}
}
return true;
}
}
But I would like to get rid of the isValid Property if I can and use the result from the IDataErrorInfo inside the viewmodel.
Can this be done?
Thanks