-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from andrewleader/toast-notifications
Add toast notifications
- Loading branch information
Showing
7 changed files
with
239 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
WindowsAppSDKGallery/SamplePages/NotificationsSamples/ToastNotificationPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Page | ||
x:Class="WindowsAppSDKGallery.SamplePages.NotificationsSamples.ToastNotificationPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:WindowsAppSDKGallery.SamplePages.NotificationsSamples" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:controls="using:WindowsAppSDKGallery.Controls" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<StackPanel> | ||
|
||
<controls:SampleExample | ||
HeaderText="Show a toast notification"> | ||
|
||
<Button | ||
x:Name="ButtonShowToast" | ||
Content="Show toast" | ||
Click="ButtonShowToast_Click"/> | ||
|
||
</controls:SampleExample> | ||
|
||
<controls:ApiExample | ||
x:Name="ClearNotifications" | ||
HeaderText="Clear all notifications" | ||
Api="ToastNotificationManagerCompat.History.Clear();" | ||
ExecuteApi="ClearNotifications_ExecuteApi"/> | ||
|
||
</StackPanel> | ||
</Page> |
52 changes: 52 additions & 0 deletions
52
WindowsAppSDKGallery/SamplePages/NotificationsSamples/ToastNotificationPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Microsoft.Toolkit.Uwp.Notifications; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace WindowsAppSDKGallery.SamplePages.NotificationsSamples | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class ToastNotificationPage : Page | ||
{ | ||
public ToastNotificationPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void ButtonShowToast_Click(object sender, RoutedEventArgs e) | ||
{ | ||
new ToastContentBuilder() | ||
.AddText("Toast from Windows App SDK Gallery") | ||
.AddText("Click the toast to open the app and navigate back to the toast sample. Or type a message to try background activation.") | ||
.AddArgument("action", "viewToastSample") | ||
.AddInputTextBox("textBox", "Type some text") | ||
.AddButton(new ToastButton() | ||
.SetTextBoxId("textBox") | ||
.SetContent("Send") | ||
.SetBackgroundActivation() | ||
.AddArgument("action", "sendMessage")) | ||
.Show(); | ||
} | ||
|
||
private void ClearNotifications_ExecuteApi(object sender, Controls.ExecuteApiArgs e) | ||
{ | ||
ToastNotificationManagerCompat.History.Clear(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters