问题
I am working in Windows phone 8. In One of the pages of my app there is a LongListSelector
and under it there is a TextBox
. When the TextBox
get focused then keyboard is opened. As the keyboard is opened then the LongListSelector
is shifted up by keyboard height. If I maintain the margin of the LongListSelector
by keyboard's offset then some of the items of LongListSelector
go under the keyboard.
All I want to do is when keyboard is shown then margin will be updated and the previous focused item of the LongListSelector
should not go under keyboard. Here I don't want to use ScrollTo()
function to scroll a specific item of LongListSelector
.
Any suggestion or help will be appreciated.
回答1:
Here is an example of workaround. Though this code is for WP8. You will have to make some changes to make this working for WP8.1 like :
- Tap in xaml will be replaced by Tapped.
((App)Application.Current).RootFrame.RenderTransform = new CompositeTransform();
will be replaced byWindow.Current.Content.RenderTransform = new CompositeTransform();
Dispatcher.BeginInvoke(() => {}
will be replaced by
CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{}
let me know if you face any issue.
来源:https://stackoverflow.com/questions/30779407/how-to-adjust-screen-when-keyboard-open-in-windows-phone-8