private static SelectedTextChanged ( |
||
obj | ||
e | System.Windows.DependencyPropertyChangedEventArgs | |
return | void |
private static void SelectedTextChanged( DependencyObject obj, DependencyPropertyChangedEventArgs e )
{
TextBox tb = obj as TextBox;
if( tb != null )
{
if( e.OldValue == null && e.NewValue != null )
{
tb.SelectionChanged += tb_SelectionChanged;
}
else if( e.OldValue != null && e.NewValue == null )
{
tb.SelectionChanged -= tb_SelectionChanged;
}
string newValue = e.NewValue as string;
if( newValue != null && newValue != tb.SelectedText )
{
tb.SelectedText = newValue as string;
}
}
}