none
DropShadow on a PopUp menu

    Question

  • hi,

    I'm wondering how to get a DropShadow on a PopUp menu. I've looked at the post here (http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c6baed1b-4347-4fc8-b63e-26db09b8ba1f) but it doesn't solve my problem.

    The DS is visible in Blend but when I run the project it disappears and is replaced with a black border - Any ideas?

    My code is here (I'm applying the DS effect to the Border object inside the Popup object):

    <ControlTemplate TargetType="{x:Type MenuItem}">
            <Border x:Name="Border"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}">
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition x:Name="Col0" MinWidth="17" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup"/>
                  <ColumnDefinition Width="Auto" SharedSizeGroup="MenuTextColumnGroup"/>
                  <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup"/>
                  <ColumnDefinition x:Name="Col3" Width="14"/>
                </Grid.ColumnDefinitions>
    
                
                <ContentPresenter Grid.Column="0" Margin="4,0,6,0" x:Name="Icon" VerticalAlignment="Center" ContentSource="Icon"/>
    
                
                <Grid Grid.Column="0" Visibility="Hidden" Margin="4,0,6,0" x:Name="GlyphPanel" VerticalAlignment="Center">
                  <Path x:Name="GlyphPanelpath" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z" FlowDirection="LeftToRight"/>
                </Grid>
    
                
                <ContentPresenter Grid.Column="1" Margin="{TemplateBinding Padding}" x:Name="HeaderHost" RecognizesAccessKey="True" ContentSource="Header"/>
    
               
                <ContentPresenter Grid.Column="2" Margin="8,1,8,1" x:Name="IGTHost" ContentSource="InputGestureText" VerticalAlignment="Center"/>
    
                
                <Grid Grid.Column="3" Margin="4,0,6,0" x:Name="ArrowPanel" VerticalAlignment="Center">
                  <Path x:Name="ArrowPanelPath" HorizontalAlignment="Right" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="M0,0 L0,8 L4,4 z"/>
                </Grid>
    
                
                <Popup IsOpen="{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" x:Name="SubMenuPopup" Focusable="false" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
                  <Border x:Name="SubMenuBorder" BorderBrush="#FF202020" Effect="{DynamicResource tabItem_notSelected_ds}" Background="{DynamicResource tabControl_content_fill}" BorderThickness="1" Padding="2,2,2,2" >
                    
    								<Grid x:Name="SubMenu" Grid.IsSharedSizeScope="True">
    								
                      
                      <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
    									
                    </Grid>
                  </Border>
                </Popup>
              </Grid>
            </Border>
    
            
            <ControlTemplate.Triggers>
              <!-- Role = TopLevelHeader : this is the root menu item in a menu; the Popup expands down -->
              <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Padding" Value="8,5,8,5"/>
                <Setter Property="Placement" Value="Bottom" TargetName="SubMenuPopup"/>
                <Setter Property="MinWidth" Value="0" TargetName="Col0"/>
                <Setter Property="Width" Value="Auto" TargetName="Col3"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="GlyphPanel"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="IGTHost"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
              </Trigger>
    
              
              <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Padding" Value="8,5,8,5"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
              </Trigger>
    
              
              <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="DockPanel.Dock" Value="Top"/>
                <Setter Property="Padding" Value="2"/>
              </Trigger>
    
              
              <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="DockPanel.Dock" Value="Top"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="ArrowPanel"/>
    						<Setter Property="Padding" Value="2"/>
              </Trigger>
              <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter Property="PopupAnimation" Value="None" TargetName="SubMenuPopup"/>
              </Trigger>
    
              
              <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
              </Trigger>
    
              
              <Trigger Property="IsChecked" Value="true">
                <Setter Property="Visibility" Value="Visible" TargetName="GlyphPanel"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
              </Trigger>
    
              <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Background" Value="#FF00A7EC" TargetName="Border"/>
                <Setter Property="Foreground" Value="{DynamicResource tabControl_content_fill}"/>
              </Trigger>
              <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource uiFramework_fontColour_inactive}"/>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>

    Thanks,


    Steve.

    Friday, May 21, 2010 10:36 AM

Answers

All replies