【问题标题】:Image inline with text in XAML与 XAML 中的文本内联的图像
【发布时间】:2014-10-20 12:44:05
【问题描述】:

如何在文本段落中放置图像,以使图像与 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 并使用边距定位图像,但这非常脆弱,因为每次容器的文本大小、文本长度或宽度发生变化时,都必须手动重新定位图像。最好让图像与文本一起流动,就像上面的 HTML 示例一样。

【问题讨论】:

    标签: xaml windows-phone


    【解决方案1】:

    您应该使用RichTextBox 将图像与文本内联

    <RichTextBox>
        <Paragraph>
            Displaying text with inline image
            <InlineUIContainer>
                <Image Source="add.png" Height="50" Width="50" />
            </InlineUIContainer>            
        </Paragraph>
    </RichTextBox>
    

    【讨论】:

    • 我很惊讶我找不到这个!问题已解决,谢谢!
    • 如何在富文本块中绑定图片url
    • @SureshBalaraman Source="{Binding Image}" 在这种情况下不起作用吗?
    猜你喜欢
    • 1970-01-01
    • 2015-11-04
    • 2022-06-10
    • 1970-01-01
    • 2014-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-19
    相关资源
    最近更新 更多