public searchCustomer(searchCustomerTypeEnum displayType) { InitializeComponent(); dataContext = new searchCustomer_ModelView(displayType); this.DataContext = dataContext; dataContext.NewCustomerRequested += (s, a) => { newCustomerUC = new NewCustomerUC(displayType); newCustomerWindow = new Window() { Title = "Új ügyfél", Content = newCustomerUC, SizeToContent = SizeToContent.WidthAndHeight }; newCustomerVM = newCustomerUC.DataContext as NewCustomer_ViewModel; newCustomerVM.CustomerInserted += (so, ar) => { dataContext.selectedCustomer = (CustomerBaseRepresentation)so; dataContext.OnCustomerSelected(EventArgs.Empty); newCustomerWindow.Close(); }; newCustomerWindow.Show(); }; DataProxy.Instance.CustomersChanged += (s, a) => { dataContext.RefreshCustomerList(); }; }
public searchCustomer_ModelView(searchCustomerTypeEnum controlType) { if (!this.IsInDesignMode) { _searchText = ""; searchCustomerType = controlType; switch (controlType) { case searchCustomerTypeEnum.Customer: filterType = FilterTypeEnum.All; break; case searchCustomerTypeEnum.Contact: filterType = FilterTypeEnum.Person; break; default: break; } IsBusy = false; RefreshCustomerList(); DataProxy.Instance.CustomersChanged += (s, a) => { RefreshCustomerList(); }; } }
public NewCustomer_ViewModel(searchCustomerTypeEnum displayType) { if (!this.IsInDesignMode) { isPerson = true; _type = displayType; } }
public NewCustomerUC(searchCustomerTypeEnum displayType) { InitializeComponent(); viewModel = new NewCustomer_ViewModel(displayType); DataContext = viewModel; viewModel.CityRequested += (s, a) => { cityChooserWindow = new SearchCity(); cityChooserVM = cityChooserWindow.DataContext as SearchCity_ViewModel; cityChooserVM.citySelected += (so, ar) => { viewModel.newCustomer.city = (CityRepresentation)so; cityChooserWindow.Close(); }; cityChooserWindow.Show(); }; }