1

番号 123.456 (InputScope="Number") のテキスト ボックスがあるとします。

フォーカスを取得してタップすると、456 が自動選択されます。

これをキャンセルするプロパティが表示されません。隠された方法はありますか?

4

1 に答える 1

1

SelectionChangedイベントを処理することによって選択が行われるたびに、すべてを選択解除することができます。例えば

private void myTextbox_SelectionChanged(object sender, RoutedEventArgs e)
{
    //get the position the user clicked
    int start = myTextbox.SelectionStart;

    //detach this event handler so it's not fired when we clear the selection
    myTextbox.SelectionChanged -= myTextbox_SelectionChanged;

    //clear the selection but keep the cursor in the place it would've been
    myTextbox.Select(start, 0);

    //reattach the handler
    myTextbox.SelectionChanged += myTextbox_SelectionChanged;
}

これにより、テキストが選択されなくなります。ユーザーがテキストボックス内でタップした実際の位置を取得するには、Tapイベントを処理し、渡されたパラメーターのGetPosition()メソッドを使用できます。GestureEventArgs

于 2013-05-18T16:46:13.600 に答える