我有一个RichTextBlock包含一些自定义的Span. 我想在Right-Tapped事件触发时更改该Background跨度的颜色。我可以访问它,span但它没有Background属性。
我该怎么做?
我有一个RichTextBlock包含一些自定义的Span. 我想在Right-Tapped事件触发时更改该Background跨度的颜色。我可以访问它,span但它没有Background属性。
我该怎么做?
中没有Background属性RichTextBlock,Span我们无法将 设置Background为Span。
Grid如果你想让 Span 有“背景” ,你应该可以StackPanel在InlineUIContainer.
例如:
<RichTextBlock HorizontalAlignment="Center" VerticalAlignment="Center">
<Paragraph>
<InlineUIContainer>
<Grid Background="Blue">
<RichTextBlock>
<Paragraph>
<Span>This is
<Bold>mixed content</Bold> with multiple text areas
<Italic>and inlines</Italic> .
</Span>
</Paragraph>
</RichTextBlock>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
<Span>This is
<Bold>mixed content</Bold> with multiple text areas
<Italic>and inlines</Italic> .
</Span>
</Paragraph>
</RichTextBlock>
也RichTextBlock用于显示数据,如果你想编辑文本,你应该可以使用RichEditBox.
那么我们应该可以使用ITextRange.CharacterFormat.BackgroundColorText来改变背景了。stackoverflow中也有类似的情况,请参考。