There are a lot of similiar questions over internet, on SO included, but proposed solutions doesn't work in my case.
Scenario : there is a log textbox in xaml
<TextBox Name="Status"
Margin="5"
Grid.Column="1"
Grid.Row="5"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="600"
Height="310"/>
There are methods in code-behind that do some work and add some multiline (maybe that's the problem?) messages into this textbox:
private static void DoSomeThings(TextBox textBox)
{
// do work
textBox.AppendText("Work finished
"); // better way than Text += according to msdn
// do more
textBox.AppendText("One more message
");
...
}
private static void DoSomething2(TextBox textBox)
{
// same as first method
}
Need to scroll to bottom of textbox after all actions take place. Tried ScrollToEnd(), ScrollToLine, wrapping textbox into ScrollViewer, Selection and Caret workarounds, attaching ScrollToEnd to TextChanged. None of this works, after execution lines that overflow textbox height still need to be scrolled to manually. Sorry for duplicate question, i guess i'm missing some minor issues that can be resolved quickly by someone that has fresh vision on the problem. Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…