Reputation: 640
Currently I am working on windows phone 8.
When a textbox get focus in popup window it hide under the keyboard. I've tried subtracting the keyboard height from the VerticalOffset of popup window. But still the textbox is hiding under the keyboard because of the suggestion bar of the keyboard. Is there any way to get the height of keyboard's suggestion bar?
Thanks!!!
Upvotes: 1
Views: 1085
Reputation: 21889
Not in a Windows Phone 8 Silverlight app
If you upgrade to a Windows Phone 8.1 Silverlight app (or Runtime, but that's a bigger update) then you can use the InputPane class and examine its OccludedRect property in the Showing event.
This will fire whenever the keyboard changes what it covers, so you'll get the event once when the keyboard first opens and then again when the suggestion bar slides up.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing += MainPage_Showing;
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding += MainPage_Hiding;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing -= MainPage_Showing;
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding -= MainPage_Hiding;
}
void MainPage_Hiding(Windows.UI.ViewManagement.InputPane sender, Windows.UI.ViewManagement.InputPaneVisibilityEventArgs args)
{
Debug.WriteLine("Hiding and occluding {0}", sender.OccludedRect.Height);
}
void MainPage_Showing(Windows.UI.ViewManagement.InputPane sender, Windows.UI.ViewManagement.InputPaneVisibilityEventArgs args)
{
Debug.WriteLine("Showing and occluding {0}", sender.OccludedRect.Height);
}
Depending on your layout this may not be necessary on WP8.1. I tested a WP8 app on the WP8.1 emulator and the TextBoxes in my Popup slid out of the way of the suggestion bar as well as out of the way of the keyboard. If your layout is complex enough that doesn't work (e.g. if you need to move things below the focused TextBox as well) then you can handle Showing to move things yourself and then set InputPaneVisibilityEventArgs.EnsuredFocusedElementInView to let the InputPane not to also move things itself.
Upvotes: 5