I have a TextBox which has many lines of text, it's being update like this:
public void UpdateMessageBox(TextBox textBox, string text)
{
textBox.SelectionStart = 0;
textBox.SelectionLength = 0;
textBox.SelectedText = String.Format("{0:HH:mm:ss }", DateTime.Now) + text + "\n";
textBox.ScrollToHome();
}
Now I need to get a text from a line on which mouse middle button was clicked right away, not by selecting line via left click first.
private void textBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
{
e.MouseDevice.GetPosition(textBox) //what next?
}
}
How can I get textBox line and it's text from mouse position?