private static void OnTextChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (args.OldValue != null) { EditableTextBlock control = (EditableTextBlock)obj; if (control.IsInEditMode) { RoutedPropertyChangedEventArgs <string> e = new RoutedPropertyChangedEventArgs <string>((string)args.OldValue, (string)args.NewValue, TextChangedEvent); control.OnTextChanged(e); control._pendingChanges = true; } else { (control as EditableTextBlock).Text = args.NewValue as string; TextBox txtBox = FindVisualChild <TextBox>(control); if (txtBox != null) { txtBox.Text = (string)args.NewValue; } TextBlock txt = FindVisualChild <TextBlock>(control); if (txt != null) { txt.Text = (string)args.NewValue; } } } }
private static String GetControlText(EditableTextBlock control) { TextBox txtBox = FindVisualChild <TextBox>(control); if (txtBox != null) { return(txtBox.Text); } TextBlock txt = FindVisualChild <TextBlock>(control); if (txt != null) { return(txt.Text); } return(null); }