using BPASmartClient.Compiler; using BPASmartClient.MessageName.接收消息Model.物料仓; using BPASmartClient.SCADAControl.Converters; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; 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.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace BPASmartClient.SCADAControl.CustomerControls { /// /// TheListBox.xaml 的交互逻辑 /// public partial class TheListBox :ListBox, IExecutable { public event EventHandler PropertyChange; //声明一个事件 public TheListBox() { InitializeComponent(); ResourceDictionary languageResDic = new ResourceDictionary(); languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute); this.Resources.MergedDictionaries.Add(languageResDic); //Style = Application.Current.Resources["DesignTheListBox"] as Style; MinWidth = 100; MinHeight = 100; //ItemsString = new ItemsListObj() //{ // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, // new datalist { Name="23232",Description="wwewewew",Messgae="564654645"}, //}; } public ItemsListObj ItemsString { get { return (ItemsListObj)GetValue(ItemsStringProperty); } set { SetValue(ItemsStringProperty,value); } } public static readonly DependencyProperty ItemsStringProperty = DependencyProperty.Register("ItemsString",typeof(ItemsListObj),typeof(TheListBox),new PropertyMetadata(null)); public string ControlType => "控件"; private bool isExecuteState; public bool IsExecuteState { get { return isExecuteState; } set { isExecuteState = value; if (IsExecuteState) { //Style = null; Register(); } } } /// /// 注册需要处理的事件 /// public void Register() { // 运行时进行项目绑定 Binding binding = new Binding(); binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self }; binding.Path = new PropertyPath("ItemsString"); SetBinding(ItemsSourceProperty,binding); } private void MyButton_Click(object sender,RoutedEventArgs e) { } } }