Web​UI​Search​Activated​Event​Args Web​UI​Search​Activated​Event​Args Web​UI​Search​Activated​Event​Args Class

Definition

Provides information about the activated event that fires when the user searches the app from the Search charm and the app isn't the main app on screen.

C#/C++/VB This type appears as SearchActivatedEventArgs.

public : sealed class WebUISearchActivatedEventArgs : IActivatedEventArgs, IApplicationViewActivatedEventArgs, ISearchActivatedEventArgs, ISearchActivatedEventArgsWithLinguisticDetails, IActivatedEventArgsDeferralpublic sealed class WebUISearchActivatedEventArgs : IActivatedEventArgs, IApplicationViewActivatedEventArgs, ISearchActivatedEventArgs, ISearchActivatedEventArgsWithLinguisticDetails, IActivatedEventArgsDeferralPublic NotInheritable Class WebUISearchActivatedEventArgs Implements IActivatedEventArgs, IApplicationViewActivatedEventArgs, ISearchActivatedEventArgs, ISearchActivatedEventArgsWithLinguisticDetails, IActivatedEventArgsDeferral
Attributes
Windows 10 requirements
Device family
Windows Desktop Extension SDK (introduced v10.0.10240.0) Windows Mobile Extension SDK (introduced v10.0.10240.0)
API contract
Windows.ApplicationModel.Activation.WebUISearchActivatedEventsContract (introduced v1)

Examples

The Search contract sample demonstrates how to respond to a search activated event.

function activated(eventObject) {
    if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
        // Use setPromise to indicate to the system that the splash screen must not be torn down
        // until after processAll and navigate complete asynchronously.
        eventObject.setPromise(WinJS.UI.processAll().then(function () {
            // Navigate to either the first scenario or to the last running scenario
            // before suspension or termination.
            var url = WinJS.Application.sessionState.lastUrl || scenarios[0].url;
            return WinJS.Navigation.navigate(url);
        }));
    } else if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.search) {
        // Use setPromise to indicate to the system that the splash screen must not be torn down
        // until after processAll and navigate complete asynchronously.
        eventObject.setPromise(WinJS.UI.processAll().then(function () {
            if (eventObject.detail.queryText === "") {
                // Navigate to your landing page since the user is pre-scoping to your app.
            } else {
                // Display results in UI for eventObject.detail.queryText and eventObject.detail.language.
                // eventObject.detail.language represents user's locale.
            }
            // Navigate to the first scenario since it handles search activation.
            var url = scenarios[0].url;
            return WinJS.Navigation.navigate(url, { searchDetails: eventObject.detail });
        }));
    }
}

For JavaScript, eventObject contains a webUISearchActivatedEventArgs object.

Remarks

If your app integrates with the Search contract, a webUISearchActivatedEventArgs is passed to your app's onactivated event handler when the user searches the app from the Search charm and your app is not the main app on screen. This type of activation is indicated by the activationKind.search value returned by the kind property.

Learn how to let users search with your app in Quickstart: Adding search. Learn about responding to other search-related events and customizing the search box and suggestions using the searchPane class in the Windows.ApplicationModel.Search namespace reference.

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX)

.

Properties

ActivatedOperation ActivatedOperation ActivatedOperation

Gets the app activated operation.

public : ActivatedOperation ActivatedOperation { get; }public ActivatedOperation ActivatedOperation { get; }Public ReadOnly Property ActivatedOperation As ActivatedOperation
Value
ActivatedOperation ActivatedOperation ActivatedOperation

The activation operation.

Attributes

CurrentlyShownApplicationViewId CurrentlyShownApplicationViewId CurrentlyShownApplicationViewId

Gets the identifier for the currently shown app view.

public : int CurrentlyShownApplicationViewId { get; }public int CurrentlyShownApplicationViewId { get; }Public ReadOnly Property CurrentlyShownApplicationViewId As int
Value
int int int

The identifier for the currently shown app view.

Attributes

Kind Kind Kind

Gets the activation type.

public : ActivationKind Kind { get; }public ActivationKind Kind { get; }Public ReadOnly Property Kind As ActivationKind
Attributes

Examples

