Creating Modularity with WPF, Prism and Unity: Listing 3.

Error reporting in the Customers list.

private Dictionary<String, String> errors = 
          new Dictionary<String, String>();
        
public void GetCustomers() 
{
  try
  {
    ObservableCollection<Customer> custs = 
      new ObservableCollection<Customer>();
    // Build collection of Customers
    this.Customers = dummyCusts;
  }
  catch (Exception ex)
  {
    if (errors.ContainsKey("Customers"))
    {
      errors.Remove("Customers");
    }
    errors.Add("Customers", ex.Message);
  }
}

public string Error
{
  get { return errors["Customers"]; }
}

public string this[string columnName]
{
  get
  {
    if (errors.ContainsKey(columnName))
    {
      return errors[columnName];
    }
    else
    {
      return null;
    }
  }
}

About the Author

Peter Vogel is a principal in PH&V Information Services, specializing in ASP.NET development with expertise in SOA, XML, database, and user interface design. His most recent book ("rtfm*") is on writing effective user manuals, and his blog on technical writing can be found at rtfmphvis.blogspot.com.