locked
Detect virtual keyboard when focusing on a TextBox inside a userControl

    Question

  • I have a the Following FlipView in a winRT project.

    <FlipView x:Name="Flip" GotFocus="FlipView_GotFocus" Grid.Row="1" ItemsSource="{Binding Controls, ElementName=pageRoot}" SelectedItem="{Binding SelectedControl, ElementName=pageRoot, Mode=TwoWay}">
            <FlipView.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                        <ContentPresenter Content="{Binding}" />
                    </Grid>
                </DataTemplate>
            </FlipView.ItemTemplate>
        </FlipView>


    inside of it i will have several usercontrols that have some TextBox, but when i focus in one of the TextBox , the virtual Keyboard gets in front of the other TextBox, it doesnt "lift" the app like it normally does when i have a simple page with TextBoxs.

    Is there a way to detect Keyboard showing up and pulling the view of the app up?

    Here is one of the UserControl im using:

    <UserControl.Resources>
        <ResourceDictionary>
            <common:ByteArrayToBitmapImageConverter x:Key="ByteArrayToBitmapImageConverter" />
            <common:StringToValidityConverter x:Key="StringToValidityConverter" />
        </ResourceDictionary>
    </UserControl.Resources>
    
    <StackPanel>
        <StackPanel Style="{StaticResource SubHeaderStyle}">
            <Image Source="/Images/Contract/Sales.png" Style="{StaticResource SubHeaderImageStyle}" />
            <TextBlock x:Uid="Sale" Style="{StaticResource SubHeaderTextStyle}" />
        </StackPanel>
    
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="50" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
    
            <Image Grid.RowSpan="6" Width="300" Source="{Binding Picture, Converter={StaticResource ByteArrayToBitmapImageConverter}}" />
    
            <TextBlock x:Uid="SalesOffice" Grid.Row="1" Grid.Column="2" />
            <TextBox Grid.Row="1" Grid.Column="3" Text="{Binding Office, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                     common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />
    
            <TextBlock x:Uid="SalesAgent" Grid.Row="2" Grid.Column="2" />
            <TextBox Grid.Row="2" Grid.Column="3" Text="{Binding AgentName, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                     common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />
    
            <TextBlock x:Uid="MobilePhone" Grid.Row="3" Grid.Column="2" />
            <TextBox Grid.Row="3" Grid.Column="3" Text="{Binding MobilePhone, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                     common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" InputScope="Number" />
    
            <TextBlock x:Uid="EmailAddress" Grid.Row="4" Grid.Column="2" />
            <TextBox Grid.Row="4" Grid.Column="3" Text="{Binding EmailAddress, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                     common:TextBoxBehavior.Validity="{Binding Text, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToValidityConverter}}" />
        </Grid>
    </StackPanel>

    Edit: seems that i can detect the keyboard with

    Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing
    Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hidding

    now i just need to learn how to pull my view up.


    • Edited by Thought2 Monday, October 20, 2014 10:26 AM
    Monday, October 20, 2014 8:47 AM

Answers