using Plugin.TestResult_WPF.Model;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
namespace Plugin.TestResult_WPF
{
///
/// InfoWindow.xaml 的交互逻辑
///
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(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 _dataSource;
public ObservableCollection dataSource
{
get => _dataSource == null ? new ObservableCollection() : _dataSource;
set => RaiseAndSetIfchanged(ref _dataSource, value);
}
public InfoWindow(string title, ObservableCollection infos)
{
this.title = title;
this.dataSource = infos;
this.DataContext = this;
InitializeComponent();
}
public void UpdateSource(ObservableCollection infos)
{
this.dataSource = infos;
}
}
}