终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

76 lines
2.3 KiB

  1. using BeDesignerSCADA.Speical;
  2. using BPASmartClient.Compiler;
  3. using BPASmartClient.SCADAControl;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. namespace BeDesignerSCADA.CustomerControls
  19. {
  20. /// <summary>
  21. /// TheComboBox.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class TheComboBox : ComboBox, IExecutable
  24. {
  25. public event EventHandler PropertyChange; //声明一个事件
  26. public TheComboBox()
  27. {
  28. InitializeComponent();
  29. VerticalContentAlignment = VerticalAlignment.Center;
  30. ItemsString = new ItemsList() { "AA", "BB" };
  31. Style = Application.Current.Resources["DesignComboBox"] as Style;
  32. Width = 80;
  33. Height = 30;
  34. Focusable = false;
  35. }
  36. public string ControlType => "控件";
  37. public ItemsList ItemsString
  38. {
  39. get { return (ItemsList)GetValue(ItemsStringProperty); }
  40. set { SetValue(ItemsStringProperty, value); }
  41. }
  42. public static readonly DependencyProperty ItemsStringProperty =
  43. DependencyProperty.Register("ItemsString", typeof(ItemsList), typeof(TheComboBox), new PropertyMetadata(null));
  44. private bool isExecuteState;
  45. public bool IsExecuteState
  46. {
  47. get { return isExecuteState; }
  48. set
  49. {
  50. isExecuteState = value;
  51. if (IsExecuteState)
  52. {
  53. Focusable = true;
  54. IsEnabled = true;
  55. Register();
  56. Style = null;
  57. }
  58. }
  59. }
  60. public void Register()
  61. {
  62. // 运行时进行项目绑定
  63. Binding binding = new Binding();
  64. binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self };
  65. binding.Path = new PropertyPath("ItemsString");
  66. SetBinding(ItemsSourceProperty, binding);
  67. }
  68. }
  69. }