title: INotifyDataErrorInfo reusable methods
body: <p>I am using MVVM-Light and for every view model I have to create an implementation of the INotifyDataErrorInfo which in some cases uses same methods to validate same property types.
  In this example I am using DateTime:</p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using SL.Resources;
  
      namespace SL.ViewModel
      {
          public partial class AdministrationViewModel : INotifyDataErrorInfo
          {
              #region Validations
  
          public void isDateToValid(DateTime? value, DateTime? dateFrom, string propertyName)
          {
              //check if null
              if (value == null) AddError(propertyName, CommonErrors.DateNull_ERROR, false);
              else RemoveError(propertyName, CommonErrors.DateNull_ERROR);
  
              //check if min and max value
              if (value &lt; DateTime.MinValue || value &gt; DateTime.MaxValue) AddError(propertyName, CommonErrors.DateNotValid_ERROR, false);
              else RemoveError(propertyName, CommonErrors.DateNotValid_ERROR);
  
              if (value &lt; dateFrom) AddError(propertyName, CommonErrors.DateFromSmall_ERROR, false);
              else RemoveError(propertyName, CommonErrors.DateFromSmall_ERROR);
          }
  
          public void IsDateValid(DateTime? value, string propertyName)
          {
              if (value == null) AddError(propertyName, CommonErrors.DateNull_ERROR, false);
              else RemoveError(propertyName, CommonErrors.DateNull_ERROR);
  
              if (value &lt; DateTime.MinValue || value &gt; DateTime.MaxValue) AddError(propertyName, CommonErrors.DateNotValid_ERROR, false);
              else RemoveError(propertyName, CommonErrors.DateNotValid_ERROR);
          }
  
          #endregion
  
          #region INotifyDataErrorInfo Members
  
          public Dictionary&lt;string, List&lt;string&gt;&gt; errors = new Dictionary&lt;string, List&lt;string&gt;&gt;();
  
          // Adds the specified error to the errors collection if it is not 
          // already present, inserting it in the first position if isWarning is 
          // false. Raises the ErrorsChanged event if the collection changes. 
          public void AddError(string propertyName, string error, bool isWarning)
          {
              if (!errors.ContainsKey(propertyName))
                  errors[propertyName] = new List&lt;string&gt;();
  
              if (!errors[propertyName].Contains(error))
              {
                  if (isWarning) errors[propertyName].Add(error);
                  else errors[propertyName].Insert(0, error);
                  RaiseErrorsChanged(propertyName);
              }
          }
  
          // Removes the specified error from the errors collection if it is
          // present. Raises the ErrorsChanged event if the collection changes.
          public void RemoveError(string propertyName, string error)
          {
              if (errors.ContainsKey(propertyName) &amp;&amp;
                  errors[propertyName].Contains(error))
              {
                  errors[propertyName].Remove(error);
                  if (errors[propertyName].Count == 0) errors.Remove(propertyName);
                  RaiseErrorsChanged(propertyName);
              }
          }
  
          public void RaiseErrorsChanged(string propertyName)
          {
              if (ErrorsChanged != null)
                  ErrorsChanged(this, new DataErrorsChangedEventArgs(propertyName));
          }
  
          public event System.EventHandler&lt;DataErrorsChangedEventArgs&gt; ErrorsChanged;
  
          public System.Collections.IEnumerable GetErrors(string propertyName)
          {
              if (string.IsNullOrEmpty(propertyName) ||
                  !errors.ContainsKey(propertyName)) return null;
              return errors[propertyName];
          }
  
          public bool HasErrors
          {
              get { return errors.Count &gt; 0; }
          }
  
          #endregion
      }
  }
  </code></pre>
  
  <p><strong>How could I make this code reusable in other view models, so I don't have to implement the same thing over and over again?</strong></p>
  
  <p>I created a class that implements INotifyDataErrorInfo :</p>
  
  <pre><code>public class ViewModelValidation : INotifyDataErrorInfo
  </code></pre>
  
  <p>But when I want to use it in my view model it doesn't work:</p>
  
  <pre><code>public partial class AdministrationViewModel : ViewModelValidation
  </code></pre>
  
  <p>Error: </p>
  
  <pre><code>Partial declarations of 'SL.ViewModel.AdministrationViewModel' must not specify different base classes...
  </code></pre>
  
  <p>this is because in my main view model file I have a base class from MVVM-Light:</p>
  
  <pre><code>public partial class AdministrationViewModel : ViewModelBase
  </code></pre>
  
  <p>Any help resolving this is appretiated.</p>