using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; namespace Plugin.TestResult_WPF { /// /// ChartWindow.xaml 的交互逻辑 /// public partial class ChartWindow : Window, INotifyPropertyChanged { #region ... public event PropertyChangedEventHandler PropertyChanged; public virtual void RaisePropertyChanged(string name) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } public void RaiseAndSetIfchanged(ref T old, T @new, [CallerMemberName] string propertyName = null) { old = @new; if (propertyName != null) RaisePropertyChanged(propertyName); } #endregion private string _title; public string title { get => _title; set => RaiseAndSetIfchanged(ref _title, value); } public ChartWindow(string title) { this.title = $"{title}详细曲线"; this.DataContext = this; InitializeComponent(); } private void Window_Unloaded(object sender, RoutedEventArgs e) { this.mainGrid.Children.Clear(); } } }