终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

62 linhas
1.6 KiB

  1. using Microsoft.Toolkit.Mvvm.Input;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace BPASmartClient.SCADAControl.Converters
  9. {
  10. /// <summary>
  11. /// 因ObservableCollection无法序列化,继承并实例化一个
  12. /// </summary>
  13. public class ItemsList : ObservableCollection<string>
  14. {
  15. public ItemsList()
  16. {
  17. AddCommand = new RelayCommand<string>(AddItem);
  18. DeleteCommand = new RelayCommand<string>(DeleteItem);
  19. }
  20. private void DeleteItem(string obj)
  21. {
  22. if (!string.IsNullOrEmpty(obj))
  23. Remove(obj);
  24. }
  25. public RelayCommand<string> AddCommand { get; }
  26. public RelayCommand<string> DeleteCommand { get; }
  27. private void AddItem(string txt)
  28. {
  29. if (!string.IsNullOrEmpty(txt))
  30. Add(txt);
  31. }
  32. }
  33. public class ItemsListObj:ObservableCollection<object>
  34. {
  35. public ItemsListObj()
  36. {
  37. AddCommand = new RelayCommand<object>(AddItem);
  38. DeleteCommand = new RelayCommand<object>(DeleteItem);
  39. }
  40. private void DeleteItem(object obj)
  41. {
  42. if (obj!=null)
  43. Remove(obj);
  44. }
  45. public RelayCommand<object> AddCommand { get; }
  46. public RelayCommand<object> DeleteCommand { get; }
  47. private void AddItem(object txt)
  48. {
  49. if (txt != null)
  50. Add(txt);
  51. }
  52. }
  53. }