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

发布于 2024-09-04 06:20:51 字数 223 浏览 1 评论 0原文

aero glass titlebar example

Aero 中的所有窗口的文本上都有这种白色背景。我想为我正在使用的 GlassWindow 创建与此效果等效的效果,该 GlassWindow 在标签区域中有一个 TextBlock,但我并不是真正的设计师,所以我不知道如何实现这一点。如何重现这种背景效果?

aero glass titlebar example

All windows in Aero have this kind of whiteish background on their text. I'd like to create an equivalent of this effect for a GlassWindow I'm using that has a TextBlock in the label area, but I'm not really a designer so I have no idea how to approach this. How can I reproduce this background effect?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫﹏色ふ单纯 2024-09-11 06:20:51

这可能会引导您走向正确的方向:Glowing Label Controls On A玻璃表面

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

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

This could lead you in the right direction: Glowing Label Controls On A Glass Surface

EDIT: Modified the original sample (linked) and added color tot the blur

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文