ContextMenuService.HasDropShadow 附加属性

定义

获取或设置指示 ContextMenu 是否已启用投影效果的值。

see GetHasDropShadow, and SetHasDropShadow
see GetHasDropShadow, and SetHasDropShadow
see GetHasDropShadow, and SetHasDropShadow

示例

以下示例为两个按钮分配相同的ContextMenu值,并设置PlacementPlacementRectangleHasDropShadow每个按钮的相同位置、属性HorizontalOffsetVerticalOffset属性。ContextMenu

<StackPanel>
  <StackPanel.Resources>
    <ContextMenu x:Key="myContextMenu">
      <MenuItem Header="Item"/>
    </ContextMenu>
  </StackPanel.Resources>

  <!--Both buttons use the same ContextMenu but use the
    properties on ContextMenuService to position them
    differently.-->
  <Button ContextMenu="{StaticResource myContextMenu}" 
          ContextMenuService.HasDropShadow="False" 
          ContextMenuService.Placement="Relative"
          ContextMenuService.HorizontalOffset="50"
          ContextMenuService.VerticalOffset="-10">
    button 1
  </Button>

  <Button ContextMenu="{StaticResource myContextMenu}" 
          ContextMenuService.HasDropShadow="True"
          ContextMenuService.Placement="Right"
          ContextMenuService.PlacementRectangle="0,0,30,30">
    button 2
  </Button>
</StackPanel>

注解

打开 ContextMenu 时,该值设置为值 SystemParameters.DropShadow。 如果SystemParameters.DropShadow属性为 false,则此属性设置为true无效。

依赖项属性信息

标识符字段 HasDropShadowProperty
元数据属性设置为 true

适用于

另请参阅