WP7 virtual keypad does not work properly for textboxes inside a scrollviewer RRS feed

  • Pregunta

  • Hi All!

    The virtual keypad appears when clicking into a textbox, but instantly it dissapears. This happens because the textbox is inside a scrollviewer.



    lunes, 14 de marzo de 2011 21:07

Todas las respuestas

  • Hello pain.

    I guess it's a question.

    yes is possible, although not directly, if you write the XAML witch is the TexBox can help you better. it is possible that this changing behavior VisualState.

    David González
    Visita mi Blog en:
    martes, 15 de marzo de 2011 16:50
  • Hi David!

    This is just a small part of the XAML:

    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <Grid x:Name="grdBody" Grid.Row="2" Style="{StaticResource Body}">
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            <TextBlock Height="28" Grid.Row="0" Padding="10 0" Margin="5" x:Name="amountLabel" Text="{Binding Source={StaticResource Strings}, Path=amount}" Style="{StaticResource Label}" TextWrapping="Wrap" HorizontalAlignment="Stretch" />
            <cc:NumericTextbox Height="47" Grid.Row="1" x:Name="amountTextBox" Margin="5 5 5 5" MaxLength="10" IsDecimal="True" />

    Where NumericTextbox is defined as follows:

    <StackPanel Name="spBase">
        <Border Grid.Row="3" Background="White" Padding="0 0 0 0" Height="50" CornerRadius="14"  HorizontalAlignment="Stretch" BorderThickness="2" BorderBrush="Black"  MouseLeftButtonDown="Border_MouseLeftButtonDown" >
            <Canvas HorizontalAlignment="Stretch">
                <TextBox Background="Transparent" BorderThickness="0" Margin="0 -7" x:Name="tbTextbox" HorizontalAlignment="Stretch" KeyDown="tbTextbox_KeyDown" TextChanged="tbTextbox_TextChanged" Loaded="tbTextbox_Loaded" Style="{StaticResource Text}"  LostFocus="UserControl_LostFocus"/>
                <TextBlock x:Name="lbTextboxTooltip" HorizontalAlignment="Stretch" Margin="10 5 10 10" Style="{StaticResource BackText}"  />
                <TextBlock Margin="10 5 10 10" x:Name="tbTextboxDis" HorizontalAlignment="Stretch" Visibility="Collapsed" FontSize="22" Foreground="Black" />


    When I click in the "amountLabel", the virtual keypad appears and instantly dissapears, so I can not enter any number in the textbox. If I do not use the ScrollViewer, the virtual keypad works ok. The fact is we need the scrollviewer because we have something like ten textboxes and they do not fit all toghether in the screen.

    Thanks in advance!




    martes, 15 de marzo de 2011 18:21
  • Hi Dolor


    I tested the code, and in this case, there is no problem. remove all events test, it is possible that one of them do that behavior.

    the only thing I have not implemented, were the events so that proves to comment on the code of the events:

    - tbTextbox_KeyDown

    - tbTextbox_TextChanged

    - tbTextbox_Loaded

    - UserControl_LostFocus

    - Border_MouseLeftButtonDown


    have implemented many events and you may be on some, if you show them the code as I can help you optimize



    David González
    Visita mi Blog en:
    jueves, 17 de marzo de 2011 13:08