积极答复者
Metro Search 合约问题

问题
-
HI,
在学习搜索合约时,添加了
SearchPane.GetForCurrentView().SuggestionsRequested += App_SuggestionsRequested这个事件并实现
public App()
{this.InitializeComponent();
this.Suspending += OnSuspending;
SearchPane.GetForCurrentView().SuggestionsRequested += App_SuggestionsRequested;
}void App_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
{
args.Request.SearchSuggestionCollection.AppendQuerySuggestion(“胜多负少”);
}但运行模拟器时,出现如下错误
找不到元素。 (异常来自 HRESULT:0x80070490) ; 请帮助
- 已更改类型 Jie BaoModerator 2012年11月13日 5:10
答案
全部回复
-
HI,
你应该写在 protected override void OnWindowCreated(WindowCreatedEventArgs args) 这个方法中
完全正确,谢谢!
protected override void OnWindowCreated(WindowCreatedEventArgs args)
{
base.OnWindowCreated(args);
SearchPane.GetForCurrentView().SuggestionsRequested += App_SuggestionsRequested;
}成功,现在思考一下,也应该是样,这应该是初始化的顺序的问题吧,在这里才可以找到SearchPane元素。