Search Results

Search found 1 results on 1 pages for 'meleak'.

Page 1/1 | 1 

  • WPF: Invert OpacityMask

    - by Meleak
    Consider the following piece of Xaml <Grid Background="Blue"> <Border Width="100" Height="60" BorderBrush="Black" BorderThickness="2"> <Border Background="Red"> <Border.OpacityMask> <VisualBrush> <VisualBrush.Visual> <TextBlock Text="Text" Foreground="#FF000000" Background="#00000000"/> </VisualBrush.Visual> </VisualBrush> </Border.OpacityMask> </Border> </Border> </Grid> It will look like this because of the OpacityMask whos only non-transparent part is the Foreground of the TextBlock. Now if I switch the Colors for Foreground and Background in the TextBlock like this <TextBlock Text="Text" Foreground="#00000000" Background="#FF000000"/> I get this because the even though the Foreground is transparent the Background behind it is not, resulting in a useless OpacityMask :) Is there anyway I can get this? Basically an inverted OpacityMask The reason I'm asking this is because of the answer I made in this question, using the approach from this link. Even though it works, it feels very "hacky". Am I missing some other way to do this here? Update To clarify, even though my example is about a TextBlock, it could be anything. Ellipse/Image/Path etc. The feature I'm after is "Invert OpacityMask"

    Read the article

1