title: error handling in WPF-MVVM / disabled button
body: <p>I have problem with error handling in view. I use caliburn.micro and MEF.</p>
  
  <p>My VM look like this:</p>
  
  <pre><code>[Export(typeof(IShellViewModel))]
  public class ShellViewModel : PropertyChangedBase, IShellViewModel,IDataErrorInfo
  {
  
      #region Private members
  
      private User _user;
      private Dictionary&lt;string, bool&gt; _validProperties;
      private bool _allPropertiesValid;
  
      #endregion
  
      #region Private methods
  
      private void ValidateProperties()
      {
          if (_validProperties.Values.Any(isValid =&gt; !isValid))
          {
              AllPropertiesValid = false;
              return;
          }
          AllPropertiesValid = true;
      }
      #endregion
  
      #region Constructor
  
      public ShellViewModel()
      {
          _user = new User();
          _validProperties = new Dictionary&lt;string, bool&gt; {{"Nick", false}, {"Password", false}};
      }
  
      #endregion
  
      #region Properties
  
      public bool AllPropertiesValid
      {
          get { return _allPropertiesValid; }
          set
          {
              if (_allPropertiesValid != value)
              {
                  _allPropertiesValid = value;
                  NotifyOfPropertyChange("AllPropertiesValid");
              }
          }
      }
  
      #endregion
  
      #region Implementation of IShellViewModel
  
      public string Nick
      {
          get { return _user.Nick; }
          set
          {
              _user.Nick = value;
              NotifyOfPropertyChange("Nick");
          }
      }
  
      public string Password
      {
          get { return _user.Password; }
          set
          {
              _user.Password = value;
              NotifyOfPropertyChange("Password");
          }
      }
  
      public void EmptyLogOn()
      { 
          MessageBox.Show(string.Format("LogOn on server with credential: {0}, {1}", Nick, Password));
      }
  
      public void LogOn(string nick, string password)
      {
  
          MessageBox.Show(string.Format("LogOn on server with credential: {0}, {1}", nick, password));
      }
  
      #endregion
  
      #region Implementation of IDataErrorInfo
  
      public string Error
      {
          get { return (_user as IDataErrorInfo).Error; }
      }
  
      public string this[string propertyName]
      {
          get
          {
              string error = (_user as IDataErrorInfo)[propertyName];
              _validProperties[propertyName] = String.IsNullOrEmpty(error) ? true : false;
              ValidateProperties();
              CommandManager.InvalidateRequerySuggested();
              return error;
          }
      }
  
      #endregion
  }
  </code></pre>
  
  <p>If I have som error I set properties AllPropertiesValid on false. I bind this properties on Button properties IsEnabled.</p>
  
  <p>So in View I have this:</p>
  
  <pre><code>&lt;Button IsEnabled="{Binding AllPropertiesValid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
          Micro:Message.Attach="EmptyLogOn"
          Content="Prihlás ma"
          Width="100" 
          Height="25" 
          VerticalAlignment="Center"
          Grid.Row="2"
          Grid.ColumnSpan="2"&gt;&lt;/Button&gt;
  &lt;Label Content="{Binding AllPropertiesValid}" Grid.Row="3"/&gt;
  </code></pre>
  
  <p>But if properties AllPropertiesValid is false Button is still enabled. I check the value of AllPropertiesValid (I bind this properties on label and label content is false) is false.</p>
  
  <p>What’s wrong ? Thank for advance.</p>
  
  <p>EDIT: In designer is button disabled, but when is loaded window button is enable.</p>