Tuesday, September 14, 2010

[silverlight] Always scrolling the scroll bar to the bottom of a TextBox

found this at http://www.gamedev.net/community/forums/topic.asp?topic_id=550283
very useful.

// If there is current text and it does not end in a newline, add one. 
if (!string.IsNullOrEmpty(outputWindow.Text) && !outputWindow.Text.EndsWith(Environment.NewLine)) 
{  
outputWindow.Text += Environment.NewLine; 
} 
// Append the text. 
outputWindow.Text += DateTime.Now.ToString(); 
// Set the selection to the end of the text, zero length. 
outputWindow.SelectionLength = 0; 
outputWindow.SelectionStart = outputWindow.Text.Length;

No comments:

Post a Comment