共用方式為


ContextMenuService.HasDropShadow 附加屬性

定義

取得或設定值,指出 ContextMenu 是否有啟用下拉式陰影效果。

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

範例

下列範例會將相同的 ContextMenu 指派給兩個按鈕,並將 、 PlacementPlacementRectangle HorizontalOffsetVerticalOffset 屬性設定 HasDropShadow 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 。 如果 屬性為 false ,則 SystemParameters.DropShadow 此屬性設定為 true 沒有作用。

相依性屬性資訊

識別碼欄位 HasDropShadowProperty
設定為 的中繼資料屬性 true

適用於

另請參閱