Search code examples
wpfflowdocument

Is it possible to vertical align listitem marker in a flowdocument?


I want to to align listitem marker to the top, default is alignment to the bottom of the first block.

My faulty code:

<Grid>
    <FlowDocumentScrollViewer>
        <FlowDocument>
            <List MarkerStyle="Decimal">
                <ListItem>
                    <BlockUIContainer>
                        <Grid>
                            <Rectangle Height="100" Fill="HotPink" />
                            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Picture</TextBlock>
                        </Grid>
                    </BlockUIContainer>
                    <Paragraph>TextTextTextTextTextTextText</Paragraph>
                </ListItem>
            </List>
        </FlowDocument>
    </FlowDocumentScrollViewer>
</Grid>

Solution

  • <FlowDocumentScrollViewer>
        <FlowDocument>
            <List MarkerStyle="Decimal">
                <ListItem>
                    <BlockUIContainer/>     
                        <BlockUIContainer>
                            <Grid Margin="0,-10,0,0">
                                <Rectangle Height="100" Fill="HotPink" />
                                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Picture</TextBlock>
                            </Grid>
                        </BlockUIContainer>
                        <Paragraph>TextTextTextTextTextTextText</Paragraph>
                 </ListItem>
            </List>
        </FlowDocument>
    </FlowDocumentScrollViewer>