private int GetTextLengthIncludingNewLineCompensation() { var text = INTERNAL_HtmlDomManager.GetTextBoxText(this.INTERNAL_InnerDomElement); if (!Host.AcceptsReturn) { text = text.Replace("\n", "").Replace("\r", ""); } return(text.Length); //this is just assuming but since INTERNAL_HtmlDomManager.GetTextBoxText makes sure all new lines are "\r\n" it should be correct. }
private void TextAreaValueChanged() { //we get the value: if (INTERNAL_VisualTreeManager.IsElementInVisualTree(this)) { var text = INTERNAL_HtmlDomManager.GetTextBoxText(this.INTERNAL_InnerDomElement) ?? string.Empty; if (!this.Host.AcceptsReturn) // This is just in case the user managed to enter multi-line text in a single-line textbox. It can happen (due to a bug) when pasting multi-line text under Interned Explorer 10. { text = text.Replace("\n", "").Replace("\r", ""); } _isUpdatingDOM = true; try { Host.SetCurrentValue(TextBox.TextProperty, text); //we call SetCurrentValue directly to avoid replacing the BindingExpression } finally { _isUpdatingDOM = false; } } }