using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BeDesignerSCADA.Speical { /// /// 因ObservableCollection无法序列化,继承并实例化一个 /// public class ItemsList : ObservableCollection { public ItemsList() { AddCommand = new RelayCommand(AddItem); DeleteCommand = new RelayCommand(DeleteItem); } private void DeleteItem(string obj) { if (!string.IsNullOrEmpty(obj)) Remove(obj); } public RelayCommand AddCommand { get; } public RelayCommand DeleteCommand { get; } private void AddItem(string txt) { if (!string.IsNullOrEmpty(txt)) Add(txt); } } }