- Should a ViewModel be initialized via constructor, properties, or method call
- public string Name
- {
- get
- {
- if (_customerModel == null) // Check model availability
- {
- return string.Empty;
- }
- _customerModel.Name;
- }
- }
- var viewModel = new MyViewModel();
- this.DataContext = viewModel;
- // Wrap in an async call if necessary
- Task.Factory.StartNew(() => viewModel.InitializeWithAccountNumber(accountNumber));