The Search contract sample demonstrates how to determine when an app is activated for search in the app's activated event handler.

} else if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.search) {
    // Use setPromise to indicate to the system that the splash screen must not be torn down
    // until after processAll and navigate complete asynchronously.
    eventObject.setPromise(WinJS.UI.processAll().then(function () {
        if (eventObject.detail.queryText === "") {
            // Navigate to your landing page since the user is pre-scoping to your app.
        } else {
            // Display results in UI for eventObject.detail.queryText and eventObject.detail.language.
            // eventObject.detail.language represents user's locale.
        }

        // Navigate to the first scenario since it handles search activation.
        var url = scenarios[0].url;
        return WinJS.Navigation.navigate(url, { searchDetails: eventObject.detail });
    }));
}

In the sample, e is a webUISearchActivatedEventArgs object. The sample checks the e.queryText property to determine whether the app should display results for the query.

Language Language Language

Gets the Internet Engineering Task Force (IETF) language tag (BCP 47 standard) that identifies the language currently associated with the user's text input device.

public : PlatForm::String Language { get; }public string Language { get; }Public ReadOnly Property Language As string
Value
PlatForm::String string string

The Internet Engineering Task Force (IETF) BCP 47 standard language tag.

Attributes

LinguisticDetails LinguisticDetails LinguisticDetails

Gets a SearchPaneQueryLinguisticDetails object that provides info about query text that the user enters through an Input Method Editor (IME).

public : SearchPaneQueryLinguisticDetails LinguisticDetails { get; }public SearchPaneQueryLinguisticDetails LinguisticDetails { get; }Public ReadOnly Property LinguisticDetails As SearchPaneQueryLinguisticDetails
Attributes

PreviousExecutionState PreviousExecutionState PreviousExecutionState

Gets the execution state of the app before it was activated.

public : ApplicationExecutionState PreviousExecutionState { get; }public ApplicationExecutionState PreviousExecutionState { get; }Public ReadOnly Property PreviousExecutionState As ApplicationExecutionState
Attributes

QueryText QueryText QueryText

Gets the text that the user wants the app to search for. The user entered this text into the search box of the search pane.

public : PlatForm::String QueryText { get; }public string QueryText { get; }Public ReadOnly Property QueryText As string
Value
PlatForm::String string string

The text to search for.

Attributes

Examples

The Search contract sample demonstrates how to use the queryText property in the app's activated event handler to determine whether the app should display a view of search results or the app's default, home view (if queryText is empty).

} else if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.search) {
    // Use setPromise to indicate to the system that the splash screen must not be torn down
    // until after processAll and navigate complete asynchronously.
    eventObject.setPromise(WinJS.UI.processAll().then(function () {
        if (eventObject.detail.queryText === "") {
            // Navigate to your landing page since the user is pre-scoping to your app.
        } else {
            // Display results in UI for eventObject.detail.queryText and eventObject.detail.language.
            // eventObject.detail.language represents user's locale.
        }

        // Navigate to the first scenario since it handles search activation.
        var url = scenarios[0].url;
        return WinJS.Navigation.navigate(url, { searchDetails: eventObject.detail });
    }));
}

In the example, e is a webUISearchActivatedEventArgs object.

SplashScreen SplashScreen SplashScreen

Gets the splash screen object that provides information about the transition from the splash screen to the activated app.

public : SplashScreen SplashScreen { get; }public SplashScreen SplashScreen { get; }Public ReadOnly Property SplashScreen As SplashScreen
Value
SplashScreen SplashScreen SplashScreen

The object that provides splash screen information.

Attributes

Examples

The Splash screen sample demonstrates how to retrieve a splashScreen object in its activated event handler, if the app was launched:


// Identify and respond to all app activated events.
WinJS.Application.onactivated = function (eventObject) {

    // App was launched
    if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
        // Retrieve splash screen object
        splash = eventObject.detail.splashScreen;

        // Add code get image coordinates or listen for the dismissed event

        WinJS.UI.processAll();
    }
    // Add code to respond to other activated event types
};

In the sample, eventObject is an object provides information about the activated event. In the case of a ActivationKind.launch activated event, the eventObject is a WebUILaunchActivatedEventArgs object.

See Also