如何防止键盘在Windows应用商店中重叠控件

时间:2014-10-02 08:18:16

标签: c# xaml windows-store-apps

我在Windows商店应用程序中的一个页面有一些TextBox供用户填写,但是当键盘显示时,它会隐藏它背后的一些TextBox。

键盘显示时有没有办法拉出页面?或者至少将应用集中在焦点文本框上。

这是我拥有的XAML页面之一

<UserControl.Resources>
    <ResourceDictionary>
        <common:StringToValidityConverter x:Key="StringToValidityConverter" />
    </ResourceDictionary>
</UserControl.Resources>

<StackPanel>
    <StackPanel Style="{StaticResource SubHeaderStyle}">
        <Image Source="/Images/Contract/Billing.png" Style="{StaticResource SubHeaderImageStyle}" />
        <TextBlock x:Uid="Billing" Style="{StaticResource SubHeaderTextStyle}" />
        <Button Click="OnResetButtonClicked" Style="{StaticResource ResetButtonStyle}" />
    </StackPanel>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="50" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock x:Uid="AccountNumber" />
        <TextBox Grid.Column="1" Text="{Binding AccountNumber, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="BillingPeriod" Grid.Column="3" />
        <input:SfDatePicker Grid.Column="4" Value="{Binding BillingPeriod, Mode=TwoWay}" />

        <TextBlock x:Uid="AccountCategory" Grid.Row="1" />
        <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding AccountCategory, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="CompanyName" Grid.Row="1" Grid.Column="3"/>
        <TextBox Grid.Row="1" Grid.Column="4" Text="{Binding CompanyName, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="CompanyType" Grid.Row="2" />
        <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding CompanyType, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="VatNumber" Grid.Row="2" Grid.Column="3" />
        <TextBox Grid.Row="2" Grid.Column="4" Text="{Binding VatNumber, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <StackPanel Grid.Row="3" Orientation="Horizontal">
            <TextBlock x:Uid="RegistrationNumber" />
            <TextBlock Text=" 1" />
        </StackPanel>
        <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding RegistrationNumber1, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <StackPanel Grid.Row="3" Grid.Column="3" Orientation="Horizontal">
            <TextBlock x:Uid="RegistrationNumber" />
            <TextBlock Text=" 2" />
        </StackPanel>
        <TextBox Grid.Row="3" Grid.Column="5" Text="{Binding RegistrationNumber2, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="BusinessActivity" Grid.Row="4" />
        <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding BusinessActivity, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="NumberOfEmployees" Grid.Row="4" Grid.Column="3" />
        <TextBox Grid.Row="4" Grid.Column="4" Text="{Binding NumberOfEmployees, Mode=TwoWay}" Style="{StaticResource ShortTextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="Language" Grid.Row="5" />
        <TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Language, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="CorrespondanceLanguage" Grid.Row="5" Grid.Column="3" />
        <TextBox Grid.Row="5" Grid.Column="4" Text="{Binding CorrespondanceLanguage, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="LandlinePhone" Grid.Row="6" />
        <TextBox Grid.Row="6" Grid.Column="1" Text="{Binding LandlinePhone, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="MobilePhone" Grid.Row="6" Grid.Column="3" />
        <TextBox Grid.Row="6" Grid.Column="4" Text="{Binding MobilePhone, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />

        <TextBlock x:Uid="EmailAddress" Grid.Row="7" />
        <TextBox Grid.Row="7" Grid.Column="1" Text="{Binding EmailAddress, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                 common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />
    </Grid>
</StackPanel>

0 个答案:

没有答案