2009-10-15 9 views
1

Y a-t-il un moyen de faire apparaître l'ombre du premier contrôle dans un StackPanel au-dessus du second contrôle? J'ai des problèmes avec ça, regardez l'image!
alt text http://img2.imageshack.us/img2/7073/issuef.png
Exemple de code:
Ombre WPF sur les contrôles de la pile

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:sys="clr-namespace:System;assembly=mscorlib"> 
     <Grid> 
     <StackPanel> 
      <Border Height="100" Width="100" Background="Red"> 
       <Border.BitmapEffect> 
        <DropShadowBitmapEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="1" Softness="2" /> 
       </Border.BitmapEffect> 
      </Border> 
       <Border Height="100" Width="100" Background="blue"> 
       </Border> 
      </StackPanel> 
     </Grid> 
    </Page> 

Répondre

3

Vous pouvez faire usage Panel.ZIndex="0" dans chacune des frontières pour définir l'ordre z des éléments directement à partir du XAML.

<StackPanel> 
    <Border Height="100" Width="100" Background="Red" Panel.ZIndex="1"> 
     <Border.BitmapEffect> 
      <DropShadowBitmapEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="1" Softness="2" /> 
     </Border.BitmapEffect> 
    </Border> 
    <Border Height="100" Width="100" Background="blue" Panel.ZIndex="0"> 
    </Border> 
</StackPanel> 

Ou vous pouvez utiliser StackPanel.SetZIndex(object, value) si vous voulez le faire à partir du code.

Questions connexes