WPF flow document TextRange doesn't replace existing content right
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Description
## Current Situation
When writing two or more [``](https://learn.microsoft.com/en-us/dotnet/api/system.windows.documents.section) elements to a [`TextRange`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.documents.textrange) object, supposed to replace the **whole flow document**, existing [``](https://learn.microsoft.com/en-us/dotnet/api/system.windows.documents.section) objects in a flow document control are not getting replaced. Instead, the new sections are *appended* to the existing sections:

## Desired Situation
When replacing Flow Document content in a Flow Document control using …
```xaml
new TextRange(TextBox.Document.ContentStart, TextBox.Document.ContentEnd).Load(ms, DataFormats.Xaml);
```
… *all* previous content should be replaced.
## Reproduction Steps
Please refer to this MRE for details:
https://github.com/SetTrend/WpfFlowDocumentFlaw
### Impact
**Can't use.**
### Configuration
- .NET 9.0
- Windows 10x64
Contributor guide
Assessment
This issue has not been assessed yet.