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