当前位置:网站首页>Using XAML only to realize the effect of ground glass background panel

Using XAML only to realize the effect of ground glass background panel

2022-06-21 07:14:00 Bullseye

        For some reason , In a wpf I want to make a frosted glass effect in my application Panel, Put some picture buttons on it , And then superimposed on a listbox( The content is pictures ) On . I think it will be pretty good .

        I spent some time on the Internet , The feeling is quite complicated , I still have to write c# Code . I think I should only write xaml That's enough , No resources found , Just write it yourself .

        Refer to some information , I think the key lies in this Panel The background of the need to refer to another Panel Image and do blur operation .

        Refer to another Panel In fact, the image is to put their own background Visual binding To that Panel On .

        Find out which container can contain Visual and Effect, So you can do the background . by the way , Use Border‘!

                <Border.Background>
                    <VisualBrush Stretch="Uniform" Visual="{Binding ElementName=targetPanelName}"/>
                </Border.Background>

                <Border.Effect>
                    <BlurEffect Radius="50"></BlurEffect>
                </Border.Effect>

      To do that, you need a ground glass background Panel, Adjust the size , Location , Set this Panel The background is Transprent.

      According to this Panel The location of , size , Set up Border.Clip

                <Border.Clip>
                    <RectangleGeometry Rect="0,0,200,200"/>
                </Border.Clip>

And then OK 了 ! well , It's quite simple !

No need, no need Panel Drag and drop , But it should not be difficult , Modify this in the code Border.Clip Just fine .

resources :https://download.csdn.net/download/bullseye/12404719

 

原网站

版权声明
本文为[Bullseye]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221538543488.html