ListDialogViewModel.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using OpenSEMI.ClientBase;
  2. using System.Collections.ObjectModel;
  3. using System.Windows.Controls;
  4. namespace MECF.Framework.UI.Client.CenterViews.Dialogs
  5. {
  6. public class ListDialogViewModel:DialogViewModel<string>
  7. {
  8. private string _CurrentValue;
  9. public ObservableCollection<string> Items { get; set; }
  10. public string HeaderText
  11. {
  12. get { return "Permission Select"; }
  13. }
  14. public ListDialogViewModel()
  15. {
  16. Items = new ObservableCollection<string>();
  17. }
  18. public void SelectChanged(object item)
  19. {
  20. _CurrentValue = item.ToString();
  21. }
  22. public void DoubleClick(object item)
  23. {
  24. _CurrentValue = item.ToString();
  25. OK();
  26. }
  27. public void OK()
  28. {
  29. if (!string.IsNullOrEmpty(_CurrentValue))
  30. {
  31. this.DialogResult = _CurrentValue;
  32. IsCancel = false;
  33. TryClose(true);
  34. }
  35. }
  36. public void Cancel()
  37. {
  38. IsCancel = true;
  39. TryClose(false);
  40. }
  41. }
  42. }