다음을 통해 공유


ToastNotificationManager.GetTemplateContent(ToastTemplateType) 메서드

정의

미리 정의된 알림 템플릿 중 하나의 XML 콘텐츠를 가져오므로 알림에 사용할 수 있도록 사용자 지정할 수 있습니다.

public:
 static XmlDocument ^ GetTemplateContent(ToastTemplateType type);
 static XmlDocument GetTemplateContent(ToastTemplateType const& type);
public static XmlDocument GetTemplateContent(ToastTemplateType type);
function getTemplateContent(type)
Public Shared Function GetTemplateContent (type As ToastTemplateType) As XmlDocument

매개 변수

type
ToastTemplateType

시스템에서 제공하는 알림 템플릿 중 하나입니다.

반환

템플릿 XML을 포함하는 개체입니다.

예제

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

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);

설명

전체 XML 페이로드를 직접 만드는 대신 템플릿을 가져와서 DOM(문서 개체 모델) 조작 함수를 사용하여 변경하려는 콘텐츠 부분을 사용자 지정할 수 있습니다. 이 XML을 ToastNotification 에 패키지하고 이 클래스의 다른 메서드를 통해 만든 ToastNotifier 를 통해 타일로 보냅니다.

타일 요소 및 특성에 대한 설명은 타일 스키마 를 참조하세요.

적용 대상

추가 정보