Wrapping text around an image or linking two text blocks in C # WPF

I am creating a program that displays text and an image in the same window. The image is in the upper left corner of the screen, and the text will start to the right of it, and then continue below the image.

I am currently trying to take two TextBlocks (one to the right of the image and one below both the image and the first text block) and want the text to continue from one block to another. This is the ideal approach, and if so, how do I do it? Is there a better / easier way than this, or can I do it with only one object? Thanks,

Andrew

+3
c # wpf textwrapping
source share
1 answer

I would not recommend using TextBlocks for this type of layout. As Cyrene suggests, FlowDocument is ideal for this type of design. Take a look at this XAML snippet and screenshot of a WPF application using a FlowDocument with a Paragraph element and a Floater element containing an image:

<Grid> <FlowDocumentScrollViewer> <FlowDocument> <Paragraph> <Floater Width="130" HorizontalAlignment="Left" Margin="0,0,5,5" Padding="3"> <BlockUIContainer> <Image Source="/FlowDocumentTest;component/dog.png" Width="100" /> </BlockUIContainer> </Floater> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse et diam felis. Vestibulum ac nisl mi. Etiam varius velit lobortis nibh vestibulum nec consequat velit pellentesque. Cras commodo libero placerat nulla dapibus eget porttitor ligula tempor. Donec nisl massa, congue et pretium sit amet, feugiat vel est. Nulla dapibus metus in justo pulvinar sit amet viverra lorem rhoncus. Integer placerat interdum massa et mattis.</Paragraph> </FlowDocument> </FlowDocumentScrollViewer> </Grid> 

alt text

+18
source share

All Articles