2013-05-11 42 views
2

有没有办法在C#中关闭当您点击TextBox时可见的文本输入弹出窗口?关闭textinput文本框?

我想在我的应用程序中将焦点设置为LayoutRoot或ContentPanel(两个父网格),但这不起作用。

+0

你的意思是隐藏键盘? – 2013-05-11 22:36:52

+0

@Alaa Masoud我想隐藏键盘 – Jason94 2013-05-12 12:02:17

回答

1

聚焦当前页面会为你隐藏键盘。

做一个扩展方法来获得当前活动页

public static PhoneApplicationPage GetActivePage(this Application application) { 
    PhoneApplicationPage content = null; 
    if (application != null) { 
     PhoneApplicationFrame rootVisual = application.RootVisual as PhoneApplicationFrame; 
     if (rootVisual != null) { 
      content = rootVisual.Content as PhoneApplicationPage; 
     } 
    } 
    return content; 
} 

然后,你可以这样做:

Application.Current.GetActivePage().Focus(); 
0

我会建议你选择,例如,你可以这样做:

private void YourTextBoxGotFocus(object sender, RoutedEventArgs e) 
     { 
      YourTextBox.IsEnabled = false; 
      YourTextBox.IsEnabled = true; 
     }