How to retain Search Results Page list items RRS feed

  • Question

  • Hello,

    In my metro app, I have a function to get the search result list from local html contents for search keyword provided in charm bar and these results are displayed in Search Contract page using CollectionViewSource. Click to an item shows the html page on webview. I am calling my search function in LoadState api of Search Contract class.


    here is a sample code:

    void SearchContract::LoadState(Object^ navigationParameter, IMap<String^, Object^>^ pageState)
        (void) pageState; // Unused parameter
        auto queryText = safe_cast<String^>(navigationParameter);
        if (!queryText->IsEmpty()) {
             ResultList = MyClass->SearchFunction(queryText);

            DefaultViewModel->Insert ("Results", resultList);
            VisualStateManager::GoToState(this, "ResultsFound", true);
            resultsViewSource->Source = resultList; //resultsViewSource is of type CollectionViewSource

    When I click on "Back Button" each time from the result page, the Search Contract class calls its constructor and LoadState function, which makes a call to my search function to get the result list. I would like to avoid this call and retain the search result list which I already have. My search function should call only when there is a new term provided. I hope there must be a option to avoid this. As I am new to metro, I couldn't able to find the option.

    Please help me to resolve this problem.

    Thanking you in advance.



    Wednesday, August 22, 2012 11:33 AM


All replies