gpt4 book ai didi

wpf - 如何仅在XAML中设置自动对焦?

转载 作者:行者123 更新时间:2023-12-03 10:23:55 25 4
gpt4 key购买 nike

是否可以在xaml文件中的文本框中设置自动对焦?

<Window x:Class="WpfApplication1.Views.Test1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="100"
Width="210"
WindowStartupLocation="CenterOwner"
ShowInTaskbar="False"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
ResizeMode="CanResizeWithGrip">
<TextBox HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap" AcceptsReturn="True" Text="{Binding Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Window>

最佳答案

<TextBox FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}" />

关于wpf - 如何仅在XAML中设置自动对焦?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11246554/

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