Reputation: 596
Is it possible to make a run span the entire width of a TextBlock
so the background looks natural and not just on the text of the run?
Another issue with the first image is that there are (unwanted) white lines between certain Runs
(in this case "test" and "1"). My current code is:
Run r = new Run("You: " + SendMessageBox.Text + "\n");
r.Background = Brushes.LightBlue;
ChatHistory.Inlines.Add(r);
Upvotes: 0
Views: 202
Reputation: 169160
Is it possible to make a run span the entire width of a TextBlock so the background looks natural and not just on the text of the run?
No, you should add another TextBlock
element for each line:
TextBlock t = new TextBlock() { Text = "You: " + SendMessageBox.Text };
t.Background = Brushes.LightBlue;
ChatHistory.Children.Add(t);
ChatHistory
could for example be a StackPanel
:
Upvotes: 1