public AddEditCustomerViewModel() { StatusMessage = string.Empty; ViewHeaderTitle = "Add/Edit Customer"; CancelCommand = new MyFirstRelayCommand(OnCancel); SaveCommand = new MyFirstRelayCommand(OnSave, CanSave); }
public AttachedPropertiesExampleViewModel() { ViewHeaderTitle = "Attached Properties Example"; DeleteCommand = new MyFirstRelayCommand(OnDeleteClicked, IsDeleteEnabled); // so with the MyMvvmBehaviors that we defined in the View, we dont have to call the load method here it will be called using Attached Properties // in class the demo he ran through this using Visual Studio Blend to get it working fully. //LoadCustomers(); }
// previous //public AddEditCustomerDIViewModel() //{ // StatusMessage = string.Empty; // ViewHeaderTitle = "Add/Edit Customer with Dependency Injection"; // CancelCommand = new MyFirstRelayCommand(OnCancel); // SaveCommand = new MyFirstRelayCommand(OnSave, CanSave); //} // here we will add an instance of the customer service and pass it into our constructor // this will allow us to decouple the CustomerServiceJSON to this view model and just use the interface public AddEditCustomerDIViewModel(ICustomerService incomingCustomerService) { _customerService = incomingCustomerService; StatusMessage = string.Empty; ViewHeaderTitle = "Add/Edit Customer with Dependency Injection"; CancelCommand = new MyFirstRelayCommand(OnCancel); SaveCommand = new MyFirstRelayCommand(OnSave, CanSave); }
public CommandsExampleViewModel() { // if we are in design mode just return and do nothing so we dont cause problems if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { return; } ViewHeaderTitle = "Commands Example"; // the .Result property on the task forces it to be syncronous Customers = new ObservableCollection <SimpleCustomer>(_customerService.GetCustomersAsync(true).Result); DeleteCommand = new MyFirstRelayCommand(OnDeleteClicked, IsDeleteEnabled); }
public ParentAndChildViewsExampleViewModel() { // if we are in design mode just return and do nothing so we dont cause problems if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { return; } ViewHeaderTitle = "Parent and Child view example"; PlaceOrderCommand = new MyFirstRelayCommand <SimpleCustomer>(OnPlaceOrder); AddCustomerCommand = new MyFirstRelayCommand(OnAddCustomer); EditCustomerCommand = new MyFirstRelayCommand <SimpleCustomer>(OnEditCustomer); DeleteCustomerCommand = new MyFirstRelayCommand <SimpleCustomer>(OnDeleteCustomer); }
// previous //public DependencyInjectionExampleViewModel() //{ // // if we are in design mode just return and do nothing so we dont cause problems // if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) // { // return; // } // ViewHeaderTitle = "Dependency Injection Example"; // PlaceOrderCommand = new MyFirstRelayCommand<SimpleCustomer>(OnPlaceOrder); // AddCustomerCommand = new MyFirstRelayCommand(OnAddCustomer); // EditCustomerCommand = new MyFirstRelayCommand<SimpleCustomer>(OnEditCustomer); // DeleteCustomerCommand = new MyFirstRelayCommand<SimpleCustomer>(OnDeleteCustomer); //} // here we will add an instance of the customer service and pass it into our constructor // this will allow us to decouple the CustomerServiceJSON to this view model and just use the interface public DependencyInjectionExampleViewModel(ICustomerService _incomingCustomerService) { if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { return; } _customerService = _incomingCustomerService; ViewHeaderTitle = "Dependency Injection Example"; PlaceOrderCommand = new MyFirstRelayCommand <SimpleCustomer>(OnPlaceOrder); AddCustomerCommand = new MyFirstRelayCommand(OnAddCustomer); EditCustomerCommand = new MyFirstRelayCommand <SimpleCustomer>(OnEditCustomer); DeleteCustomerCommand = new MyFirstRelayCommand <SimpleCustomer>(OnDeleteCustomer); ClearSearchCommand = new MyFirstRelayCommand(OnClearSearch); }
public MainWindowViewModel() { //CurrentViewModel = _initialViewModel; NavigationCommand = new MyFirstRelayCommand <string>(OnNavigationClicked); _dependencyInjectionExampleViewModel = ContainerHelpers.Container.Resolve <DependencyInjectionExampleViewModel>(); _addEditCustomerDIViewModel = ContainerHelpers.Container.Resolve <AddEditCustomerDIViewModel>(); _parentAndChildViewsExampleViewModel.PlaceOrderRequested += NavigateToOrder; _parentAndChildViewsExampleViewModel.AddCustomerRequested += NavigateToAddCustomer; _parentAndChildViewsExampleViewModel.EditCustomerRequested += NavigateToEditCustomer; _dependencyInjectionExampleViewModel.PlaceOrderRequested += NavigateToOrder; _dependencyInjectionExampleViewModel.AddCustomerRequested += NavigateToAddCustomerDI; _dependencyInjectionExampleViewModel.EditCustomerRequested += NavigateToEditCustomerDI; _addEditCustomerViewModel.Done += NavigateToCustomerList; _addEditCustomerDIViewModel.Done += NavigateToCustomerListDI; }
public PropertyChangeNotificationsExampleViewModel() { DeleteCommand = new MyFirstRelayCommand(OnDeleteClicked, IsDeleteEnabled); ChangeCustomerCommand = new MyFirstRelayCommand(OnCustomerChangedClicked); }