title: How to add a close button to ValidationSummary in Silverlight
body: <p>In Silverlight 3 I am working with a MVVM and also the validation principle that the setters cause an exception if a validation error occurs.  I using the Binding Syntax on the fields using TwoWay i.e.:</p>
  
  <pre><code>&lt;TextBox x:Name="TextBoxClientName" Text="{Binding Name,Mode=TwoWay,ValidatesOnExceptions=True,NotifyOnValidationError=true}"  Grid.Column="1" Grid.Row="0" Margin="5 5 5 5" /&gt;
  </code></pre>
  
  <p>I validate this property in the ViewModel using the Annotations:</p>
  
  <pre><code>[Required(ErrorMessage = "Name is required")]
  public string Name
  {
      get
      {
          return _client.Name;
      }
      set
      {
          Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = "Name", DisplayName="Client Name" });
          _client.Name = value;
      }
  }
  </code></pre>
  
  <p>I have the Validation summary and all work well BUT lol, the functionality I am looking for is the following:</p>
  
  <p>You have the Data Form and I want the validation summary to appear over the top ONLY when I click save, and further more I want to implement a close button on that ValidationSummary so the user can continue on with entering and correcting.</p>
  
  <p>I am not sure how to control the visibility or toggle of with the validationsummary, I have tried the Visibility.  The following is code that I tried, WHICH does collect the errors on submit, but I cannot apply them to the validationsummary:</p>
  
  <pre><code>    public void Save()
      {
          List&lt;ValidationError&gt; errors = new List&lt;ValidationError&gt;();
  
          foreach (UIElement ui in LayoutRoot.Children)
          {
              FrameworkElement fe = ui as FrameworkElement;
  
              if (fe != null)
              {
                  foreach (ValidationError ve in Validation.GetErrors(fe))
                  {
                      errors.Add(ve);
                  }
              }
          }
  
  
          if (errors.Count &gt; 0)
          {
  
              Validation1.DataContext = errors;
              Validation1.Filter = ValidationSummaryFilters.All;
          }
          else
          {
              if (Saved != null)
                  Saved(this, EventArgs.Empty);
          }
  
      }
  </code></pre>
  
  <p>Cheers,</p>
  
  <p>Andrew</p>