Drakestar
Drakestar

Reputation: 748

Can't explain leading whitespace in FlowDocument

I'm using a conventional FlowDocument setup with a Floater and a Run to wrap text around an image. I get a leading whitespace that I don't understand. Can anybody help? (Before anybody suggests removing the Run: I want to use an actual Run element here because I have situations where the text comes in via databinding).

<FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto">                
    <FlowDocument PagePadding="5" TextAlignment="Left">
        <Paragraph FontFamily="Segoe UI" FontSize="12">
            <Floater Width="32" HorizontalAlignment="Left" Margin="0,0,2,2" Padding="0">
                <BlockUIContainer>
                    <Image Width="28" Height="28" Source="../imgscr/BassClef_32x.png" />                           
                </BlockUIContainer>
            </Floater>
            <Run Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin et ante erat. Duis ut scelerisque nisl. Maecenas rutrum sapien vel dolor imperdiet egestas. Duis vel purus at leo hendrerit venenatis. Aenean nibh dui, ornare eu consequat nec, dapibus vel mauris. In bibendum urna efficitur ipsum auctor consequat. Phasellus nunc neque, mollis eget felis eu, placerat pharetra velit. Sed auctor posuere turpis vitae lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit." />
        </Paragraph>
    </FlowDocument>
</FlowDocumentScrollViewer>

The leading whitespace (notice it before the L in Lorem) is visible at runtime and in the visual XAML editor, so this looks like intended behavior. Can somebody explain why and how I fix this? I checked the whole visual tree via Snoop and can't find the cause.

Leading Whitespace - Why?

Upvotes: 1

Views: 246

Answers (1)

user3188639
user3188639

Reputation:

Remove a whitespace between end of Floater and Run, like this:

</Floater><Run Background="Red" 
                Text="Lorem ipsum dolor sit 

enter image description here

Upvotes: 5

Related Questions