在 C# WPF 中将文本环绕图像或链接两个 TextBlock
我正在创建一个在同一窗口中显示文本和图像的程序。图像位于屏幕的左上角,文本将从图像的右侧开始,然后继续向下延伸到图像下方。
目前,我正在尝试获取两个 TextBlock(一个位于图像右侧,一个位于图像和第一个文本块下方),并希望文本从一个块继续到另一个块。这是一种理想的方法吗?如果是的话,我会怎么做?有没有比这更好/更简单的方法,或者我可以只用一个对象来做到这一点?谢谢,
安德鲁
I am creating a program that shows text and an image in the same window. The Image is in the top-left corner of the screen and the Text will begin to the right of it, and then continue down below the image.
Currently, what I am trying is to take two TextBlocks (one to the right of the image and one below both the image and the first textblock) and want to have the text continue from one block to the other. Is this an ideal approach, and if so, how would I do it? Is there a better/easier way than this or can I do it with just one object? Thanks,
Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不建议使用 TextBlocks 来实现这种类型的布局。正如 Kieren 所建议的,FlowDocument 对于此类设计来说是理想的选择。使用带有 Paragraph 元素和包含图像的 Floater 元素的 FlowDocument 查看此 XAML 代码段和生成的 WPF 应用程序屏幕截图:
I would not recommend using TextBlocks to achieve this type of layout. As Kieren suggests, a FlowDocument would be ideal for this type of a design. Take a look at this XAML snippet and the resulting WPF app screenshot using a FlowDocument with a Paragraph element and a Floater element containing an image:
在后面的代码中尝试这个:
In code behind try this: