How to adjust screen when keyboard open in windows phone 8?

怎甘沉沦 提交于 2019-12-06 10:25:19

问题


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 :

  1. Tap in xaml will be replaced by Tapped.
  2. ((App)Application.Current).RootFrame.RenderTransform = new CompositeTransform(); will be replaced by

    Window.Current.Content.RenderTransform = new CompositeTransform();

  3. 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

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