Answered by:
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
-
Hello Thought2,
To pull the view up, you should handle the
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hidding
Events.
You can find some sample code in the thread at [1].Regards,
Bo Liu
Developer-Hotline for MSDN Online Germany
Disclaimer:
Please take into consideration, that further inquiries cannot or will be answered with delay.
For further information please contact us per telephone through the MSDN-Entwickler-Hotline: http://www.msdn-online.de/Hotline
For this post by the MSDN-Entwickler-Hotline the following terms and conditions apply: Trademarks, Privacy as well as the separate terms of use for the MSDN-Entwickler-Hotline.- Marked as answer by Thought2 Monday, October 20, 2014 1:44 PM
Monday, October 20, 2014 12:17 PM