2

以下に示すように、私はRadioButtonTextBox内部のものを持っていStackPanelます:

  <StackPanel Orientation="Horizontal">
        <RadioButton x:Name="rbSelectedQuantity" GroupName="CardQuantity"
          FontSize="14" Margin="5"
          Content="Selected Quantity">
        </RadioButton>

        <TextBox x:Name="txtSelectedQuantity" Width="50" Margin="5" TextAlignment="Right"
        Text="0"></TextBox>
  </StackPanel>

これが私のシナリオです。TextBox内をクリックすると、ラジオボタンが自動的にチェックされます。

これはどのようにすればよいですか?

4

1 に答える 1

3

GotFocusTextBox のイベントを処理し、RadioButton IsCheckedプロパティをTrue

private void txtSelectedQuantity_GotFocus(object sender, RoutedEventArgs e)
    {
        rbSelectedQuantity.IsChecked = True;
    }
于 2013-01-29T10:26:21.973 に答える