I experienced a weird bug and am unable to solve it.
To reproduce:
1. Create new wpf project
2. Add richtextbox, name it e.g. "rtb"
3. Append a text with line break at the end 3 times. For example
- rtb.AppendText("lol\n");
- rtb.AppendText("lol\n");
- rtb.AppendText("lol\n");
5. Now clear the richtextbox before appending the lines:
- rtb.Document.Blocks.Clear();
- rtb.AppendText("lol\n");
- rtb.AppendText("lol\n");
- rtb.AppendText("lol\n");
lol
lol
lol
but this time
lollol
lol
so essentially the "\n" for the first "lol" was added after the next "lol", lol?
Do you know what's going on because I don't. I'd expect it to output
lol
lol
lol
and I don't see why clearing the text content makes the richtextbox behave like this. I guess it's a bug but I don't understand why it's happening or how can I solve this.
It can't be because of "rtb.Document.Blocks.Clear()" as I've tried other methods for clearing the richtextbox as well, like
- rtb.SelectAll();
- rtb.Selection.Text = "";
- rtb.Document.Blocks.Clear();
- rtb.AppendText("lol\nlol\nlol\n");
Dharmraj ThakurPosted Feb 1, 2018, 8:49 AM
Guest UserPosted Feb 1, 2018, 9:09 AM
Guest UserPosted Feb 1, 2018, 8:13 AM
Amit GuptaPosted Jan 31, 2018, 1:09 PM