using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Controls; namespace Util.ManualDebug { /// /// ManualCell.xaml 的交互逻辑 /// public partial class ManualCell : 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 private string title; public string Title { get => title; set => Set(ref title, value); } private bool selected; public bool Selected { get => selected; set { if (selected != value) { Set(ref selected, value); SelectedChanged?.Invoke(this, new EventArgs()); } } } private int index; public int Index { get => index; set => Set(ref index, value); } public event EventHandler SelectedChanged; public ManualCell() { this.DataContext = this; InitializeComponent(); } } }