diff --git a/src/Avalonia.Controls/Notifications/Notification.cs b/src/Avalonia.Controls/Notifications/Notification.cs index 376df175f3..ace8cba243 100644 --- a/src/Avalonia.Controls/Notifications/Notification.cs +++ b/src/Avalonia.Controls/Notifications/Notification.cs @@ -1,4 +1,7 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; namespace Avalonia.Controls.Notifications { @@ -9,8 +12,10 @@ namespace Avalonia.Controls.Notifications /// This class represents a notification that can be displayed either in a window using /// or by the host operating system (to be implemented). /// - public class Notification : INotification + public class Notification : INotification, INotifyPropertyChanged { + private string? _title, _message; + /// /// Initializes a new instance of the class. /// @@ -35,23 +40,59 @@ namespace Avalonia.Controls.Notifications OnClick = onClick; OnClose = onClose; } + + /// + /// Initializes a new instance of the class. + /// + public Notification() : this(null, null) + { + } /// - public string? Title { get; private set; } + public string? Title + { + get => _title; + set + { + if (_title != value) + { + _title = value; + OnPropertyChanged(); + } + } + } /// - public string? Message { get; private set; } + public string? Message + { + get => _message; + set + { + if (_message != value) + { + _message = value; + OnPropertyChanged(); + } + } + } /// - public NotificationType Type { get; private set; } + public NotificationType Type { get; set; } /// - public TimeSpan Expiration { get; private set; } + public TimeSpan Expiration { get; set; } /// - public Action? OnClick { get; private set; } + public Action? OnClick { get; set; } /// - public Action? OnClose { get; private set; } + public Action? OnClose { get; set; } + + public event PropertyChangedEventHandler? PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } }