Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 在叠加WPF中制作透明孔_.net_Wpf_Wpf Controls - Fatal编程技术网

.net 在叠加WPF中制作透明孔

.net 在叠加WPF中制作透明孔,.net,wpf,wpf-controls,.net,Wpf,Wpf Controls,我试图在WPF中复制下面的效果。我有一个网格控件,其中的边框背景色为#000000,不透明度为0.7,还有一个像这样的内容演示器 <Grid> <Border Background="#000000" Opacity="0.7" /> <ContentPresenter ... /> </Grid> 我在控件的内容中放置了一个椭圆,试图获得效果,但我已经到达了一个路障 <Control:SomeControl>

我试图在WPF中复制下面的效果。我有一个网格控件,其中的边框背景色为#000000,不透明度为0.7,还有一个像这样的内容演示器

<Grid>
    <Border Background="#000000" Opacity="0.7" />
    <ContentPresenter ... />
</Grid>

我在控件的内容中放置了一个椭圆,试图获得效果,但我已经到达了一个路障

<Control:SomeControl>
    <Ellipse Fill="Transparent" />
</Control:SomeControl>

感谢您的帮助


您可以设置覆盖元素的
Clip
属性(如下面的矩形)。请注意,覆盖必须位于其他图元的顶部

<Grid>
    <TextBlock Margin="80,80" Text="Some Text" FontSize="32"/> 
    <Rectangle Fill="Black" Opacity="0.7">
        <Rectangle.Clip>
            <CombinedGeometry GeometryCombineMode="Exclude">
                <CombinedGeometry.Geometry1>
                    <RectangleGeometry Rect="0,0,10000,10000"/>
                </CombinedGeometry.Geometry1>
                <CombinedGeometry.Geometry2>
                    <EllipseGeometry Center="100,100" RadiusX="50" RadiusY="50"/>
                </CombinedGeometry.Geometry2>
            </CombinedGeometry>
        </Rectangle.Clip>
    </Rectangle>
</Grid>