Question

I have a semi transparent grid on a window . I have placed a button in grid cell.

now I want to be able to set the button text transparent, but not background ie., I want to set some background color to button and I want to be able to see through the button text.

Please somebody could help me on this.

Was it helpful?

Solution

I am a bit confused what you mean to acquire but if you want to be able to read across text you can cut it out. To do this you create for instance a square, put a text into it and cut out this text (for instance in gimp) so you will obtain a png file which looks like first picture (at first glance foreground reminds white but it is transparent). Then you add picture to project and

  <Button Opacity="1" Background="Goldenrod" Width="100" Height="100">
        <Button.OpacityMask>
            <ImageBrush ImageSource="fileWithText.png"/>
        </Button.OpacityMask>
    </Button>

The second picture depicts result. Background of grid is set to blue what we can presume thanks to text which is cut out. It is not efficient way out since not everything can be done only in WPF but I hope you will take advantage of it.
enter image description here enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top