码迷,mamicode.com
首页 > Windows程序 > 详细

WPF窗口默认TextBox焦点

时间:2020-02-19 05:49:46      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:复制   nta   sdn   man   -name   str   tle   inpu   https   

原文:WPF窗口默认TextBox焦点

 当WPF窗口显示后 如果想设置某个输入框为默认焦点 使用 FocusManager

  1. <Grid FocusManager.FocusedElement="{Binding ElementName=inputbox}">
  2. <TextBox Name="inputbox" HorizontalAlignment="Left" Height="24" Margin="10,10,0,0"
  3. Text="{Binding SearchText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
  4. TextWrapping="Wrap" VerticalAlignment="Top" Width="161">
  5. <TextBox.InputBindings>
  6. <!--键盘事件绑定-->
  7. <KeyBinding Command="{Binding Search_Click}" Key="Enter"/>
  8. </TextBox.InputBindings>
  9. </TextBox>
  10. </Grid>

 

WPF窗口默认TextBox焦点

标签:复制   nta   sdn   man   -name   str   tle   inpu   https   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12329524.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!