SearchBoxControl has focus on app launching on Win8.1

心不动则不痛 提交于 2019-12-07 13:49:18

问题


I'm using the new SearchBox Control in my Windows 8.1 app, but everytime I launch the app the SearchBox has the focus and displays the search history. I've tried to set the focus on another control on my page, but it doesn't work. So how can I start my app without showing the search history?

Thanks.


回答1:


Here's my guess. You are attempting to set focus to something else on the page, but there's actually nothing else on your page that can accept a programmatic focus. To test this, simply add a <Button /> to your page and set the focus to that. Buttons are perfect for this test, as would be a <TextBox />. If this foxes the problem then you understand it.

You have some options, and your choices will vary based on your app:

  1. Set the SearchBox to IsEnabled=false until the Page.Loaded is raised
  2. Set focus on another control, like a <Button /> that is Width="1" and Height="1"
  3. You might try TabStop="False" on the SearchBox, but that may not work
  4. Move the SearchBox further down the Logical Tree, the default Tab Stop is higher

Sorry for just brainstorming with you on this. I bet one of those will do it. Let me know.

Best of luck.




回答2:


Try setting the SearchHistoryEnabled to false: http://msdn.microsoft.com/en-US/library/windows/apps/windows.ui.xaml.controls.searchbox.searchhistoryenabled.aspx



来源:https://stackoverflow.com/questions/20544627/searchboxcontrol-has-focus-on-app-launching-on-win8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!