protected void ShowTemplateEditWindow(TowerTemplateStorageInfo templateInfo, bool isReadOnly) { TowerTemplate template = new TowerTemplate(); //templateInfo 不是null,需要从project中读取模板 if (templateInfo != null) { var proInstance = ProjectUtils.GetInstance(); string path = isReadOnly ? proInstance.GetGeneralTowerTemplatePath(templateInfo.Name, templateInfo.TowerType) : proInstance.GetProjectlTowerTemplatePath(templateInfo.Name, templateInfo.TowerType); NewTowerTemplateReader newTemplateReader = new NewTowerTemplateReader(TowerTypeStringConvert.TowerStringToType(templateInfo.TowerType)); template = newTemplateReader.Read(path); } StruTemplateEditViewModel model = ViewModelSource.Create(() => new StruTemplateEditViewModel(template, isReadOnly)); model.CloseEditTemplateWindowEvent += CloseTemplateEditWindow; editWindow = new StruTemplateEditWindow(); editWindow.DataContext = model; editWindow.ShowDialog(); }