WebUIApplication.Navigated 이벤트

정의

앱이 탐색할 때 발생합니다.

public:
 static event NavigatedEventHandler ^ Navigated;
// Register
static event_token Navigated(NavigatedEventHandler const& handler) const;

// Revoke with event_token
static void Navigated(event_token const* cookie) const;

// Revoke with event_revoker
static WebUIApplication::Navigated_revoker Navigated(auto_revoke_t, NavigatedEventHandler const& handler) const;
public static event NavigatedEventHandler Navigated;
function onNavigated(eventArgs) { /* Your code */ }
Windows.UI.WebUI.WebUIApplication.addEventListener("navigated", onNavigated);
Windows.UI.WebUI.WebUIApplication.removeEventListener("navigated", onNavigated);
- or -
Windows.UI.WebUI.WebUIApplication.onnavigated = onNavigated;
Public Shared Custom Event Navigated As NavigatedEventHandler 

이벤트 유형

예제

탐색된 이벤트에 등록하고 WebUINavigatedDeferral 개체를 사용하여 상태가 파일에서 비동기적으로 로드될 때까지 앱의 UI 고정을 지연합니다.

function navigatedHandler(eventArgs) {

    var deferral = eventArgs.navigatedOperation.getDeferral();

    // Populate the text box with the previously saved value while the app visuals are frozen
    app.local.readText(myfile, "default").then(function (str) {
        document.getElementById("userText").value = str;

        // Complete the deferral to transition back to a live view of the app
        deferral.complete();
    }, function(error) {
        document.getElementById("userText").value = 'undefined';

        // Complete the deferral even in the case where readText fails 
        // else the app would appear hung to the user
        deferral.complete();
    });
}

Windows.UI.WebUI.WebUIApplication.addEventListener("navigated", navigatedHandler, false);

설명

대부분의 경우 HTML 기반 UWP 앱은 최상위 문서를 탐색하거나 다시 로드할 필요가 없습니다. 글로벌 상태를 유지하고 원활한 사용자 환경을 만들려면 앱이 동일한 최상위 페이지 내에서 필요한 대로 HTML을 동적으로 로드하고 분해하는 것이 좋습니다.

그러나 드물게 앱이 최상위 문서를 탐색하거나 다시 로드해야 할 수 있습니다. 이 경우 최상위 문서를 탐색하거나 다시 로드한 후 탐색된 이벤트가 발생합니다. DOMContentLoaded 이벤트 이후 및 onLoad 이벤트 전에 발생합니다. 이 이벤트는 새 활성화가 아니라 앱 탐색의 로 인해 로드되고 있음을 새 페이지에 알릴 수 있습니다. 이 이벤트를 사용하여 페이지에 저장된 상태를 복원하고 앱의 UI를 다시 초기화할 수 있습니다.

참고

이 이벤트가 발생하기 전에 앱의 시각적 개체가 고정되어 사용자가 앱의 이전 페이지를 계속 볼 수 있습니다. 탐색한 후 시스템이 새 페이지의 UI로 전환됩니다. 이렇게 하면 사용자가 UI를 보기 전에 앱이 새 페이지에서 해당 UI를 설정할 수 있습니다. 비동기 메서드를 사용하여 UI를 초기화해야 하는 경우 eventArgs에서 navigatedOperation 을 사용하여 탐색 완료를 연기할 수 있습니다.

적용 대상