0

我有一些用于 Silverlight 项目的 xaml 代码,如下所示:

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

问题是,无论我在粗体标签中/周围放置空格的位置,我都无法在“This”中的“T”之前获得空格。有没有比仅在父标签上使用 xml:space="preserve" 属性更优雅的解决方案?因为那时我必须删除带有此问题的标签之前的所有制表符,这会破坏 xml 本身的分层视图。

需要明确的是,我知道以下解决方案有效:

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

但我很想知道是否有更清洁的方法来完成同样的事情

4

1 回答 1

1

怎么样

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

让您需要保留空间的地方更加明显?

于 2012-05-04T08:53:12.270 回答