AdornerPanel.SetPlacements 方法
更新:2007 年 11 月
设置所提供元素的 Placements 附加属性的值。
命名空间: Microsoft.Windows.Design.Interaction
程序集: Microsoft.Windows.Design.Interaction(在 Microsoft.Windows.Design.Interaction.dll 中)
语法
声明
Public Shared Sub SetPlacements ( _
adorner As UIElement, _
value As AdornerPlacementCollection _
)
用法
Dim adorner As UIElement
Dim value As AdornerPlacementCollection
AdornerPanel.SetPlacements(adorner, value)
public static void SetPlacements(
UIElement adorner,
AdornerPlacementCollection value
)
public:
static void SetPlacements(
UIElement^ adorner,
AdornerPlacementCollection^ value
)
public static function SetPlacements(
adorner : UIElement,
value : AdornerPlacementCollection
)
参数
adorner
类型:System.Windows.UIElement要写入 HorizontalStretch 附加属性的 UIElement。
value
类型:Microsoft.Windows.Design.Interaction.AdornerPlacementCollection一个 AdornerPlacementCollection,存放表示 adorner 的大小和位置的 AdornerPlacementValue 对象。
异常
异常 | 条件 |
---|---|
ArgumentNullException | adorner 为 nullnull 引用(在 Visual Basic 中为 Nothing)。 |
示例
下面的代码示例演示如何使用 SetPlacements 方法指定某个装饰器在装饰器面板中的位置。有关更多信息,请参见 演练:创建设计时装饰器。
Dim placement As New AdornerPlacementCollection()
' The adorner's width is relative to the content.
' The slider extends the full width of the control it adorns.
placement.SizeRelativeToContentWidth(1.0, 0)
' The adorner's height is the same as the slider's.
placement.SizeRelativeToAdornerDesiredHeight(1.0, 0)
' Position the adorner above the control it adorns.
placement.PositionRelativeToAdornerHeight(-1.0, 0)
' Position the adorner up 5 pixels. This demonstrates
' that these placement calls are additive. These two calls
' are equivalent to the following single call:
' PositionRelativeToAdornerHeight(-1.0, -5).
placement.PositionRelativeToAdornerHeight(0, -5)
AdornerPanel.SetPlacements(opacitySlider, placement)
AdornerPlacementCollection placement = new AdornerPlacementCollection();
// The adorner's width is relative to the content.
// The slider extends the full width of the control it adorns.
placement.SizeRelativeToContentWidth(1.0, 0);
// The adorner's height is the same as the slider's.
placement.SizeRelativeToAdornerDesiredHeight(1.0, 0);
// Position the adorner above the control it adorns.
placement.PositionRelativeToAdornerHeight(-1.0, 0);
// Position the adorner up 5 pixels. This demonstrates
// that these placement calls are additive. These two calls
// are equivalent to the following single call:
// PositionRelativeToAdornerHeight(-1.0, -5).
placement.PositionRelativeToAdornerHeight(0, -5);
AdornerPanel.SetPlacements(opacitySlider, placement);
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
另请参见
参考
Microsoft.Windows.Design.Interaction 命名空间