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

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”
You can use my
HollowTextBlockwhich is different answer to the same question:Update:
Here is a more fleshed out version of
HollowTextBlockwith proper measure capability, property value inheritance for the usual text properties, and a newVerticalTextAlignmentproperty for centering the text vertically in it’s allocated space: