WPF随笔---virtualBrush 实现模糊效果

最近做一个毛玻璃覆盖层效果

底层代码

<Grid x:Name="bg" Background="#00000000">
            <StackPanel>
                <Button  Height="40" HorizontalAlignment =" Left">
                    <Label Content="BtnBtn" FontWeight="Bold"/>
                </Button>
                <Button  Height="40" HorizontalAlignment =" Left">
                    <Label Content="BtnBtn" FontWeight="Bold"/>
                </Button>
                <Button  Height="40" HorizontalAlignment =" Left">
                    <Label Content="BtnBtn" FontWeight="Bold"/>
                </Button>
            </StackPanel>
        </Grid>

覆盖层代码

<Grid x:Name="cover" Visibility="Visible">
            <Border>
                <Border.Background>
                    <VisualBrush Visual="{Binding ElementName=bg}" Stretch="None">
                    </VisualBrush>
                </Border.Background>
                <Border.Effect>
                    <BlurEffect Radius="4" RenderingBias="Performance"/>
                </Border.Effect>
            </Border>
        </Grid>

原始效果图

 

posted on 2016-05-27 15:45  吹鬼灯  阅读(575)  评论(0)    收藏  举报

导航