@ -4,19 +4,26 @@ using System.Text;
using System.Threading.Tasks ;
using Avalonia ;
using Avalonia.Controls.Notifications ;
using Avalonia.Diagnostics.ViewModels ;
using Avalonia.Threading ;
using ReactiveUI ;
namespace ControlCatalog.ViewModels
{
class MainWindowViewModel
class MainWindowViewModel : ViewModelBase
{
public MainWindowViewModel ( )
{
this . WhenAnyValue ( x = > x . NotificationManager ) . Subscribe ( x = >
{
} ) ;
Dispatcher . UIThread . InvokeAsync ( async ( ) = >
{
await Task . Delay ( 5 0 0 0 ) ;
Application . Current . MainWindow . LocalNotificationManager . Show ( new NotificationViewModel { Title = "Warning" , Message = "Please save your work before closing." } ) ;
await Task . Delay ( 1 5 0 0 ) ;
@ -33,5 +40,13 @@ namespace ControlCatalog.ViewModels
} ) ;
}
private INotificationManager _ notificationManager ;
public INotificationManager NotificationManager
{
get { return _ notificationManager ; }
set { this . RaiseAndSetIfChanged ( ref _ notificationManager , value ) ; }
}
}
}