Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/maui/alerts/snackbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ await MyVisualElement.DisplaySnackbar("Snackbar is awesome. It is anchored to My
> [!WARNING]
> `Snackbar` on Windows can't be anchored to `VisualElement` and is always displayed as a default Windows Notification.

> [!IMPORTANT]
> `Snackbar` on Windows requires a **packaged (MSIX) app**. The underlying `AppNotificationManager` API is only available within a packaged app identity. If your app is not packaged, constructing a `Snackbar` will throw an `InvalidOperationException` with a descriptive message and a `HelpLink` pointing to this documentation. For unpackaged apps, consider using an alternative notification mechanism such as in-app UI alerts.

`SnackBar` contains two events:

- `public static event EventHandler Shown`
Expand Down
4 changes: 3 additions & 1 deletion docs/maui/alerts/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To access the `Toast` functionality, the following platform specific setup is re

## Syntax

### C#
### C #

To display `Toast`, first create it using the static method `Toast.Make()`, then display it using its method `Show()`.

Expand All @@ -40,6 +40,7 @@ await toast.Show(cancellationTokenSource.Token);
When calling `Toast.Make()`, its parameter `string text` is required. All other parameters are optional. Its optional parameter `ToastDuration duration` uses the default duration of `ToastDuration.Short`. Its optional parameter `double fontSize` uses the default value of `14.0`.

The following screenshot shows the resulting Toast:

### [Android](#tab/toast-preview-android)

![Screenshot of an Toast on Android](../images/alerts/toast-android.gif "Toast on Android")
Expand Down Expand Up @@ -90,3 +91,4 @@ You can find the source code for `Toast` over on the [.NET MAUI Community Toolki
1. The API allows override existing methods with your own implementation or creating your own Toast, by implementing `IToast` interface.
2. Toast is implemented on Android, created by Google. Other platforms use a custom-implemented container (`UIView` for iOS and MacCatalyst, `ToastNotification` on Windows).
3. Toast on Tizen can't be customized with its `Duration` and `TextSize` properties.
4. `Toast` on Windows requires a **packaged (MSIX) app**. The underlying `AppNotificationManager` API is only available within a packaged app identity.
11 changes: 7 additions & 4 deletions docs/maui/includes/toast-snackbar-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ No setup is required.

### [Windows](#tab/windows)

When using `Snackbar` it is essential to perform the following two steps:
> [!IMPORTANT]
> `Snackbar` and `Toast` on Windows require a **packaged (MSIX) app**. The underlying Windows App SDK `AppNotificationManager` API only works within a packaged app identity. If your app is not packaged, `Snackbar` and `Toast` are not supported on Windows.

When using `Snackbar` or `Toast` on Windows, perform the following steps:

#### 1. Enable the snackbar usage with the MauiAppBuilder
#### 1. Enable snackbar/toast usage with the MauiAppBuilder

When using the `UseMauiCommunityToolkit` make use of the `options` parameter to enable the snackbar usage on Windows as follows:
When using `UseMauiCommunityToolkit`, enable snackbar and toast support on Windows as follows:

```csharp
var builder = MauiApp.CreateBuilder()
Expand All @@ -27,7 +30,7 @@ var builder = MauiApp.CreateBuilder()
})
```

The above will automatically register the required handlers by configuring lifecycle events (`OnLaunched` and `OnClosed`).
In a **packaged (MSIX)** app, this registers the required handlers by configuring lifecycle events (`OnLaunched` and `OnClosed`). In an **unpackaged** app, registration is silently skipped and a diagnostic message is emitted via `Trace.WriteLine`.

#### 2. Include ToastNotification registrations in your Package.appxmanifest file

Expand Down