Mike Corcoran
Mike Corcoran

Reputation: 14565

preserving whitespace in/around nested Bold tags

I have some xaml code for a silverlight project sort of like below:

<Grid>
    <RichTextBox>
        <Paragraph>
            <Bold>Note: </Bold>This is an important message!
        </Paragraph>
    </RichTextBox>
</Grid>

The problem is that regardless of where I put the whitespace in/around the Bold tag, i can't get a space before the 'T' in 'This'. Is there a more elegant solution than just using the xml:space="preserve" property on the parent tag? Because then I have to remove all tabbing before the tags with this issue, which sort of destroys the hierarchical view of the xml itself.

To be clear, I know this solution below works:

    <Grid>
        <RichTextBox>
            <Paragraph xml:space="preserve">
<Bold>Note:</Bold> This is an important message!
            </Paragraph>
        </RichTextBox>
    </Grid>

But i'm interested in knowing if there is a cleaner way to accomplish the same thing

Upvotes: 0

Views: 241

Answers (1)

Ben
Ben

Reputation: 35613

How about

<Grid>
    <RichTextBox>
        <Paragraph>
            <Bold xml:space="preserve">Note: </Bold>This is an important message!
        </Paragraph>
    </RichTextBox>
</Grid>

Makes it a bit more obvious where you need space preserved?

Upvotes: 1

Related Questions