Pergunta

In the example below, the LinearGradientBrush gives a bit of a beveled look to the border, The border is stretched across the width, but the height is similiar to a average toolbar. The textblock text in the border looks like it's sitting on top of the bar, I'm curious if there is a way to make the text appear to be in the bar, instead of on top of the bar. Thanks for any direction.

<Border HorizontalAlignment="Stretch" VerticalAlignment="Top" BorderThickness="1" CornerRadius="0" BorderBrush="SlateGray">
    <Border.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="DimGray" Offset="0" />
            <GradientStop Color="Black" Offset="0.5" />
            <GradientStop Color="Gray" Offset="1" />
        </LinearGradientBrush>
    </Border.Background>
    <TextBlock Text="Check for updates" Foreground="AliceBlue" FontWeight="Bold"/>
</Border>
Foi útil?

Solução

Not quite sure what you are looking for but two things that make it more embedded are overlaying a modified version of the background brush and using a gradient for the Text itself, but light it up as if the inside of the border is curved.

<Border HorizontalAlignment="Stretch" VerticalAlignment="Top" BorderThickness="1" CornerRadius="0" BorderBrush="SlateGray">
    <Border.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="DimGray" Offset="0" />
            <GradientStop Color="Black" Offset="0.5" />
            <GradientStop Color="Gray" Offset="1" />
        </LinearGradientBrush>
    </Border.Background>
    <Grid>
        <TextBlock Text="Check for updates" FontWeight="Bold">
            <TextBlock.Foreground>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="DimGray" Offset="0" />
                    <GradientStop Color="AliceBlue" Offset="0.5" />
                    <GradientStop Color="White" Offset="1" />
                </LinearGradientBrush>
            </TextBlock.Foreground>
        </TextBlock>
        <Border>
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="0.5">
                    <GradientStop Color="DimGray" Offset="0" />
                    <GradientStop Color="Transparent" Offset="0.5" />
                    <GradientStop Color="Gray" Offset="1" />
                </LinearGradientBrush>
            </Border.Background>
        </Border>
    </Grid>
</Border>

screenshot

Outras dicas

you need to use such named Effects in WPF. Here is a libary of them http://wpffx.codeplex.com/, the Embossed effect might help you.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top