2012-09-11 36 views
4

正如标题所示,基本上我想要做与this for WPF相同的事情,但在Silverlight中取而代之。保持Silverlight文本框选择显示虽然没有重点?

但在我的TextBox.LostFocus事件中,没有e.Handled。我也尝试使用VisualStateManger.GoToState专注状态:

 VisualStateManager.GoToState(TextBox1, "Focused", false); 
     TextBox1.SelectionStart = 0; 
     TextBox1.SelectionLength = 3; 
     TextBox1.SelectionForeground = new SolidColorBrush(Colors.Orange); 

但它也不起作用。

有什么解决方法吗?

回答

0

以下代码将选择所有焦点。

TextBox1.Select(0, TextBox1.Text.Length); 

也许使用这种方法来设置选择。如果选择不会持续,请尝试将您的插入位置和长度存储在临时变量中(在自定义文本框类中)。

相关问题