title: Validate with button using caliburn micro and fluent Validation
body: <p>I would like to show validation upon a button event using caliburn micro and FluentValidation. The validations rules  are currently show as expected but I am unable to hide them until I click a button. Fairly new to Wpf so please be easy. I have tried to bind ValidatesOnDataErrors but am unable to. Furthermore I have tried to hide my ControlTemplate that shows the errors</p>
  <p>My View</p>
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;BooleanToVisibilityConverter x:Key=&quot;booleanVisibilityConverter&quot;/&gt;
  &lt;/UserControl.Resources&gt;
  
  &lt;Canvas FocusManager.FocusedElement=&quot;{Binding ElementName=box}&quot;&gt;
      &lt;!-- Sets the focus to start with textbox--&gt;
      &lt;Button x:Name=&quot;ValidateText&quot; Content=&quot;Validate&quot; Canvas.Left=&quot;234&quot; Canvas.Top=&quot;265&quot; Width=&quot;301&quot; Height=&quot;29&quot; /&gt;
  
      &lt;TextBox  Height=&quot;23&quot; Canvas.Left=&quot;205&quot; TextWrapping=&quot;Wrap&quot; Text=&quot;{Binding Name, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}&quot; 
                Canvas.Top=&quot;187&quot; Width=&quot;330&quot; TabIndex=&quot;0&quot; x:Name=&quot;box&quot; &gt;
          &lt;Validation.ErrorTemplate &gt;
              &lt;ControlTemplate &gt;
                  &lt;StackPanel Orientation=&quot;Horizontal&quot; &gt;
                      &lt;!-- Placeholder for the TextBox itself --&gt;
                      &lt;AdornedElementPlaceholder x:Name=&quot;textBox&quot; /&gt;
                      &lt;TextBlock Margin=&quot;10&quot; Text=&quot;{Binding [0].ErrorContent}&quot; Foreground=&quot;Red&quot;  /&gt;
                  &lt;/StackPanel&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Validation.ErrorTemplate&gt;
      &lt;/TextBox&gt;
  &lt;/Canvas&gt;
  </code></pre>
  <p>Validation:</p>
  <pre><code> public class UserValidator : AbstractValidator&lt;TestViewModel&gt;
      {
          public UserValidator()
          {
              RuleFor(x =&gt; x.Name)
                  .NotEmpty()
                  .WithMessage(&quot;No name entered&quot;);
          }
      }
  </code></pre>
  <p>ViewModel:</p>
  <pre><code>    public class TestViewModel : Screen, IDataErrorInfo
  
      {
          public bool Hello { get; set; } = false;
  
          private readonly UserValidator _userValidator;
          private bool _showHideError = false;
  
          public bool ShowHideError
          {
              get { return _showHideError; }
              set { _showHideError = value;
                  NotifyOfPropertyChange(() =&gt; ShowHideError);
              }
          }
  
          public TestViewModel()
          {
              _userValidator = new UserValidator();
          }
  
          public string Name { get; set; }
          private string _lastName;
  
          public string LastName
          {
              get { return _lastName; }
              set
              {
                  _lastName = value;
                  NotifyOfPropertyChange(() =&gt; LastName);
              }
          }
  
          public string this[string columnName]
          {
              get
              {
                  var firstOrDefault = _userValidator.Validate(this).Errors.FirstOrDefault(lol =&gt; lol.PropertyName == columnName);
                  if (firstOrDefault != null)
                      return _userValidator != null ? firstOrDefault.ErrorMessage : &quot;&quot;;
                  return &quot;&quot;;
              }
          }
          public string Error
          {
              get
              {
                  if (_userValidator != null)
                  {
                      FluentValidation.Results.ValidationResult results = _userValidator.Validate(this);
                      if (results != null &amp;&amp; results.Errors.Any())
                      {
                          string errors = string.Join(Environment.NewLine, results.Errors.Select(x =&gt; x.ErrorMessage).ToArray());
                          return errors;
                      }
                  }
                  return string.Empty;
              }
          }
          public void ValidateText()
          {
              //Display Error on View when this is fired
          }
      }
  }
  </code></pre>