다음을 통해 공유


ToastNotification(XmlDocument) 생성자

정의

ToastNotification의 새 instance 만들고 초기화합니다.

public:
 ToastNotification(XmlDocument ^ content);
 ToastNotification(XmlDocument const& content);
public ToastNotification(XmlDocument content);
function ToastNotification(content)
Public Sub New (content As XmlDocument)

매개 변수

content
XmlDocument

알림 메시지를 정의하는 XML 콘텐츠입니다.

예제

다음 예제에서는 ToastNotification 생성자 사용을 포함하여 텍스트 및 이미지가 포함된 알림 메시지를 만들고 보내는 방법을 보여 줍니다.

var notifications = Windows.UI.Notifications;

// Get the toast notification manager for the current app.
var notificationManager = notifications.ToastNotificationManager;

// The getTemplateContent method returns a Windows.Data.Xml.Dom.XmlDocument object
// that contains the toast notification XML content.
var template = notifications.ToastTemplateType.toastImageAndText01;
var toastXml = notificationManager.getTemplateContent(notifications.ToastTemplateType[template]);

// You can use the methods from the XML document to specify the required elements for the toast.
var images = toastXml.getElementsByTagName("image");
images[0].setAttribute("src", "images/toastImageAndText.png");

var textNodes = toastXml.getElementsByTagName("text");
textNodes.forEach(function (value, index) {
    var textNumber = index + 1;
    var text = "";
    for (var j = 0; j < 10; j++) {
        text += "Text input " + /*@static_cast(String)*/textNumber + " ";
    }
    value.appendChild(toastXml.createTextNode(text));
});

// Create a toast notification from the XML, then create a ToastNotifier object
// to send the toast.
var toast = new notifications.ToastNotification(toastXml);

notificationManager.createToastNotifier().show(toast);

적용 대상

추가 정보