2
我有一个RichTextBlock
,其中包含一些自定义Span
。我想要在发生Right-Tapped
事件时更改该跨度的Background
颜色。我可以访问该span
但它没有Background
属性。如何更改自定义跨度的背景颜色?
我该怎么办?
我有一个RichTextBlock
,其中包含一些自定义Span
。我想要在发生Right-Tapped
事件时更改该跨度的Background
颜色。我可以访问该span
但它没有Background
属性。如何更改自定义跨度的背景颜色?
我该怎么办?
有一个在RichTextBlock
和Span
没有Background
的性质,我们不能设置Background
到Span
。
如果您希望量程具有“背景”,您应该能够在InlineUIContainer
中添加Grid
或StackPanel
。
例如:
<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.BackgroundColor
来更改文本的背景。 stackoverflow有类似的情况,请参考。
有没有更新?我的答案解决了你的问题吗? –