private void AddNew() { var model = new AutoNumber(); model.AutoNumberCatID = -1; model.Category = AutoNumberCategory; model.Name = "<New Autonumber>"; RegisterPendingChange(new InsertAutoNumberCommand(model)); var viewmodel = new AutoNumberViewModel(model); _model.Add(viewmodel); viewmodel.IsSelected = true; lst.SelectedItem = viewmodel; }
private void LoadModel() { var service = new SupportService(User); var list = service.GetAutoNumbersForCategory(AutoNumberCategory); _model = new ObservableCollection <AutoNumberViewModel>(list.ConvertAll((model) => { var viewmodel = new AutoNumberViewModel(model); viewmodel.DataChanged += new DataChangedHandler((m) => { RegisterUniquePendingChange(new UpdateAutoNumberCommand(model)); }); return(viewmodel); })); lst.ItemsSource = _model; gridAutonumber.IsEnabled = false; if (_model.Count > 0) { lst.SelectedItem = _model[0]; } }