2014-10-20 3 views
0

내부의 텍스트 상자에 초점을 때 내가 어떤 텍스트 상자가 몇 가지 추가 된 UserControls을하는 winRT 프로젝트 그것의 내부UserControl이

<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> 

에 뒤에 오는 FlipView이 가상 키보드를 감지,하지만 난 하나에 초점을 맞출 때 TextBox의 가상 키보드가 다른 TextBox 앞에 오면 TextBox가있는 간단한 페이지가있을 때 평소처럼 "리프트"하지 않습니다.

키보드가 나타나서 앱보기를 위로 올려 놓는 것을 감지하는 방법이 있습니까? 여기

<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> 

를 사용하여 UserControl을 메신저 중 하나이며, 여기가 App when Keyboard is up

편집 모습입니다 : 내가

Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing 
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hidding 
와 키보드를 감지 할 수있는 것

이제 나는 내 견해를 끌어 올리는 법을 배울 필요가 있습니다.

+0

이 게시물은을 도왔습니다. https://social.msdn.microsoft.com/forums/windowsapps/en-us/7349d01d-dc0e-4e1c-9327-df90e00fbebf/how-to-handle-the-appearance-of-the -onscreen-keyboard – Ric

답변

0

알다시피 InputPane의 표시 및 숨기기 이벤트를 사용하여 InputPane의 가시성 변경 사항을 감지 할 수 있습니다. InputPaneVisibilityEventArgs에는 처리 할 OccludedRect가 포함되어 있으므로 페이지에 RenderTransform을 적용하여 변환 할 수 있습니다.

<Page.RenderTransform> 
    <CompositeTransform x:Name="pageTransform"/> 
</Page.RenderTransform> 

그리고 고통스럽게 순진 구현 : 현실에서

void Page_Showing(InputPane sender, InputPaneVisibilityEventArgs args) 
{ 
    // We probably want something more sophisticated to make sure the 
    // focus control and any dependencies are in view 
    pageTransform.TranslateY -= args.OccludedRect.Height; 
    // Tell the InputPane we already handled things so it doesn't move the page again 
    args.EnsuredFocusedElementInView = true; 
} 

void Page_Hiding(InputPane sender, InputPaneVisibilityEventArgs args) 
{ 
    pageTransform.TranslateY = 0; 
    args.EnsuredFocusedElementInView = true; 
} 

당신이 필요한 컨트롤이보기에 있는지 확인하기 위해 수학을 할 수 있습니다. 애니메이션을 사용하여 이동을보다 부드럽게 할 수 있습니다. 더 창의적으로 만들고 싶다면보다 친숙한 레이아웃으로 편집 할 수있는 필수 필드가있는 새로운 비주얼 상태로 전환 할 수 있습니다. 귀하의 UserControl 경우에는 페이지가 아닌 컨트롤 만 이동할 수 있습니다.

소프트 키보드 동작이 윈도우 응용 프로그램과 조금씩 다르기 때문에 Windows 10 데스크톱에서도 테스트 해보십시오.

관련 문제