开发者

Silverligth 4 [XAML] - giving letters in a text a background color/highligth

I am making some things in silverligth with marked up text in XAML. Everything is going fine until i came up with this.

I am trying to give my text a background color but it says the property does not exist. the property for a foreground does exist.

is there a way to still give my text parts a background color?

image in link: http://img146.imageshack.u开发者_高级运维s/img146/537/highligths.png


This is one of those annoying Silverlight vs. WPF differences. Neither TextBlock nor Run elements provide a Background property in Silverlight. You need to wrap them in a Border:

<Border Background="Red">
  <TextBlock>Test please ignore</TextBlock>
</Border>

Thus it's annoyingly involved to do precisely what you want, but possible. If the text you want to display is not well known ahead of time, your best bet is to look at a third party RichTextBox control such as Telerik's RadRichTextBox.


Please tell me you did that with Textblock and Runs. I think the Run element can support foreground and background properties. I know you can twist the content to support both you just have to be clever about the controls inside the Textblock.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