Glowing Label Controls On A Glass Surface [closed]
Asked Answered
A

1

5

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?

Thank you

Adkisson answered 10/5, 2010 at 16:9 Comment(7)
Changed the 'Glow' tag to WPF because its more likely that the solution will be WPF based.Encumber
This can certainly be accomplished in WPF (probably quite trivially, as well), but can you attach a screenshot which better illustrates the desired effect?Jones
Appears the image is not hosted properly. Should probably host it on Imageshack or something of that sort.Jones
@Charlie: Out of curiosity, do you see the binary contents of a GIF image, or an image that reads "I am a lousy bandwidth thief / Don't trust me! / Hosting © ababa.net"?Arteritis
If I do right-click, save as, I see the bandwidth thief message. If I just click the link I see the binary.Jones
For the benefit of all, please do update the image.Mouse
yeh i just uploaded the 40-something kilobyte image to my free hosting account... and they call that stealing. What idiots.Adkisson
V
3

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>
Vagina answered 11/5, 2010 at 8:50 Comment(2)
Wow, thank you for that. One question; Where abouts would I paste this code? Obviously it'll be somewhere inside the XAML file, but where? Sorry, I haven't used WPF very much. But after seeing a few things tonight, I love it!Adkisson
Short answer: For the sake of being pragmatic and getting your stuff working, paste this in your window's resource section. ... <Window.Resources> ...[insert the style here]... </Window.Resources> Long answer: Read up on resource handling in WPF.Vagina

© 2022 - 2024 — McMap. All rights reserved.