private void InitializeBoilerPlate() { List <Data.Boilerplate> allItems = Data.Boilerplate.LoadAll(); BoilerplateAnswers.Clear(); foreach (Data.Boilerplate item in allItems) { BoilerplateAnswers.Add(new BoilerplateAnswer(item, () => { boilerPlateSelected(item); })); } }
public async void UpdateBoilerplate(Data.Boilerplate bp) { BoilerplateEditorViewModel bpdc = (BoilerplateEditorViewModel)_boilerplate_dialog.DataContext; if (!bpdc.Cancel && bpdc.Exception == null) { BoilerplateAnswer bpa = BoilerplateAnswers.FirstOrDefault(item => item.Title.Equals(bp.Title)); if (bpa == null) { BoilerplateAnswers.Add(new BoilerplateAnswer(bp, () => { boilerPlateSelected(bp); })); } else { // this won't update the text in the datagrid though... bpa.Text = bp.Text; bpa.Title = bp.Title; } } if (bpdc.Exception != null) { await _dialogCoordinator.ShowMessageAsync(this, "Add Boilerplate Answer", "Unable to save: " + bpdc.Exception.Message); } }