2
如果要實現在Windows Store應用搜索合同,然後在App.xaml.cs你重寫了OnSearchActivated
方法是這樣的:App.OnSearchActivated與App.OnActivated與ActivationKind.Search有什麼不同?
protected override void OnSearchActivated(SearchActivatedEventArgs args)
{
(Window.Current.Content as Frame).Navigate(typeof(Contracts.Search), args.QueryText);
}
但是,如果你正在關注,那麼你就可以看到,有一個名爲OnActivated
App類有事件參數指示搜索激活,這樣其他控制裝置:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Search)
{
(Window.Current.Content as Frame).Navigate(typeof(Contracts.Search), args.QueryText);
}
}
當我實現一個或另一個結果似乎是相同的。這引出了一個問題:兩者有什麼區別? 他們真的一樣嗎?