我创建了一个简单的测试应用程序来复制我看到的问题,但无法解决问题 . 我有一个基本的Windows应用商店应用程序,其中包含ItemsControl中包含的TextBox的平面列表 . 该列表足够长,当Bottom TextBox具有焦点时,它被虚拟键盘遮挡,整个视图将自动向上滚动以确保TextBox在使用键盘时可见 .
但是,如果ItemsControl托管在FlipView或GridView而不是简单的Grid中,如下所示,则不会发生自动垂直滚动,并且底部元素仍然被虚拟键盘遮挡 . 这似乎是由于Parent控件包含一个ScrollViewer,它似乎完全覆盖了默认的有用视图滚动行为 .
问题是如何重新启用此行为?我尝试以我自己的风格删除ScrollViewer,但也意味着FlipView不再用作FlipView .
<Grid>
<ItemsControl Width="200">
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Test"></TextBox>
<TextBox Text="Hidden by VKD"></TextBox>
</ItemsControl>
</Grid>
2 回答
我遇到了同样的问题并找到了引起问题的元素:它是
VirtualizingStackPanel
,在许多ItemsControls
中用作默认的Items Panel . 如果将其更改为正常StackPanel
,则弹出虚拟键盘时会正确转换相应的输入控件 .详情请见:Why is my text box contained in a FlipView obscured by the soft keyboard when it pops up?
也许您可以在键盘出现时自己移动TextBox?这个样本很有希望:
Responding to the appearance of the on-screen keyboard sample