title: How to validate all fields using WPF MVVM?
body: <p>If I click the Create button, it checks that all fields are empty and validate or not. If anything is missing, it shows a validation message.</p>
  
  <p>View:
  </p>
  
  <pre><code>&lt;ControlTemplate x:Key="validationErrorTemplate"&gt;
      &lt;ControlTemplate.Resources&gt;
          &lt;Style x:Key="textblockErrorTooltip" TargetType="TextBlock"&gt;
              &lt;Setter Property="HorizontalAlignment" Value="Center" /&gt;
              &lt;Setter Property="VerticalAlignment" Value="Center" /&gt;
              &lt;Setter Property="FontWeight" Value="Bold" /&gt;
              &lt;Setter Property="Foreground" Value="White" /&gt;
              &lt;Setter Property="Margin" Value="10 0 10 0" /&gt;
          &lt;/Style&gt;
      &lt;/ControlTemplate.Resources&gt;
      &lt;DockPanel&gt;
          &lt;Border Height="Auto"
              Margin="5,0,0,0"
              Background="#DC000C"
              CornerRadius="3"
              DockPanel.Dock="right"&gt;
              &lt;TextBlock Style="{StaticResource textblockErrorTooltip}" DockPanel.Dock="Top"
                         Text="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" /&gt;
          &lt;/Border&gt;
          &lt;AdornedElementPlaceholder Name="customAdorner"&gt;
              &lt;Border BorderBrush="#DC000C" BorderThickness="1.3" /&gt;
          &lt;/AdornedElementPlaceholder&gt;
      &lt;/DockPanel&gt;
  &lt;/ControlTemplate&gt;     
  
  &lt;TextBlock FontSize="20" Text="UserName"  Name="txtuserName" HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="163" Canvas.Left="426" Canvas.Top="172"/&gt;
  &lt;TextBox MaxLength="10" Name="txtUserName" Validation.ErrorTemplate="{StaticResource validationErrorTemplate}" Text="{Binding MemberModelObj.MemberName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" FontSize="18"  Style="{StaticResource textblockErrorTooltip}" GotFocus="TextUserName_GotFocus" Background="Transparent" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center" Height="24" Width="370" &gt;&lt;/TextBox&gt;
  &lt;TextBlock FontSize="20" Text="FullName" HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="102" Canvas.Left="426" Canvas.Top="241" RenderTransformOrigin="-1.275,0.967"/&gt;
  &lt;TextBox FontSize="18" Validation.ErrorTemplate="{StaticResource validationErrorTemplate}" GotFocus="TextFull_GotFocus"  Background="Transparent" BorderThickness="0" Text="{Binding MemberModelObj.MemberFullName,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" HorizontalAlignment="Left" VerticalAlignment="Center" Height="24" Width="367" Name="txtFirstName" /&gt;
  </code></pre>
  
  <p>I'm using <code>IDataErrorInfo</code> interface in Model Class.</p>
  
  <p>Model:
  </p>
  
  <pre><code>public string this[string columnName]
  {
      set { columnName = value; }
      get
      {
          switch (columnName)
          {
              case "MemberName":
                  if (String.IsNullOrEmpty(MemberName))
                  {
                      result = "! Please Enter a User Name";
                  }
                  else if (MemberName.Length &gt;= 30)
                  {
                      result = "! Name can not be longer than 30 characters.";
                  }
                  break;
          }
          return result;
      }
  }
  </code></pre>
  
  <p>It validates only before button click. But I excepted it after the button command or click event.</p>