WPF 中的 OuterGlow 效果不适用于分层窗口?
谁能告诉我为什么 /no/outerglow 效果在我的 WPF 窗口上起作用?这是代码示例:
<Window x:Class="SocialShock_WPF_Client.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
AllowsTransparency="True"
WindowStyle='None'
Background="Transparent"
Loaded="Window_Loaded">
<Grid>
<Rectangle Margin="12" Name="rectangle1" Fill="#FFB75050">
<Rectangle.BitmapEffect>
<OuterGlowBitmapEffect GlowColor="Black" GlowSize="20" />
</Rectangle.BitmapEffect>
</Rectangle>
</Grid>
</Window>
以及生成的图像:
http://img408.imageshack .us/img408/6213/1c1761f31ce6408d948e266.png
边缘没有发光。 不仅矩形上没有出现发光,而且我添加到窗口的任何其他控件也无法接受发光。
编辑:它在.Net 4.0中
can any one tell me why /no/ outerglow effects are working on my WPF Window? here is an example of the code:
<Window x:Class="SocialShock_WPF_Client.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
AllowsTransparency="True"
WindowStyle='None'
Background="Transparent"
Loaded="Window_Loaded">
<Grid>
<Rectangle Margin="12" Name="rectangle1" Fill="#FFB75050">
<Rectangle.BitmapEffect>
<OuterGlowBitmapEffect GlowColor="Black" GlowSize="20" />
</Rectangle.BitmapEffect>
</Rectangle>
</Grid>
</Window>
and the resulting image:
http://img408.imageshack.us/img408/6213/1c1761f31ce6408d948e266.png
No glow around the edge.
not only is the glow not appearing on the rectangle, but any other controls i add to the window cannot accept glows either.
EDIT: its in .Net 4.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.NET 4.0 不再支持 BitmapEffects。
来自 MSDN
没有真正好的替代品,但您可以尝试使用
DropShadowEffect
且ShadowDepth
为 0。示例如果我理解您的评论正确,
添加效果在代码后面
修改代码后面的效果
BitmapEffects are no longer supported in .NET 4.0.
From MSDN
There isn't a really good substitute but you can try to use a
DropShadowEffect
with aShadowDepth
of 0. ExampleIf I understood you comment correctly,
Adding the effect in code behind
Modifying the effect in code behind