Skip to content

Latest commit

 

History

History
67 lines (40 loc) · 2.13 KB

appnotificationbuilder_addtext_1783245644.md

File metadata and controls

67 lines (40 loc) · 2.13 KB
-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)

-description

Adds a block of text, with display and localization options, to the XML payload for an app notification.

-parameters

-param text

A string containing the text to be displayed on the app notification.

-param properties

An AppNotificationTextProperties specifying display and localization properties for the text.

-returns

Returns the AppNotificationBuilder instance so that additional method calls can be chained.

-remarks

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.

-see-also

-examples

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>