|
12345678910111213141516171819202122232425262728293031323334353637 |
- 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
- {
- /// <summary>
- /// 因ObservableCollection无法序列化,继承并实例化一个
- /// </summary>
- public class ItemsList : ObservableCollection<string>
- {
- public ItemsList()
- {
- AddCommand = new RelayCommand<string>(AddItem);
- DeleteCommand = new RelayCommand<string>(DeleteItem);
- }
-
- private void DeleteItem(string obj)
- {
- if (!string.IsNullOrEmpty(obj))
- Remove(obj);
- }
-
- public RelayCommand<string> AddCommand { get; }
- public RelayCommand<string> DeleteCommand { get; }
- private void AddItem(string txt)
- {
- if (!string.IsNullOrEmpty(txt))
- Add(txt);
- }
-
- }
- }
|