语言

AppNotificationBuilder.SetHeroImage 方法

定义

重载

名称 说明
SetHeroImage(Uri)

设置显示在应用通知顶部的图像,占用通知的完整宽度。

SetHeroImage(Uri, String)

使用指定的备用文本设置显示在应用通知顶部的图像,占用通知的全宽。

SetHeroImage(Uri)

设置显示在应用通知顶部的图像,占用通知的完整宽度。

public:
 virtual AppNotificationBuilder ^ SetHeroImage(Uri ^ imageUri) = SetHeroImage;
/// [Windows.Foundation.Metadata.Overload("SetHeroImage")]
AppNotificationBuilder SetHeroImage(Uri const& imageUri);
[Windows.Foundation.Metadata.Overload("SetHeroImage")]
public AppNotificationBuilder SetHeroImage(System.Uri imageUri);
function setHeroImage(imageUri)
Public Function SetHeroImage (imageUri As Uri) As AppNotificationBuilder

参数

imageUri
Uri Uri

主图文件的 URI。

返回

返回 AppNotificationBuilder 实例,以便可以链接其他方法调用。

属性

示例

以下示例演示如何在应用通知的 XML 有效负载中设置应用徽标替代图像。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetHeroImage(new Uri("ms-appx:///Images/HeroImage.png"))
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
            <image placement='hero' src='ms-appx:///Images/HeroImage.png'/>
        </binding>
    </visual>
</toast>

注解

以下屏幕截图演示了主图的位置。

包含主图的应用通知的屏幕截图。

支持的映像文件类型包括:

  • .png
  • .jpg
  • .svg

有关使用 AppNotificationBuilder API 创建应用通知的 UI 的指导,请参阅 应用通知内容。

有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构。

适用于

SetHeroImage(Uri, String)

使用指定的备用文本设置显示在应用通知顶部的图像,占用通知的全宽。

public:
 virtual AppNotificationBuilder ^ SetHeroImage(Uri ^ imageUri, Platform::String ^ alternateText) = SetHeroImage;
/// [Windows.Foundation.Metadata.Overload("SetHeroImage2")]
AppNotificationBuilder SetHeroImage(Uri const& imageUri, winrt::hstring const& alternateText);
[Windows.Foundation.Metadata.Overload("SetHeroImage2")]
public AppNotificationBuilder SetHeroImage(System.Uri imageUri, string alternateText);
function setHeroImage(imageUri, alternateText)
Public Function SetHeroImage (imageUri As Uri, alternateText As String) As AppNotificationBuilder

参数

imageUri
Uri Uri

主图文件的 URI。

alternateText
String

Platform::String

winrt::hstring

包含主图的备用文本的字符串。

返回

返回 AppNotificationBuilder 实例,以便可以链接其他方法调用。

属性

示例

以下示例演示如何在应用通知的 XML 有效负载中设置应用徽标替代图像。

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .SetHeroImage(new Uri("ms-appx:///Images/HeroImage.png"), "Alternate text")
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

生成的 XML 有效负载:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
            <image placement='hero' src='ms-appx:///Images/HeroImage.png'/>
        </binding>
    </visual>
</toast>

注解

以下屏幕截图演示了主图的位置。

包含主图的应用通知的屏幕截图。

支持的映像文件类型包括:

  • .png
  • .jpg
  • .svg

有关使用 AppNotificationBuilder API 创建应用通知的 UI 的指导,请参阅 应用通知内容。

有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构。

适用于