AppNotificationBuilder.AddText 方法

定義

多載

AddText(String)

將文字區塊新增至代理程式更新的 XML 承載。

AddText(String, AppNotificationTextProperties)

將具有顯示和當地語系化選項的文字區塊新增至代理程式更新的 XML 承載。

AddText(String)

將文字區塊新增至代理程式更新的 XML 承載。

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

參數

text
String

Platform::String

winrt::hstring

字串,包含要顯示在代理程式更新上的文字。

傳回

傳回 AppNotificationBuilder 實例,以便鏈結其他方法呼叫。

屬性

範例

下列範例示範如何將文字區塊新增至代理程式更新的 XML 承載。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

產生的 XML 承載:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
</toast>

備註

最多可以新增三個文字元素至代理程式更新。 超過此限制將會擲回錯誤。

如需使用 AppNotificationBuilder API 建立代理程式更新 UI 的指引,請參閱 代理程式更新內容

如需代理程式更新之 XML 架構的參考資訊,請參閱 代理程式更新內容架構

適用於

AddText(String, AppNotificationTextProperties)

將具有顯示和當地語系化選項的文字區塊新增至代理程式更新的 XML 承載。

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

參數

text
String

Platform::String

winrt::hstring

字串,包含要顯示在代理程式更新上的文字。

properties
AppNotificationTextProperties

AppNotificationTextProperties,指定文字的顯示和當地語系化屬性。

傳回

傳回 AppNotificationBuilder 實例,以便鏈結其他方法呼叫。

屬性

範例

下列範例示範如何將文字區塊新增至代理程式更新的 XML 承載。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.", new AppNotificationTextProperties().SetMaxLines(2))
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

產生的 XML 承載:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text hint-maxLines='2'>Notification text.</text>
        </binding>
    </visual>
</toast>

備註

最多可以新增三個文字元素至代理程式更新。 超過此限制將會擲回錯誤。

如需使用 AppNotificationBuilder API 建立代理程式更新 UI 的指引,請參閱 代理程式更新內容

如需代理程式更新之 XML 架構的參考資訊,請參閱 代理程式更新內容架構

適用於