private void Create() { Chamber edititem = new Chamber(); //实例化一个新的model ChamberEditViewModel evm = new ChamberEditViewModel(edititem); //实例化一个新的view model evm.DisplayName = "Chamber-Create"; evm.commandType = CommandType.Create; var ChamberViewInstance = new ChamberView(); //实例化一个新的view ChamberViewInstance.DataContext = evm; ChamberViewInstance.ShowDialog(); //设置viewmodel属性 if (evm.IsOK == true) { _chamberService.SuperAdd(edititem); } }
private void SaveAs() { Chamber m = new Chamber(); //实例化一个新的model ChamberEditViewModel evm = new ChamberEditViewModel(m); //实例化一个新的view model evm.Name = _selectedItem.Name; evm.Manufacturer = _selectedItem.Manufacturer; evm.LowTemp = _selectedItem.LowTemp; evm.HighTemp = _selectedItem.HighTemp; evm.DisplayName = "Chamber-Save As"; evm.commandType = CommandType.SaveAs; var ChamberViewInstance = new ChamberView(); //实例化一个新的view ChamberViewInstance.DataContext = evm; ChamberViewInstance.ShowDialog(); if (evm.IsOK == true) { _chamberService.SuperAdd(m); } }
private void Edit() { Chamber edititem = new Chamber(); //实例化一个新的model ChamberEditViewModel evm = new ChamberEditViewModel(edititem); //实例化一个新的view model evm.Id = SelectedItem.Id; evm.Name = _selectedItem.Name; evm.Manufacturer = _selectedItem.Manufacturer; evm.LowTemp = _selectedItem.LowTemp; evm.HighTemp = _selectedItem.HighTemp; evm.DisplayName = "Chamber-Edit"; evm.commandType = CommandType.Edit; var ChamberViewInstance = new ChamberView(); //实例化一个新的view ChamberViewInstance.DataContext = evm; ChamberViewInstance.ShowDialog(); if (evm.IsOK == true) { _chamberService.SuperUpdate(edititem); } }