如何更改自定义范围的背景颜色?

时间:2016-12-10 10:43:45

标签: c# uwp richtextblock

我有RichTextBlock,其中包含一些自定义Span。我想在Right-Tapped事件被触发时更改该范围的Background颜色。我可以访问span,但它没有Background属性。

我该怎么办?

1 个答案:

答案 0 :(得分:0)

{"type": "FeatureCollection", "features": [ {"type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [[28.9681060393493, 41.007415243341], [28.9679918512905, 41.00729272796], [28.9679314102614, 41.0073143412354], [28.9680128968503, 41.007414681345], [28.9680423242404, 41.0074515099658], [ 28.9681094965952, 41.0074197765024], [28.9681060393493, 41.007415243341]] ] }, "properties": { "f1": 110006283, } } ] } Background中没有RichTextBlock属性我们无法将Span设置为Background

如果您希望Span有“背景”,您应该可以在enter image description here中添加SpanGrid

例如:

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> 用于显示数据,如果您要编辑文字,则应该可以使用InlineUIContainer

然后我们应该可以使用RichTextBlock来更改文本的背景。 RichEditBox中有类似的情况,请参阅。