如何在文本段落中放置图像,以便图像与XAML中的文本内联?这是我想要实现的HTML的等价物:
<p>Your collection of things does not contain any items. Add a
new item by pressing <img src="add.png"> button and choosing
the options that you like lorem ipsum etc.</p>
我可以在Grid中放置TextBlock和Image并使用边距定位Image,但这非常脆弱,因为每当文本大小,文本长度或容器宽度发生变化时,都必须手动重新定位图像。最好让图像与文本一起流动,就像上面的HTML示例一样。
答案 0 :(得分:2)
您应该使用RichTextBox将图片内嵌到文字
<RichTextBox>
<Paragraph>
Displaying text with inline image
<InlineUIContainer>
<Image Source="add.png" Height="50" Width="50" />
</InlineUIContainer>
</Paragraph>
</RichTextBox>