我目前正在開發通用應用程序,但這裏有一個問題。我有用於用戶電話號碼的文本框的框架。 InputPane無法正常工作
所以,我想改變我的LayoutRoot(網格)的高度,以便它可以適應可用空間。
爲此,我使用了InputPane.GetForCurrentView().Showing
和InputPane.GetForCurrentView().Hiding
。 這是我的代碼。
public UserRegistrationAuthorization_PhoneNumber()
{
this.InitializeComponent();
LayoutRootInitialHeight = LayoutRoot.ActualHeight;
InputPane.GetForCurrentView().Showing += UserRegistrationAuthorization_PhoneNumber_Showing;
InputPane.GetForCurrentView().Hiding += UserRegistrationAuthorization_PhoneNumber_Hiding;
}
private void UserRegistrationAuthorization_PhoneNumber_Showing(InputPane sender, InputPaneVisibilityEventArgs args)
{
LayoutRoot.Height = LayoutRoot.ActualHeight - args.OccludedRect.Height;
LayoutRoot.VerticalAlignment = VerticalAlignment.Top;
args.EnsuredFocusedElementInView = true;
}
private void UserRegistrationAuthorization_PhoneNumber_Hiding(InputPane sender, InputPaneVisibilityEventArgs args)
{
// TODO: Get rid of that shit
LayoutRoot.Height = LayoutRootInitialHeight;
args.EnsuredFocusedElementInView = false;
}
當我點擊文本框鍵盤之外隱藏和離開後,在屏幕上的黑洞。 2
不過,最有意思的是,當我按我的Lumia物理後退按鈕,鍵盤通常隱藏和我的LayoutRoot獲取框架的初始高度。
這是一個錯誤還是我做錯了什麼?
感謝您的詳細答案! –