0

私は、ユーザーが個人の電話番号を入力するページを持っています。 TextBoxにフォーカスがあると、仮想キーボードが表示されますが、ユーザーが電話番号を入力して「次へ」緑色のボタン(スクリーンショットのロシア語についてはごめんね)をクリックすると、最初のクリックはボタンを通過してキーボードを閉じます次のクリックだけがクリックイベントをアクティブにします。 これを修正する方法はありますか? ページのフォーカス状態にはいくつかの問題があるかもしれませんが、私は正直に分かりません。ボタンが最初のクリックに対して応答しない

enter image description here

UPDATE: それがある場合、これは、私のページのXAML

<Grid x:Name="LayoutRoot" Style="{StaticResource GeneralAppBackground}"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="Auto" /> 
    </Grid.RowDefinitions> 

    // Control to show the loading state 
    <controls:LoadingPageState x:Name="LoadingGrid" Visibility="Collapsed" Grid.RowSpan="3" Canvas.ZIndex="1" TitleOfOperation="Проверка существования кошелька..." /> 
    <Grid Style="{StaticResource GeneralAppHeaderStyle}"> 
     <TextBlock Text="Введите номер телефона" FontWeight="Normal" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource PageHeaderTextBlockStyle}" /> 
    </Grid> 
    <Grid Grid.Row="1"> 
     <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="20,0,20,0"> 
      <TextBlock x:Uid="Greeting" Foreground="#979797" TextAlignment="Center" Margin="0,0,0,10" /> 
      <Grid Margin="0,0,0,5"> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="Auto" /> 
        <ColumnDefinition Width="*" /> 
       </Grid.ColumnDefinitions> 
       <TextBox Grid.Column="0" PlaceholderText="+7" FontSize="18" BorderThickness="0,0,0,2" BorderBrush="#979797" Background="Transparent" IsReadOnly="True" Margin="0,0,10,0" Template="{StaticResource DefaultTextBoxStyle}"/> 
       <TextBox x:Name="UserPhoneNumberInput" Grid.Column="1" IsTextPredictionEnabled="False" IsSpellCheckEnabled="False" PlaceholderText="777 123 12 12" FontSize="18" BorderThickness="0,0,0,2" BorderBrush="#979797" MaxLength="10" Background="Transparent" InputScope="TelephoneNumber" Template="{StaticResource DefaultTextBoxStyle}" TextChanged="UserPhoneNumberInput_TextChanged" /> 
      </Grid> 
      <TextBlock x:Name="HintText" TextWrapping="WrapWholeWords" Foreground="#979797" TextAlignment="Center"> 
       Ваш телефон будет использоваться в качестве номера кошелька 
      </TextBlock> 
     </StackPanel> 
    </Grid> 
    <Button x:Name="NextStepButton" Grid.Row="2" IsEnabled="False" Content="Далее" VerticalAlignment="Bottom" Style="{StaticResource WideGreenButtonStyle}" Click="NextStepButton_Click" /> 
</Grid> 

そして、ここでは、ボタンのクリックイベントのための私のC#コード

private void NextStepButton_Click(object sender, RoutedEventArgs e) 
    { 
     if (!UserPhoneNumberInput.Text.All(Char.IsDigit) || UserPhoneNumberInput.Text.Length == 0) 
     { 
      NotifyUser.ShowWrongPhoneNumberFormatMessage(); 
      return; 
     } 

     phoneNumber = Helpers.FormatNumber(UserPhoneNumberInput.Text); 

     // Activate the ContentLoading ring 
     LoadingGrid.Visibility = Visibility.Visible; 
     LoadingGrid.IsProgressRingActive = true; 

     CheckNumber(phoneNumber); 
    } 

そして、ここであります重要なのは、私の "LoadingGrid"のXAMLです。

<Grid x:Name="LayoutRoot" Background="#CC000000"> 
    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"> 
     <ProgressRing x:Name="ProgressRing" Width="50" Height="50" Foreground="White" IsActive="{x:Bind IsProgressRingActive, Mode=TwoWay}" /> 
     <TextBlock x:Name="OperationTitle" Text="{x:Bind TitleOfOperation, Mode=TwoWay}" TextAlignment="Center" FontSize="18" Foreground="White" Margin="0,20,0,0" /> 
    </StackPanel> 
</Grid> 
+0

コードを投稿するまで不明瞭です。 –

+0

@Rakitić私は自分のコードで質問を更新しました。 –

+0

@Henk Holterman、私はそうではないと思う。時にはボタンのクリックが正しく機能するからだ。おそらくこれは私のコードの問題ですが、どこにあるのかわかりません! –

答えて

3

これは仕様です。あなたはNextStepButtonボタンをクリックすると

UserPhoneNumberInput TextBoxのは、そのフォーカスを失った後、キーボードが自動的に消えます。ほとんどの場合、カスタムレイアウトテンプレートに応じて、NextStepButtonもわずかに下に移動します。マウスボタンを放すと(エミュレータを使用していると仮定した場合)、NextStepButtonはその時点では存在しません。そのため、をクリックしないでください。イベントをクリックします。ご存じのように、ボタンのデフォルトClickModeは、ClickMode.Releaseです。私は最近まったく同じ問題を抱えていました。

この現象を回避するには、IsTabStop = "False"をボタンのプロパティに追加してみてください。

+0

あなたの明確な説明に非常に感謝します!あなたの答えは私を大いに助けました。 –

関連する問題