This question dường như được yêu cầu cho một cái gì đó tương tự với những gì bạn muốn. Câu trả lời here sẽ chứng minh một giải pháp cho những gì bạn mong muốn.
Một bản tóm tắt của câu trả lời là, sử dụng một FlowDocument
như ví dụ sau:
<FlowDocument>
<Paragraph>
<Floater HorizontalAlignment="Left">
<BlockUIContainer>
<Image Source="/FlowDocumentTest;component/dog.png" Width="100" />
</BlockUIContainer>
</Floater>
Here is where the text goes to wrap around the image.
</Paragraph>
</FlowDocument>
Cập nhật
Như bang câu hỏi của bạn, bây giờ bạn đang sử dụng một số mã C# để tạo TextBlock/Run Các phần tử, cả hai có thể là con của đối tượng Đoạn. Vì vậy, chỉ đơn giản là tên của bạn Paragraph
như vậy:
<FlowDocument>
<Paragraph x:Name="textPara">
<Floater HorizontalAlignment="Left">
<BlockUIContainer>
<Image Source="/FlowDocumentTest;component/dog.png" Width="100" />
</BlockUIContainer>
</Floater>
</Paragraph>
</FlowDocument>
Sau đó, trong C#, thêm tạo TextBlock
của bạn hoặc Run
s đến Inlines
tài sản của textPara, tức là
var runToInsert = new Run("Some text to display");
textPara.Inlines.InsertAfter(textPara.Inlines.FirstInline, runToInsert);
Tại chỗ trên! Đồng thời xem [this] (http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.richtextblockoverflow (v = win.10) .aspx) – wpfwannabe