询问者
WP7键盘弹起来后会遮住其他控件,有什么办法解决吗?不用ScrollViewer···

问题
全部回复
-
你好,
请具体解释一下当使用ScrollViewer的时候,你那边得到的效果是怎么样的,理想的效果又是怎样的?同时也请粘帖一下你那边相关的代码,以便我们帮你找到合适的解决方案。
使用 ScrollViewer ,一个textbox,下面一个button ,(为能观察到这个问题,将textbox 高度设大一点让button位于弹出键盘覆盖到的地方。 )
当点击textbox 会自动弹出键盘,这时button 很可能就被键盘盖住了。
最理想的效果即是,当键盘弹出,不管是那个输入框,整个页面只使用除去键盘显示剩于的屏幕空间
-
你好,
以下是一个例子,请参考
xaml
<!--ContentPanel - place additional content here--> <ScrollViewer x:Name="scroll" Grid.Row="1" Height="500" VerticalAlignment="Top"> <Grid x:Name="ContentPanel" > <TextBox Text="Hover" Height="202" HorizontalAlignment="Left" Margin="47,61,0,0" Name="toggleButton1" VerticalAlignment="Top" Width="347" GotFocus="toggleButton1_GotFocus" LostFocus="toggleButton1_LostFocus" /> <Button Content="Button" Height="87" HorizontalAlignment="Left" Margin="124,269,0,0" Name="button1" VerticalAlignment="Top" Width="210" /> </Grid> </ScrollViewer>
cs
private void toggleButton1_GotFocus(object sender, RoutedEventArgs e) { scroll.Height = 200;//缩短ScrollViewer高度,这样滑动即可看到页面下方的button } private void toggleButton1_LostFocus(object sender, RoutedEventArgs e) { scroll.Height = 500; }
- 已建议为答案 胡佳利 2012年8月9日 20:19