询问者
WPF 如何实现窗体背景透明,并且边框带有阴影效果

问题
全部回复
-
你好,
一般的方式是重写窗体样式,在图片容器外套一层容器,对它应用DropShadowEffect:
<Window x:Class="WpfWindowDropShadowEffect.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="70" Width="320" WindowStyle="None" AllowsTransparency="True" Background="Transparent" WindowStartupLocation="Manual"> <Border Margin="10"> <Border.Effect> <DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" ShadowDepth="2"/> </Border.Effect> <StackPanel Orientation="Horizontal" > <Image Source="Images\1.ico" Height="50" Width="50" /> <Image Source="Images\2.ico" Height="50" Width="50" /> <Image Source="Images\3.ico" Height="50" Width="50" /> <Image Source="Images\4.ico" Height="50" Width="50" /> <Image Source="Images\5.ico" Height="50" Width="50" /> <Image Source="Images\6.ico" Height="50" Width="50" /> </StackPanel> </Border> </Window>
我的ICO都是Metro样式的,如截图看来基本没问题,对于像你这种ICO,有个问题是阴影会环绕每个图标,而不是环绕整个窗体。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
你好,
我们可以很方便地重写窗体,达到你要的基本布局,但是如果要同时保证边框阴影,我有个想法是用假透明实现,即获取到窗体以下的桌面图片,设置为窗体背景,再应用透明,这样可以在保证透明效果的同时,加上阴影。不过WPF不像Winform,窗体渲染方式不一样,这么做不太好实现。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.