using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Web.UI.WebControls.WebParts; using System.Windows; namespace PdmSwPlugin.Common.Util.UI { /// /// MultiExWindow.xaml 的交互逻辑 /// public partial class MultiExWindow : Window, INotifyPropertyChanged { #region ... public virtual 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); } private ObservableCollection _exceptions; public ObservableCollection exceptions { get => _exceptions; set => RaiseAndSetIfChanged(ref _exceptions, value); } public MultiExWindow(DependencyObject parent, string title, List exceptions) { this.title = title; InitializeComponent(); DataContext = this; if (exceptions == null) { this.exceptions = new ObservableCollection(); } else { this.exceptions = new ObservableCollection(exceptions); } Owner = Window.GetWindow(parent); } private void Window_Loaded(object sender, RoutedEventArgs e) { Dispatcher.Invoke(() => { table.ItemsSource = new ObservableCollection(exceptions); }); } } }