using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Controls; namespace Plugin.JarUI { /// /// JarCell.xaml 的交互逻辑 /// public partial class JarCell : UserControl, INotifyPropertyChanged { #region ... public event PropertyChangedEventHandler PropertyChanged; protected void Set([CallerMemberName] string name = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } protected void Set(ref T old, T @new, [CallerMemberName] string propertyName = null) { old = @new; if (propertyName != null) { Set(propertyName); } } #endregion public JarCell(int index) { DataContext = this; Index = index; Name = $"Socket_{index + 1}"; SnText = $"SN{index + 1}"; InitializeComponent(); } #region Properties public int Index { get; private set; } public string Name { get; private set; } private string _status = "Ready"; public string Status { get { return _status; } set { Set(ref _status, value); } } private string _info = ""; public string Info { get { return _info; } set { Set(ref _info, value); } } private string _snText; public string SnText { get { return _snText; } set { Set(ref _snText, value); } } #endregion public void SetStatus(string status) { Status = status; } public void SetInfo(string info) { Info = info; } public void SetSn(string sn) { TbSn.Text = sn; } } }