本文介绍了玻璃表面上的发光标签控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法,教程,文章和示例,使在运行时创建的每个新Label Control都可以像在Vista/7上一样焕发光芒?

Is there any way, and any tutorials, articles, samples around that allow each and every new Label Control created at runtime to have a Glow around it, just like on Vista/7?

谢谢

推荐答案

无法看到附件的图像,因此只能猜测应该是什么样子-我在WPF中通过更改模板的模板进行了快速测试标记并添加另一个应用了BlurEffect的ContentPresenter.

Not being able to see the attached image, and therefore only guessing what the desired looks should be - I made a quick test in WPF with altering the template of a Label and adding a second ContentPresenter with a BlurEffect applied.

假设外观是您想要的,这是一种快速简便的方法.

Assuming the looks is what you are looking for, it's a quick and easy way to go.

<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 ContentTemplate="{TemplateBinding ContentTemplate}"
                                Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Opacity="0.5">

                                <ContentPresenter.Effect>
                                    <BlurEffect Radius="5"  />
                                </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>

这篇关于玻璃表面上的发光标签控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:18