using Bro.Common.Helper; using Bro.Common.Interface; using System; using System.Collections.Generic; using System.Globalization; 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; using static Bro.Common.Helper.EnumHelper; namespace Bro.UI.Ctrls { /// /// DeviceStatusCtrl.xaml 的交互逻辑 /// public partial class DeviceStatusCtrl : UserControl { public DeviceStatusCtrl() { InitializeComponent(); lbDevices.ItemsSource = DeviceList; } public static readonly DependencyProperty DeviceListProperty; public IEnumerable DeviceList { get => GetValue(DeviceListProperty) as List; set => SetValue(DeviceListProperty, value); } static DeviceStatusCtrl() { DeviceListProperty = DependencyProperty.Register("DeviceList", typeof(IEnumerable), typeof(DeviceStatusCtrl), new PropertyMetadata(new List(), OnDeviceListPropertyChanged)); } private static void OnDeviceListPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DeviceStatusCtrl ctrl = d as DeviceStatusCtrl; if (ctrl != null) { IEnumerable list = e.NewValue as IEnumerable; if (list != null) { ctrl.lbDevices.ItemsSource = list; } } } } }