终端一体化运控平台
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.
 
 
 

79 line
2.6 KiB

  1. using BPASmartClient.Compiler;
  2. using BPASmartClient.SCADAControl;
  3. using BPASmartClient.SCADAControl.Converters;
  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 BPASmartClient.SCADAControl.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. ResourceDictionary languageResDic = new ResourceDictionary();
  30. languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
  31. this.Resources.MergedDictionaries.Add(languageResDic);
  32. //VerticalContentAlignment = VerticalAlignment.Center;
  33. ItemsString = new ItemsList() { "AA", "BB" };
  34. //Style = Application.Current.Resources["DesignComboBox"] as Style;
  35. Width = 80;
  36. Height = 30;
  37. Focusable = false;
  38. }
  39. public string ControlType => "控件";
  40. public ItemsList ItemsString
  41. {
  42. get { return (ItemsList)GetValue(ItemsStringProperty); }
  43. set { SetValue(ItemsStringProperty, value); }
  44. }
  45. public static readonly DependencyProperty ItemsStringProperty =
  46. DependencyProperty.Register("ItemsString", typeof(ItemsList), typeof(TheComboBox), new PropertyMetadata(null));
  47. private bool isExecuteState;
  48. public bool IsExecuteState
  49. {
  50. get { return isExecuteState; }
  51. set
  52. {
  53. isExecuteState = value;
  54. if (IsExecuteState)
  55. {
  56. Focusable = true;
  57. IsEnabled = true;
  58. Register();
  59. //Style = null;
  60. }
  61. }
  62. }
  63. public void Register()
  64. {
  65. // 运行时进行项目绑定
  66. Binding binding = new Binding();
  67. binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self };
  68. binding.Path = new PropertyPath("ItemsString");
  69. SetBinding(ItemsSourceProperty, binding);
  70. }
  71. }
  72. }