AppNotificationBuilder.AddText Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddText(String) |
Adds a block of text to the XML payload for an app notification. |
AddText(String, AppNotificationTextProperties) |
Adds a block of text, with display and localization options, to the XML payload for an app notification. |
AddText(String)
Adds a block of text to the XML payload for an app notification.
public:
virtual AppNotificationBuilder ^ AddText(Platform::String ^ text) = AddText;
/// [Windows.Foundation.Metadata.Overload("AddText")]
AppNotificationBuilder AddText(winrt::hstring const& text);
[Windows.Foundation.Metadata.Overload("AddText")]
public AppNotificationBuilder AddText(string text);
function addText(text)
Public Function AddText (text As String) As AppNotificationBuilder
Parameters
- text
-
String
Platform::String
winrt::hstring
A string containing the text to be displayed on the app notification.
Returns
Returns the AppNotificationBuilder instance so that additional method calls can be chained.
- Attributes
Examples
The following example demonstrates adding a text block to the XML payload for an app notification.
var notification = new AppNotificationBuilder()
.AddText("Notification text.")
.BuildNotification();
AppNotificationManager.Default.Show(notification);
The resulting XML payload:
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Notification text.</text>
</binding>
</visual>
</toast>
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.
Applies to
AddText(String, AppNotificationTextProperties)
Adds a block of text, with display and localization options, to the XML payload for an app notification.
public:
virtual AppNotificationBuilder ^ AddText(Platform::String ^ text, AppNotificationTextProperties ^ properties) = AddText;
/// [Windows.Foundation.Metadata.Overload("AddText2")]
AppNotificationBuilder AddText(winrt::hstring const& text, AppNotificationTextProperties const& properties);
[Windows.Foundation.Metadata.Overload("AddText2")]
public AppNotificationBuilder AddText(string text, AppNotificationTextProperties properties);
function addText(text, properties)
Public Function AddText (text As String, properties As AppNotificationTextProperties) As AppNotificationBuilder
Parameters
- text
-
String
Platform::String
winrt::hstring
A string containing the text to be displayed on the app notification.
- properties
- AppNotificationTextProperties
An AppNotificationTextProperties specifying display and localization properties for the text.
Returns
Returns the AppNotificationBuilder instance so that additional method calls can be chained.
- Attributes
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>
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.