C# 不带位图效果的WPF辉光效果
我已经试过寻找这个问题的解决方案,但没有找到任何结果 我有一个带有自定义C++/CLI钩子的WPF窗口,用于扩展框架(DWMAPI)和将客户端区域扩展到框架(Win32/NCCALCSIZE)。我用WPF添加了一个自定义图标和标题。窗口的标记如下所示(请记住,客户区的大小已调整到玻璃框的边缘):C# 不带位图效果的WPF辉光效果,c#,wpf,effects,C#,Wpf,Effects,我已经试过寻找这个问题的解决方案,但没有找到任何结果 我有一个带有自定义C++/CLI钩子的WPF窗口,用于扩展框架(DWMAPI)和将客户端区域扩展到框架(Win32/NCCALCSIZE)。我用WPF添加了一个自定义图标和标题。窗口的标记如下所示(请记住,客户区的大小已调整到玻璃框的边缘): 窗口如下所示: 我希望文本周围有比当前更不透明的光晕(不是文本块)(半径为15的DropShadow效果几乎不可见,但半径为15的WINAPI光晕更不透明)。最好的方法是什么?(首选自定义效果)作
窗口如下所示:
我希望文本周围有比当前更不透明的光晕(不是文本块)(半径为15的DropShadow效果几乎不可见,但半径为15的WINAPI光晕更不透明)。最好的方法是什么?(首选自定义效果)作为临时解决方案,我在文本块下方放置了一个模糊的白色半透明矩形。工作正常,虽然这不是我想要的-我希望文本模糊,而不必添加矩形。就我理解您的要求而言,我想您应该使用该类来实现您的目标 我创建了一个简单的XAML文件,您可以在本文末尾找到,在这个文件中,我使用了DropShadowEffect(第一列)和BlurEffect(第二列)的各种参数 在模糊效果的情况下,诀窍是包含另一个没有这种效果的文本块,因此文本保持可读性:
<Grid>
<!-- Blurred text -->
<TextBlock Foreground="#FFCCCCCC" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="3.5"/>
</TextBlock.Effect>
</TextBlock>
<!-- Crisp text -->
<TextBlock Text="My Window Title"/>
</Grid>
以下是完整的标记:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Tan">
<Grid Margin="20">
<StackPanel Orientation="Horizontal">
<StackPanel Width="200">
<TextBlock Text="My Window Title"/>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="5"
Color="#FFFFFF"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="5"
Color="#EEEEEE"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="2"
Color="#777777"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="3"
Color="#AAAAAA"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
</StackPanel>
<StackPanel>
<TextBlock Text="My Window Title"/>
<Grid>
<TextBlock Foreground="#FFFFFFFF" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="2.0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
<Grid>
<TextBlock Foreground="#99FFFFFF" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="3.0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
<Grid>
<TextBlock Foreground="#BB999999" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="5.0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
<Grid>
<TextBlock Foreground="#FFCCCCCC" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="3.5"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
</StackPanel>
</StackPanel>
</Grid>
</Page>
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Tan">
<Grid Margin="20">
<StackPanel Orientation="Horizontal">
<StackPanel Width="200">
<TextBlock Text="My Window Title"/>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="5"
Color="#FFFFFF"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="5"
Color="#EEEEEE"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="2"
Color="#777777"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title">
<TextBlock.Effect>
<DropShadowEffect
BlurRadius="3"
Color="#AAAAAA"
Direction="0"
ShadowDepth="0"/>
</TextBlock.Effect>
</TextBlock>
</StackPanel>
<StackPanel>
<TextBlock Text="My Window Title"/>
<Grid>
<TextBlock Foreground="#FFFFFFFF" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="2.0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
<Grid>
<TextBlock Foreground="#99FFFFFF" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="3.0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
<Grid>
<TextBlock Foreground="#BB999999" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="5.0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
<Grid>
<TextBlock Foreground="#FFCCCCCC" Text="My Window Title">
<TextBlock.Effect>
<BlurEffect KernelType="Box" Radius="3.5"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="My Window Title"/>
</Grid>
</StackPanel>
</StackPanel>
</Grid>
</Page>