void modifyCommand(object obj) { UIClassHourRule rule = obj as UIClassHourRule; CreateSameStarting createWin = new CreateSameStarting(Models.Enums.OperatorEnum.Modify, this.GetCurrentRuleEnum(), rule); createWin.Closed += (s, arg) => { var modify = createWin.Modify; if (createWin.DialogResult.Value) { rule.IsActive = modify.IsActive; rule.Weight = modify.Weight; rule.ClassHours = modify.ClassHours; rule.RaiseChanged(); } }; createWin.ShowDialog(); }
void createCommand() { CreateSameStarting createWin = new CreateSameStarting(Models.Enums.OperatorEnum.Add, this.GetCurrentRuleEnum()); createWin.Closed += (s, arg) => { if (createWin.DialogResult.Value) { // 1.向UI中插入 var last = this.Rules.LastOrDefault(); var index = last == null ? 0 : Convert.ToInt32(last.NO); // 2.创建对象 createWin.Add.NO = index + 1; // 3.更新界面 this.Rules.Add(createWin.Add); } }; createWin.ShowDialog(); }