-api-id | -api-type |
---|---|
M:Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.AddText(System.String,Microsoft.Windows.AppNotifications.Builder.AppNotificationTextProperties) |
winrt method |
Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.AddText(System.String,Microsoft.Windows.AppNotifications.Builder.AppNotificationTextProperties)
Adds a block of text, with display and localization options, to the XML payload for an app notification.
A string containing the text to be displayed on the app notification.
An AppNotificationTextProperties specifying display and localization properties for the text.
Returns the AppNotificationBuilder instance so that additional method calls can be chained.
A maximum of three text elements can be added to an app notification. Exceeding this limit will throw an error.
For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.
For reference information about the XML schema for app notifications, see App notification content schema.
The following example demonstrates adding a text block to the XML payload for an app notification.
var notification = new AppNotificationBuilder()
.AddText("Notification text.", new AppNotificationTextProperties().SetMaxLines(2))
.BuildNotification();
AppNotificationManager.Default.Show(notification);
The resulting XML payload:
<toast>
<visual>
<binding template='ToastGeneric'>
<text hint-maxLines='2'>Notification text.</text>
</binding>
</visual>
</toast>