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 BPASmartClient.SCADAControl.Converters { /// /// 因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); } } public class ItemsListObj:ObservableCollection { public ItemsListObj() { AddCommand = new RelayCommand(AddItem); DeleteCommand = new RelayCommand(DeleteItem); } private void DeleteItem(object obj) { if (obj!=null) Remove(obj); } public RelayCommand AddCommand { get; } public RelayCommand DeleteCommand { get; } private void AddItem(object txt) { if (txt != null) Add(txt); } } }