alielie
2025-03-03 4c3eb7f334abb8129b57e86f2935d75d0b3070b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Plugin.TestResult_WPF.Model;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
 
namespace Plugin.TestResult_WPF
{
    /// <summary>
    /// InfoWindow.xaml 的交互逻辑
    /// </summary>
    public partial class InfoWindow : Window, INotifyPropertyChanged
    {
 
        #region ...
        public event PropertyChangedEventHandler PropertyChanged;
 
        public virtual void RaisePropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
 
        public void RaiseAndSetIfchanged<T>(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<Info> _dataSource;
 
        public ObservableCollection<Info> dataSource
        {
            get => _dataSource == null ? new ObservableCollection<Info>() : _dataSource;
            set => RaiseAndSetIfchanged(ref _dataSource, value);
        }
 
        public InfoWindow(string title, ObservableCollection<Info> infos)
        {
            this.title = title;
            this.dataSource = infos;
            this.DataContext = this;
            InitializeComponent();
        }
 
        public void UpdateSource(ObservableCollection<Info> infos)
        {
            this.dataSource = infos;
        }
    }
}