using BPASmartClient.Compiler; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing.Design; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; namespace BPASmartClient.SCADAControl.CustomerControls { /// /// TheWuLiaoControl.xaml 的交互逻辑 /// public partial class TheWuLiaoControl : UserControl, IExecutable, IDisposable { public TheWuLiaoControl() { InitializeComponent(); vs.Add(new shujuModel { name = "", dataModel = new ObservableCollection { "", "" } }); vs.Add(new shujuModel { name = "", dataModel = new ObservableCollection { "", "", "", "" } }); Width = 200; Height = 200; } public string ControlType => "物料仓"; private bool isExecuteState; public bool IsExecuteState { get { return isExecuteState; } set { isExecuteState = value; if (IsExecuteState) { IsEnabled = true; Register(); } } } public event EventHandler PropertyChange; //声明一个事件 /// /// 数据模板 /// private ObservableCollection vs { get { return (ObservableCollection)GetValue(vsProperty); } set { SetValue(vsProperty, value); } } private static readonly DependencyProperty vsProperty = DependencyProperty.Register("vs", typeof(ObservableCollection), typeof(TheWuLiaoControl), new PropertyMetadata(new ObservableCollection())); /// /// 数据模板 /// private Dictionary DataModel { get { return (Dictionary)GetValue(DataModelProperty); } set { SetValue(DataModelProperty, value); } } private static readonly DependencyProperty DataModelProperty = DependencyProperty.Register("DataModel", typeof(Dictionary), typeof(TheWuLiaoControl), new PropertyMetadata(new Dictionary())); public void Register() { Class_DataBus.GetInstance().BindingAction += BindingActionHeader; } public void BindingActionHeader(object sender, EventArgs e) { this.Dispatcher.Invoke((Action)(() => { DataModel = Class_DataBus.GetInstance().Dic_RedisDataBinding; PropertyChange?.Invoke(this, EventArgs.Empty); })); } public void Dispose() { } } public class shujuModel { public string name { get; set; } public ObservableCollection dataModel { get; set; } } }