【问题标题】:How to move focus from textbox to textbox int contentcontrol in wpf?如何将焦点从文本框移动到 wpf 中的文本框 int contentcontrol?
【发布时间】:2021-01-20 05:21:29
【问题描述】:

我想将焦点从标题文本框移动到 WPF 中 ContentControl 中的文本框。 但是任何命令都不起作用。 如何移动焦点?

    <TextBox
        Grid.Row="0"
        MinWidth="200"
        Name="Title"
        VerticalContentAlignment="Center"
        mahApps:TextBoxHelper.ClearTextButton="True"
        mahApps:TextBoxHelper.Watermark="Task Title"
        Text="{Binding Title, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

    <StackPanel
        Grid.Row="1"
        Margin="0,5,0,5"
        Background="White">
        <ContentControl
            MinHeight="55"
            Margin="5"
            Content="{Binding CreateTaskControl}" />
    </StackPanel>

【问题讨论】:

    标签: wpf xaml focus contentcontrol


    【解决方案1】:

    您可以使用Focusable="True"KeyboardNavigation.TabIndex="1" 当然,如果 TabIndex 你没有使用它。

    此代码Focusable="True"KeyboardNavigation.TabIndex="1" 用于不接受TabIndex 元素的地方,例如TextBlock

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多