Wpf 如何复制应用于Aero窗口标题栏中文本的“背景”?

Wpf 如何复制应用于Aero窗口标题栏中文本的“背景”?,wpf,text,background,aero,aero-glass,Wpf,Text,Background,Aero,Aero Glass,Aero中的所有窗口的文本上都有这种白色背景。我想为我正在使用的在标签区域有文本块的玻璃窗创建一个类似的效果,但我不是一个真正的设计师,所以我不知道如何处理这个问题。如何再现这种背景效果?这可能会引导您走向正确的方向: 编辑:修改链接的原始样本并为模糊添加颜色 <Style TargetType="{x:Type Label}"> <Setter Property="Template"> <Setter.Val

Aero中的所有窗口的文本上都有这种白色背景。我想为我正在使用的在标签区域有文本块的玻璃窗创建一个类似的效果,但我不是一个真正的设计师,所以我不知道如何处理这个问题。如何再现这种背景效果?

这可能会引导您走向正确的方向:

编辑:修改链接的原始样本并为模糊添加颜色

<Style TargetType="{x:Type Label}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Label}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{TemplateBinding Background}" 
                            Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                            <Grid>
                                <ContentPresenter 

                                    Content="{TemplateBinding Content}"
                                    ContentStringFormat="{TemplateBinding ContentStringFormat}" 
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    RecognizesAccessKey="True" 
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                    <ContentPresenter.ContentTemplate>
                                        <DataTemplate>
                                            <TextBlock Foreground="White" Text="{TemplateBinding Content}" />
                                        </DataTemplate>
                                    </ContentPresenter.ContentTemplate>
                                    <ContentPresenter.Effect>
                                        <BlurEffect Radius="10"  />
                                    </ContentPresenter.Effect>
                                </ContentPresenter>

                                <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" 
                                        Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" 
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  RecognizesAccessKey="True" 
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>

                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

这模糊了文字,但没有添加任何背景。是我做错了什么,还是这就是样本的目的?正如我所说的,WPF的这一部分是我无法理解的。请尝试编辑答案的示例。我添加了一种模糊的颜色。该示例要做的是替换标签的控件模板,以便contentpresenter显示两次,一次应用模糊效果,然后与原始contennt重叠。根据代码的外观,这可能是现成的,也可能不是现成的。如果这不起作用,就发布一些代码。好的,这起作用了,我现在只需要调整它,直到它看起来像我想要的那样。谢谢