WPF transparent text with opaque background

后端 未结 2 817
南笙
南笙 2021-01-26 16:44

I need transparent text with opaque background with WPF/XAML. Is that possible?

Here is an example, but I don\'t use css: css, transparent text with opaque background

2条回答
  •  旧时难觅i
    2021-01-26 17:27

    You can set it using the Opacity property on the SolidColorBrush. It takes values from 0 to 1. Where 0 is complete transparency and 1 complete opacity. But if you set the text transparent then what you will see is the background of the text box. In the example I've set partial opacity so you can see the text is greyish.

    
        
            
        
    
    

    Other thing to get the transparency and see the background of the control beneath the text block is to set transparent foreground and partially transparent background.

提交回复
热议问题