public TillView(TillModel tillModel, ObservableCollection<TillDivisionModel> tillDivisions) { InitializeComponent(); DataContext = _viewModel = new TillViewModel(tillModel, tillDivisions); _viewModel.PropertyChanged += ViewModelOnPropertyChanged; Unloaded += TillView_Unloaded; }
private void AddTill() { var tillModel = new TillModel(new Till() { ID = Guid.NewGuid() }); tillModel.PropertyChanged += OnTillPropertyChanged; Till = tillModel; }
public async void RefreshTills(TillModel _till) { var tillDivisions = await _adminDataUnit.TillDivisionsRepository.GetAllAsync(); TillDivisions = new ObservableCollection<TillDivisionModel>(tillDivisions.Select(x => new TillDivisionModel(x))); if (_till != null) { var selectedTillDivision = TillDivisions.FirstOrDefault(tillDiv => tillDiv.TillDivision.ID == _till.TillDivision.ID); if (selectedTillDivision != null) { var selectedTill = selectedTillDivision.Tills.FirstOrDefault(till => till.Till.ID == _till.Till.ID); if (selectedTill != null) { SelectedTreeViewObject = selectedTill; TillDivisions.ForEach(tilldivision => { tilldivision.IsExpanded = false; }); selectedTillDivision.IsExpanded = true; } } } }