locked
Problem with inherit Styles and Effects RRS feed

  • Question

  • Hi everybody, I have a problem  with inheritance.

    I've created a border with a grid inside it. The problem is: all the internal elements are inheriting the border style. I need to avoid this inheritance and make the elements inside the border without style or with a different style.

    Eg. In the image A you see the shadow in the border. The internal elements are following this shadow. In the image B you can see the shadow in the border but the internal elements are NOT following this shadow. That is what I want.

    Somebody can help me? Maybe there is a way to avoid this inheritance or something like that.

     Thanks in advance.

    Example

     

     

     

     

    Tuesday, December 29, 2009 7:47 AM

All replies

  • Put another border around your content that doesn't have the effect.

    Tuesday, December 29, 2009 8:01 AM
  • Hi,

    One way to avoid the inheritance is to use Grid to layout the Border and TextBlock to put TextBlock inside Border, instead of add TextBlock as a child of Border, here is a simple samlpe:

    <Grid>
        <Border Margin="0" BorderBrush="Black" BorderThickness="2"> 
            <Border.Effect>
                <DropShadowEffect Color="Black" Direction="320" ShadowDepth="8" BlurRadius="5" Opacity="0.5"/>
            </Border.Effect>
        </Border>
        <TextBlock Text="Here is some text" Margin="0,30,0,0">
        </TextBlock>
    </Grid>
    Wednesday, December 30, 2009 9:34 PM