ContextMenuService.HorizontalOffset 附加屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個值,指示該在 x 方向上相 ContextMenu 對於父控制項的位置。
see GetHorizontalOffset, and SetHorizontalOffset
see GetHorizontalOffset, and SetHorizontalOffset
see GetHorizontalOffset, and SetHorizontalOffset
範例
以下範例將相同ContextMenu位置分配給兩個按鈕,並將 HasDropShadow、 Placement、 PlacementRectangle、 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、 PlacementTarget、 PlacementRectangle、 Placement和 HorizontalOffset 屬性來定位 aVerticalOffsetProperty。 這些性質的行為與 Popup中相同。 更多資訊,請參閱 彈出式元件的擺放行為。
相依財產資訊
| Item | 價值觀 |
|---|---|
| 識別碼欄位 | HorizontalOffsetProperty |
元資料屬性設為 true |
None |
XAML 屬性使用方式
<object HorizontalOffset="double"/>
- or -
<object HorizontalOffset="qualifiedDouble"/>
XAML 值
雙重Double
一個數值的 Double 字串表示。 此測量被解釋為與裝置無關的單位(1/96英吋)。 字串不必明確包含小數點。 例如 1 ,值為可接受。
取得雙重資格如上所述的雙倍值,接著是以下其中一個單位宣告字串:px, in, cmpt, 。
px (預設)為裝置無關單位(每單位 1/96 吋)
in 是英吋;1in==96px
cm 是公分;1cm==(96/2.54) px
pt 是分數;1pt==(96/72) px