locked
Call OnNavigatedFrom when OnSearchActivated RRS feed

  • Question

  • Hi everybody,

    Is there any possibility to call the OnNavigatedFrom method when we call OnSearchActivated (when we do a search)?

    It seems that OnNavigatedFrom isn't called when we execute a search...

    Sorry for my english and thank you so much everybody.

    Monday, April 29, 2013 1:54 PM

Answers

  • You may try with Unloaded event.

    Otherwise it is possible to take over Search charm events if you use

    SearchPane.GetForCurrentView().QuerySubmitted += Search_QuerySubmitted;

    This will override OnSearchActivated event and you can handle this as need to.
    But don't forget to remove this event when it is not needed or you want another page to handle searching.

    SearchPane.GetForCurrentView().QuerySubmitted -= Search_QuerySubmitted;

    Also note that only one method can be used for QuerySubmitted event. Adding one more will result with an exception.
    If QuerySubmitted has no events, OnSearchActivated will work the same as before.
    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:10 AM
    Monday, April 29, 2013 2:28 PM
  • Not sure how you want to use OnNavigatedFrom, however it will not be called as Page is still very much there when search is activated.

    You can try using search visibility event if it fits in your scenario. (search declaration is needed in package manifest for this)

    SearchPane searchPane = SearchPane.GetForCurrentView(); searchPane.VisibilityChanged += searchPane_VisibilityChanged; void searchPane_VisibilityChanged(SearchPane o, SearchPaneVisibilityChangedEventArgs e) { try { if (e.Visible == true) { }

    else

    { } } catch (Exception ex) { } }



    Thanks,
    Sachin
    My Samples | Personal Website

    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:10 AM
    Monday, April 29, 2013 4:05 PM

All replies

  • You may try with Unloaded event.

    Otherwise it is possible to take over Search charm events if you use

    SearchPane.GetForCurrentView().QuerySubmitted += Search_QuerySubmitted;

    This will override OnSearchActivated event and you can handle this as need to.
    But don't forget to remove this event when it is not needed or you want another page to handle searching.

    SearchPane.GetForCurrentView().QuerySubmitted -= Search_QuerySubmitted;

    Also note that only one method can be used for QuerySubmitted event. Adding one more will result with an exception.
    If QuerySubmitted has no events, OnSearchActivated will work the same as before.
    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:10 AM
    Monday, April 29, 2013 2:28 PM
  • Not sure how you want to use OnNavigatedFrom, however it will not be called as Page is still very much there when search is activated.

    You can try using search visibility event if it fits in your scenario. (search declaration is needed in package manifest for this)

    SearchPane searchPane = SearchPane.GetForCurrentView(); searchPane.VisibilityChanged += searchPane_VisibilityChanged; void searchPane_VisibilityChanged(SearchPane o, SearchPaneVisibilityChangedEventArgs e) { try { if (e.Visible == true) { }

    else

    { } } catch (Exception ex) { } }



    Thanks,
    Sachin
    My Samples | Personal Website

    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:10 AM
    Monday, April 29, 2013 4:05 PM