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 system architect and principal in PH&V Information Services. PH&V provides full-stack consulting from UX design through object modeling to database design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His blog posts on user experience design can be found at http://blog.learningtree.com/tag/ui/.

comments powered by Disqus

Featured

Subscribe on YouTube