title: How to display validation error in button bound to command
body: <p>I am developing an app and trying to stick to an MVVM model, I have a button that is just bound to a command. Currently the command can be enabled / disabled and greys out the button when the command is set to CanExecute false. But I want to add the ability to show validation errors on the button (by changing its color to red, maybe showing a tooltip).</p>
  
  <p>The validation is currently already shown in another location in the UI, but the users are getting annoyed that the button is enabled and they click it only to have a message box pops up telling them they shouldn't of clicked the button because there is a validation error. But just disabling the button completely without showing them why would make the users confused(since they overlook the large red validation error at the bottom of the screen). So how can I show additional information on the save button?</p>
  
  <p>This is my current button xaml:</p>
  
  <pre><code>&lt;Button Name="SaveDataPointButton" Style="{StaticResource ImageButton}" Command="{Binding OpenDataPoint.SaveDataPointEditsCommand}" Margin="5,0" VerticalAlignment="Stretch"&gt;
      &lt;Image Source="save.png" Stretch="None" ToolTip="Save Edits"/&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <p>And the style that is changing its appearance when IsEnabled is false, is it possible to somehow inspect some other command state from the style to make the button red during validation errors?</p>
  
  <pre><code>&lt;!-- Style for all of the nav and save buttons in the datapoints view --&gt;
  &lt;Style x:Key="ImageButton" TargetType="Button"&gt;
      &lt;Setter Property="SnapsToDevicePixels" Value="true"/&gt;
      &lt;Setter Property="OverridesDefaultStyle" Value="true"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="Button"&gt;
                  &lt;Border 
                      x:Name="Border"  
                      BorderThickness="0"&gt;
                      &lt;ContentPresenter 
                          Margin="2"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          RecognizesAccessKey="True"/&gt;
                  &lt;/Border&gt;
                  &lt;ControlTemplate.Triggers&gt;
                      &lt;Trigger Property="IsMouseOver" Value="true"&gt;
                          &lt;Setter TargetName="Border" Property="Background"&gt;
                              &lt;Setter.Value&gt;
                                  &lt;SolidColorBrush Color="LightGray"/&gt;
                              &lt;/Setter.Value&gt;
                          &lt;/Setter&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsPressed" Value="true"&gt;
                          &lt;Setter TargetName="Border" Property="Background"&gt;
                              &lt;Setter.Value&gt;
                                  &lt;SolidColorBrush Color="Gray"/&gt;
                              &lt;/Setter.Value&gt;
                          &lt;/Setter&gt;
                      &lt;/Trigger&gt;
                      &lt;Trigger Property="IsEnabled" Value="false"&gt;
                          &lt;Setter Property="Opacity" Value="0.3"/&gt;
                      &lt;/Trigger&gt;
                  &lt;/ControlTemplate.Triggers&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="Command" Value="{x:Null}"&gt;
              &lt;Setter Property="IsEnabled" Value="False"/&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>