David Sherret
David Sherret

Reputation: 106710

"float: left" Behaviour in WPF

Is it possible, in WPF, to have an image on the left side of a container, then to have a wrapping textblock to stay beside the image then wraps down below the image once the height of the textblock exceeds the height of the image? This kind of behaviour is similar to float: left; in css, for example doing:

    <img src="..." style="float: left;">Some text here that eventually wraps below the image once this text exceeds the image height

...but in WPF. Is this possible? I'm binding from a database so I don't want to split up the textblock.

Upvotes: 2

Views: 3022

Answers (1)

Joe Castro
Joe Castro

Reputation: 2201

There isn't a way to composite WPF panels to get this behavior without splitting your text across multiple controls, but FlowDocument has this functionality via Floaters.

http://blogs.msdn.com/b/llobo/archive/2005/11/20/floaters.aspx

or

http://msdn.microsoft.com/en-us/magazine/cc163371.aspx

It may take more work to get the text from your db into the FlowDocument structure, and FlowDocument is pretty heavy if you were just using TextBlocks before, but it will probably give what you want. Without more context I can't say.

Upvotes: 2

Related Questions