Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 4  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Should a ViewModel be initialized via constructor, properties, or method call
  2. public string Name
  3. {
  4.     get
  5.     {  
  6.         if (_customerModel == null) // Check model availability
  7.         {
  8.             return string.Empty;
  9.         }
  10.  
  11.         _customerModel.Name;
  12.     }
  13. }
  14.        
  15. var viewModel = new MyViewModel();
  16. this.DataContext = viewModel;
  17. // Wrap in an async call if necessary
  18. Task.Factory.StartNew(() => viewModel.InitializeWithAccountNumber(accountNumber));