private void Create_Button_Click(object sender, RoutedEventArgs e) { creating = true; CategoryEditor ce_win = new CategoryEditor(); ce_win.Closing += (s, e) => { string name = null; string formats = null; List <ClassForList> List = new List <ClassForList> { }; foreach (CategoryClass category in CategoryList) { foreach (string format in category.Formats) { formats += $"{format}; "; } name = category.Name; ClassForList Cate = new ClassForList(name, formats); List.Add(Cate); name = null; formats = null; } CateList.ItemsSource = List; }; ce_win.ShowDialog(); }
private void Edit() { if (CateList.SelectedItem != null) { creating = false; ClassForList SelectedCate = (ClassForList)CateList.SelectedItem; foreach (CategoryClass Cate in CategoryList) { if (Cate.Name == SelectedCate.Name) { indexIn = CategoryList.IndexOf(Cate); } } CategoryEditor ce_win = new CategoryEditor(); ce_win.Closing += (s, e) => { string name = null; string formats = null; List <ClassForList> List = new List <ClassForList> { }; foreach (CategoryClass category in CategoryList) { foreach (string format in category.Formats) { name = category.Name; formats += $" {format};"; } ClassForList Cate = new ClassForList(name, formats); List.Add(Cate); formats = ""; name = ""; } CateList.ItemsSource = List; }; ce_win.ShowDialog(); } }