gpt4 book ai didi

c# - 在 WPF 中将焦点设置在文本框上

转载 作者:IT王子 更新时间:2023-10-29 03:36:15 26 4
gpt4 key购买 nike

如何在 WPF 中将焦点设置在 TextBox 元素上

我有这个代码:

txtCompanyID.Focusable = true;
txtCompanyID.Focus();

...但它不起作用。

有什么想法吗?

最佳答案

在 XAML 中:

<StackPanel FocusManager.FocusedElement="{Binding ElementName=Box}">
<TextBox Name="Box" />
</StackPanel>

关于c# - 在 WPF 中将焦点设置在文本框上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1345391/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com