Wpf 作为窗口背景的图像模糊效果
我的WPF应用程序中有一个以图像为背景的窗口。我希望那个图像变得模糊。我就是这样做的: 这是我的窗口:Wpf 作为窗口背景的图像模糊效果,wpf,xaml,background,blur,effects,Wpf,Xaml,Background,Blur,Effects,我的WPF应用程序中有一个以图像为背景的窗口。我希望那个图像变得模糊。我就是这样做的: 这是我的窗口: <Window x:Class="kiosk.UI.Views.PageSwitch" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="
<Window x:Class="kiosk.UI.Views.PageSwitch"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:myProjectName.Converters"
Title="PageSwitch" Height="1024" Width="1280"
Style="{StaticResource WindowStyle}"
WindowStyle="None" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen">
</Window>
以下是我应用于它的风格:
<Style x:Key="WindowStyle" TargetType="{x:Type Window}">
<Setter Property="FontFamily" Value="Verdana" />
<Setter Property="Background">
<Setter.Value>
<VisualBrush>
<VisualBrush.Visual>
<Image Source="Images\myImage.png" >
<Image.Effect>
<BlurEffect Radius="20"/>
</Image.Effect>
</Image>
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</Style>
这是可行的-图像模糊。然而,在背景图像周围有一个大约5毫米厚的黑色边框。它为什么在那里?我如何才能删除它
以下是我尝试的替代方案:
<VisualBrush Viewbox="0, 0, 1280, 1024" ViewboxUnits="Absolute" >
边界被移除,但图像被拉伸了很多。几乎一半的图像甚至没有显示出来
如何修复此问题?我做了类似的操作,但只是将图像作为元素添加到LayoutRoot中。由此,我将边距设置为减去模糊半径,以避免边缘模糊。如果你是黑色边框淡入我会怀疑这就是问题所在
<Image Source="pack://siteoforigin:,,,/image.jpg" Stretch="UniformToFill" Margin="-50">
<Image.Effect>
<BlurEffect Radius="100"/>
</Image.Effect>
</Image>
按照前面一个问题中的说明进行操作。将图像控件置于网格中,并将cliptobunds
设置为true
<VisualBrush>
<VisualBrush.Visual>
<Grid ClipToBounds="True">
<Image Source="Images\myImage.png">
<Image.Effect>
<BlurEffect Radius="20"/>
</Image.Effect>
</Image>
</Grid>
</VisualBrush.Visual>
</VisualBrush>