title: validating model in silverlight MVVM
body: <p>how to validate in model in silverlight? 
  The code sample what Im trying to achieve  is shown below..</p>
  
  <pre><code> &lt;Grid x:Name="AddnewGrid" Margin="2" DataContext="{Binding SaveUpdateEmp, Mode=TwoWay"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="125"&gt;&lt;/ColumnDefinition&gt;
              &lt;ColumnDefinition Width="10"&gt;&lt;/ColumnDefinition&gt;
              &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;TextBlock x:Name="EmployeeCode" Text="EmployeeCode" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBlock x:Name="EmployeeCodeSprtr" Text=":" FontSize="14" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBox x:Name="txtEmployeeCode" Text="{Binding EmployeeCode, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"&gt;&lt;/TextBox&gt;
  
          &lt;TextBlock x:Name="EmployeeName" Text="Employee Name" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBlock x:Name="EmployeeNameSprtr" Text=":" FontSize="14" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBox x:Name="txtEmployeeName" Text="{Binding EmployeeName, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"&gt;&lt;/TextBox&gt;
  
          &lt;TextBlock x:Name="EmployeePW" Text="PassWord" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBlock x:Name="EmployeePWSprtr" Text=":" FontSize="14" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBox x:Name="txtEmployeePW" Text="{Binding EmployeePW, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"&gt;&lt;/TextBox&gt;
  
          &lt;TextBlock x:Name="EmployeeDesg" Text="Designation" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBlock x:Name="EmployeeDesgSprtr" Text=":" FontSize="14" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBox x:Name="txtEmployeeDesg" Grid.Row="3" Text="{Binding EmployeeDesg, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"&gt;&lt;/TextBox&gt;
  
          &lt;TextBlock x:Name="DepartmentId" Text="DepartmentID" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBlock x:Name="DepartmentIdSprtr" Text=":" FontSize="14" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBox x:Name="txtDepartmentId" Grid.Row="4" Text="{Binding DepartmentId, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"&gt;&lt;/TextBox&gt;
  
          &lt;TextBlock x:Name="DepartmentName" Text="Department" FontSize="14" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBlock x:Name="DepartmentNameSprtr" Text=":" FontSize="14" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"&gt;&lt;/TextBlock&gt;
          &lt;TextBox x:Name="txtDepartmentName" Grid.Row="5" Text="{Binding DepartmentName, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="2" VerticalAlignment="Center" Width="150" HorizontalAlignment="Left"&gt;&lt;/TextBox&gt;
  
          &lt;Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Grid.Row="6" Grid.Column="2"  Width="75" Height="23" HorizontalAlignment="Left" /&gt;
          &lt;Button x:Name="OKButton" Content="Save" Click="OKButton_Click" Grid.Row="6" Grid.Column="0" Width="75" Height="23" HorizontalAlignment="Left" /&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>Here the SaveUpdateEmp is object of propertyclass in model. How to validate these fields.??</p>