private void self_Loaded(object sender, RoutedEventArgs e) { tb.IsMouseCapturedChanged += new EventHandler(ImplementQuntity_IsMouseCapturedChanged); } private void ImplementQuntity_IsMouseCapturedChanged(object sender, DependencyPropertyChangedEventArgs e) { if (ImplementQuntity.Text.Length > 0) { int a = ImplementQuntity.Text.IndexOf("+", ImplementQuntity.SelectionStart); if (a > 0) { int b = ImplementQuntity.Text.LastIndexOf("+", a - 1); ImplementQuntity.Select(b + 1, a - b - 1); } else if (a == -1) { int b = ImplementQuntity.Text.LastIndexOf("+"); ImplementQuntity.Select(b + 1, ImplementQuntity.Text.Length); } double s = Convert.ToDouble(ImplementQuntity.SelectedText); if (FindTreeViewItem(element, s) != null) FindTreeViewItem(element, s).IsSelected = true; } }
解决方案
20