views:

47

answers:

1

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?

A: 

This could lead you in the right direction: http://stackoverflow.com/questions/2804265/glowing-label-controls-on-a-glass-surface/2809223#2809223

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>
Tendlon
That blurred the text, but didn't add any kind of background to it. Did I do something wrong, or is that all that sample is intended to do? As I said, this part of WPF is rather beyond me.
JustABill
Try the edited answer's sample. I added a color to the blur (kind of).What the sample is supposed to do is replace the control template for a label so that contentpresenter is shown twice, one with a blur effect applied and then overlayed with the original contennt. Depending on how your code looks, this may or may not work out of the box. Post some code if this doesnt work.
Tendlon
Ok, that worked, I'll now just have to adjust it until it looks the way I want. Thanks!
JustABill