3

我在网格中包含的堆栈面板集合中有一堆控件。网格很长,超出了页面,所以我把它放到了滚动查看器中。一切正常,我可以上下滚动页面,直到键盘处于活动状态。一旦发生这种情况,当突出显示文本框时,我无法将内容一直滚动到底部。我可以滚动到一定程度,但不能一直向下滚动。难道我做错了什么?我的代码如下:

<ScrollViewer Margin="12,0,12,0" Grid.Row="1">
        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Height="837" Width="456">                
            <StackPanel HorizontalAlignment="Left" Width="450" Margin="0,63,0,405">
                <TextBlock Height="30" Name="tBlk_Username" Text="Display Name" />
                <TextBox Height="71" Name="tb_UserNameVal" Text="{Binding UserNameValue, Mode=TwoWay}" Width="452" />
                <TextBlock Height="30" Name="tBlk_Email" Text="Email" />
                <TextBox Height="71" Name="tb_EmailVal" Text="{Binding EmailValue, Mode=TwoWay}" Width="452" />
                <TextBlock Height="30" Name="tBlk_Message" Text="Message" />
                <TextBox Height="130" Name="tb_MessageVal" Text="{Binding MessageValue, Mode=TwoWay}" Width="452" />
            </StackPanel>
            <StackPanel Height="37" HorizontalAlignment="Left" Margin="0,519,0,0" Name="stackPanel2"
                        VerticalAlignment="Top" Width="450">
                <TextBlock Height="30" Name="tBlk_PicInfo" Text="Include a Photo" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" Height="90" HorizontalAlignment="Left" Margin="12,432,0,0"
                        Name="stackPanel1" VerticalAlignment="Top" Width="450" d:LayoutOverrides="GridBox">
                <TextBox Height="71" Name="tb_Location" Text="{Binding Location}" Width="367" IsReadOnly="True" />
                <Button Height="60" Name="btn_Clear" Width="60" BorderThickness="0" Background="{Binding LocationImage}" Style="{StaticResource LocationButtonStyle}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <GalaSoft_MvvmLight_Command:EventToCommand x:Name="ClearCommand" Command="{Binding ClearCommand}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Height="205" HorizontalAlignment="Left" Margin="12,556,0,0"
                        Name="stackPanel3" VerticalAlignment="Top" Width="452" d:LayoutOverrides="GridBox">
                <Image Name="img_FlickrPic" Stretch="Fill" Width="260" Source="{Binding Capture}" Margin="0,13,0,0" />
                <Button Name="btn_Capture" Width="90" Height="90" Margin="0,67,0,55" BorderThickness="0">
                    <Button.Background>
                        <ImageBrush ImageSource="/Images/camera.png" />
                    </Button.Background>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <GalaSoft_MvvmLight_Command:EventToCommand x:Name="CaptureClick" Command="{Binding CaptureCommand}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>                        
                </Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Height="100" HorizontalAlignment="Left"
                        Margin="4,763,0,0" Name="stackPanel4" VerticalAlignment="Top" Width="450" d:LayoutOverrides="GridBox">
                <Button Content="Submit" Height="71" Name="btn_Submit" Width="130" IsEnabled="{Binding SubmitEnabled}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <GalaSoft_MvvmLight_Command:EventToCommand x:Name="SubmitCommand" Command="{Binding SubmitCommand}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
            </StackPanel>
            <StackPanel Height="59" HorizontalAlignment="Left" Name="stackPanel5" VerticalAlignment="Top" Width="456" Orientation="Horizontal">
                <TextBlock FontFamily="{StaticResource HelveticaNeue}" Name="tBlk_StepConf" Text="Please share my " Width="150" TextAlignment="Center" Height="33" />
                <TextBlock FontFamily="{StaticResource HelveticaNeue}" Foreground="#FF00BCE4" Name="tBlk_StepConfCount" Text="{Binding StepVal}" Width="56" FontSize="34" TextAlignment="Center" VerticalAlignment="Top" />
                <TextBlock FontFamily="{StaticResource HelveticaNeue}" Name="tBlk_StepConfTrail" Text=" steps for water" Width="134" TextAlignment="Center" Height="40" />
            </StackPanel>
        </Grid>
    </ScrollViewer>
4

1 回答 1

0

问题是 ScrollViewer 不注意软输入面板(或键盘),所以它只能在键盘后面滚动,可以这么说。

一个简单的解决方案是在 ScrollViewer 的内容控件底部添加一个边距。

更长更复杂的解决方案是在显示 SIP 时添加边距。不幸的是,它没有任何事件,但我想当文本框获得或失去焦点时可以听到,并在文本框获得焦点时设置边距或在页面底部显示控件(因此显示 SIP)并在没有时隐藏它。

于 2012-09-09T14:28:41.140 回答