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

时间:2010-06-06 18:50:09

标签: wpf text background aero aero-glass

aero glass titlebar example

Aero中的所有窗口都有这种白色背景。我想为我正在使用的GlassWindow创建一个等效的效果,它在标签区域有​​一个TextBlock,但我不是真正的设计师,所以我不知道如何处理它。如何重现这种背景效果?

1 个答案:

答案 0 :(得分:0)

这可能会引导您朝着正确的方向前进:Glowing Label Controls On A Glass Surface

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

<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>