title: Disable Save button in WPF if validation fails
body: <p>I've adopted what appears to be the standard way of validating textboxes in WPF using the IDataErrorInfo interface and styles as shown below. However, how can I disable the Save button when the page becomes invalid? Is this done somehow through triggers?</p>
  
  <pre><code>Default Public ReadOnly Property Item(ByVal propertyName As String) As String Implements IDataErrorInfo.Item
      Get
          Dim valid As Boolean = True
          If propertyName = "IncidentCategory" Then
              valid = True
              If Len(IncidentCategory) = 0 Then
                  valid = False
              End If
              If Not valid Then
                  Return "Incident category is required"
              End If
          End If
  
          Return Nothing
  
      End Get
  End Property
  </code></pre>
  
  <p>
          
          
          
          
          
          
          
      </p>
  
  <pre><code>&lt;Style TargetType="{x:Type TextBox}"&gt;
      &lt;Setter Property="Margin" Value="3" /&gt;
      &lt;Setter Property="Height" Value="23" /&gt;
      &lt;Setter Property="HorizontalAlignment" Value="Left" /&gt;
      &lt;Setter Property="Validation.ErrorTemplate"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate&gt;
                  &lt;DockPanel LastChildFill="True"&gt;
                      &lt;Border BorderBrush="Red" BorderThickness="1"&gt;
                          &lt;AdornedElementPlaceholder Name="MyAdorner" /&gt;
                      &lt;/Border&gt;
                  &lt;/DockPanel&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="Validation.HasError" Value="true"&gt;
              &lt;Setter Property="ToolTip"  Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" /&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>