using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; namespace SourceGit.Views.Widgets { /// /// 错误提示面板 /// public partial class Exceptions : UserControl { public ObservableCollection Messages { get; set; } public Exceptions() { Messages = new ObservableCollection(); Models.Exception.Handler = e => Dispatcher.Invoke(() => Messages.Add(e)); InitializeComponent(); } private void Dismiss(object sender, RoutedEventArgs e) { var data = (sender as Button).DataContext as string; Messages.Remove(data); } } }