wpf - TextBlock TextWrapping not wrapping -
wpf - TextBlock TextWrapping not wrapping -
when place textblock within of horizontally aligned stackpanel not wrap. realize because available width of stackpanel positiveinfinity there workarounds?
my layout much more complicated sample cannot remove stackpanel or horizontal orientation. tried reproduce simplest possible illustration exhibits behavior.
<stackpanel orientation="horizontal"> <rectangle width="50" height="50" fill="blue" verticalalignment="top" /> <rectangle width="50" height="50" fill="red" verticalalignment="top" /> <textblock textwrapping="wrap" text="lorem ipsum dolor sit down amet, consectetur adipiscing elit. phasellus leo lectus, viverra ut lobortis vel, mollis eget lectus. suspendisse laoreet consequat ultrices. curabitur ultricies, tortor feugiat porttitor faucibus, lorem eros pretium nisl, european union ullamcorper mauris tortor sit down amet augue." /> </stackpanel> update: width of textblock must dynamic. need flow window resized.
update 2: added element stackpanel because need children laid out horizontally.
update 3 (solution): replaced stackpanel dockpanel.
<dockpanel> <dockpanel dockpanel.dock="top"> <rectangle width="50" height="50" fill="blue" verticalalignment="top" dockpanel.dock="left" /> <rectangle width="50" height="50" fill="red" verticalalignment="top" dockpanel.dock="left" /> <textblock textwrapping="wrap" text="lorem ipsum dolor sit down amet, consectetur adipiscing elit. phasellus leo lectus, viverra ut lobortis vel, mollis eget lectus. suspendisse laoreet consequat ultrices. curabitur ultricies, tortor feugiat porttitor faucibus, lorem eros pretium nisl, european union ullamcorper mauris tortor sit down amet augue." /> </dockpanel> </dockpanel>
it's because you're using horizontal orientation on stackpanel. means stackpanel giving total width each kid control, , laying them out horizontally - if means exceeding bounded/visible width. because there's nil constrain width of textblock, doesn't wrap.
if switch vertical orientation wrapping works, i'm guessing there's reason specifying otherwise. can show layout you're trying achieve?
wpf xaml
Comments
Post a Comment