繁体   English   中英

如何在WPF中从文本框中突出显示光标?

[英]How focus out the Cursor from textbox in wpf?

<Grid x:Name="LayoutRoot">
    <TextBox x:Name="TxtFocusOut" Height="74" Margin="186,149,225,0" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="26.667" TextChanged="TextBox_TextChanged"/>
</Grid>

private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
    {
        if(TxtFocusOut.Text.Length>=4)
        {
            MessageBox.Show("Four you typed four values");
        }
    }

在单击“确定”按钮后,光标应从texbox中移出。但是现在它在文本框中闪烁。我应该怎么做才能从testbox中移出焦点?

FocusManager.SetFocusedElement(AnotherElementID);  

通过这样做,这将松散其焦点,并且焦点可用于其他元素。
要么
Keyboard.ClearFocus();
http://msdn.microsoft.com/en-us/library/system.windows.input.keyboard.clearfocus.aspx
尝试任何这些

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM