diff --git a/Sample Applications/Win11ThemeGallery/App.xaml.cs b/Sample Applications/Win11ThemeGallery/App.xaml.cs index 3bee797c0..bd0799e88 100644 --- a/Sample Applications/Win11ThemeGallery/App.xaml.cs +++ b/Sample Applications/Win11ThemeGallery/App.xaml.cs @@ -98,7 +98,8 @@ public partial class App : Application services.AddTransient(); services.AddTransient(); - + services.AddTransient(); + services.AddTransient(); services.AddSingleton(); services.AddSingleton(); }).Build(); diff --git a/Sample Applications/Win11ThemeGallery/ViewModels/MainWindowViewModel.cs b/Sample Applications/Win11ThemeGallery/ViewModels/MainWindowViewModel.cs index d3a3a8b03..1b99fb0d3 100644 --- a/Sample Applications/Win11ThemeGallery/ViewModels/MainWindowViewModel.cs +++ b/Sample Applications/Win11ThemeGallery/ViewModels/MainWindowViewModel.cs @@ -135,6 +135,12 @@ public partial class MainWindowViewModel : ObservableObject new NavigationItem("PasswordBox", typeof(PasswordBoxPage)), } }, + new NavigationItem + { + Name = "Notifications", + PageType = typeof(NotificationsPage), + Icon = "\xE8D2" + }, }; [ObservableProperty] diff --git a/Sample Applications/Win11ThemeGallery/ViewModels/NotificationsPageViewModel.cs b/Sample Applications/Win11ThemeGallery/ViewModels/NotificationsPageViewModel.cs new file mode 100644 index 000000000..e22517b61 --- /dev/null +++ b/Sample Applications/Win11ThemeGallery/ViewModels/NotificationsPageViewModel.cs @@ -0,0 +1,43 @@ +using Microsoft.Windows.AppNotifications; +using Microsoft.Windows.AppNotifications.Builder; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Win11ThemeGallery.ViewModels +{ + public partial class NotificationsPageViewModel + { + private static AppNotificationManager notificationManager; + + static NotificationsPageViewModel() + { + notificationManager = AppNotificationManager.Default; + notificationManager.NotificationInvoked += OnNotificationInvoked; + notificationManager.Register(); + } + + private static void OnNotificationInvoked(AppNotificationManager sender, AppNotificationActivatedEventArgs args) + { + throw new NotImplementedException(); + } + + [RelayCommand] + public void SendNotification(object pageType) + { + + var appNotification = new AppNotificationBuilder() + .AddArgument("action", "ToastClick") + .AddText("Notification From Gallery App") + .AddText("This is an example message using WPF") + .AddButton(new AppNotificationButton("Open App") + .AddArgument("action", "OpenApp") + ) + .BuildNotification(); + notificationManager.Show(appNotification); + + } + } +} diff --git a/Sample Applications/Win11ThemeGallery/Views/NotificationsPage.xaml b/Sample Applications/Win11ThemeGallery/Views/NotificationsPage.xaml new file mode 100644 index 000000000..1fbaf3e87 --- /dev/null +++ b/Sample Applications/Win11ThemeGallery/Views/NotificationsPage.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/Sample Applications/Win11ThemeGallery/Views/NotificationsPage.xaml.cs b/Sample Applications/Win11ThemeGallery/Views/NotificationsPage.xaml.cs new file mode 100644 index 000000000..5885ed04b --- /dev/null +++ b/Sample Applications/Win11ThemeGallery/Views/NotificationsPage.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Win11ThemeGallery.ViewModels; +namespace Win11ThemeGallery.Views +{ + /// + /// Interaction logic for NotificationsPage.xaml + /// + public partial class NotificationsPage : Page + { + public NotificationsPageViewModel ViewModel { get; } + public NotificationsPage(NotificationsPageViewModel viewModel) + { + InitializeComponent(); + ViewModel = viewModel; + DataContext = this; + } + } +} diff --git a/Sample Applications/Win11ThemeGallery/Win11ThemeGallery.csproj b/Sample Applications/Win11ThemeGallery/Win11ThemeGallery.csproj index 5a0a39f44..8fcf57f3e 100644 --- a/Sample Applications/Win11ThemeGallery/Win11ThemeGallery.csproj +++ b/Sample Applications/Win11ThemeGallery/Win11ThemeGallery.csproj @@ -2,10 +2,13 @@ WinExe - net9.0-windows + net9.0-windows10.0.19041.0 + win-x64; enable enable true + None + true x64 AnyCPU;x64 Win11ThemeGallery.App @@ -24,7 +27,18 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + E:\Wpf