IAdornerPlacement 接口

更新:2007 年 11 月

AdornerPlacementCollection 指定一个位置项。

命名空间:  Microsoft.Windows.Design.Interaction
程序集:  Microsoft.Windows.Design.Interaction(在 Microsoft.Windows.Design.Interaction.dll 中)

语法

声明
Public Interface IAdornerPlacement
用法
Dim instance As IAdornerPlacement
public interface IAdornerPlacement
public interface class IAdornerPlacement
public interface IAdornerPlacement

备注

位置项用来建立一组值,在 AdornerPanel 上确定装饰器的位置和大小时这些值可以提供灵活性。

示例

下面的代码示例演示如何为轨道装饰器设置在控件内的位置。有关更多信息,请参见演练:在控件内部实现一个轨道

' Place the slider in the adorner panel.
Dim placement As New AdornerPlacementCollection()
AdornerPanel.SetHorizontalStretch(skewSlider, AdornerStretch.Stretch)
AdornerPanel.SetVerticalStretch(skewSlider, AdornerStretch.None)

' Use layout space for the adorner panel.
' If render space were used, the slider would skew along with the button.
panel.CoordinateSpace = AdornerCoordinateSpaces.Layout

' The adorner's width is relative to the content.
' The slider extends half the width of the control it adorns.
placement.SizeRelativeToContentWidth(0.5, 0)

' Center the adorner within the control.
placement.PositionRelativeToAdornerWidth(0.5, 0)

' The adorner's height is the same as the slider's.
placement.SizeRelativeToAdornerDesiredHeight(1.0, 0)

' Position the adorner within the control it adorns.
placement.PositionRelativeToAdornerHeight(1.0, 0)

AdornerPanel.SetPlacements(skewSlider, placement)
// Place the slider in the adorner panel.
AdornerPlacementCollection placement = new AdornerPlacementCollection();
AdornerPanel.SetHorizontalStretch(skewSlider, AdornerStretch.Stretch);
AdornerPanel.SetVerticalStretch(skewSlider, AdornerStretch.None);

// Use layout space for the adorner panel.
// If render space were used, the slider would skew along with the button.
panel.CoordinateSpace = AdornerCoordinateSpaces.Layout;

// The adorner's width is relative to the content.
// The slider extends half the width of the control it adorns.
placement.SizeRelativeToContentWidth(0.5, 0);

// Center the adorner within the control.
placement.PositionRelativeToAdornerWidth(0.5, 0);

// The adorner's height is the same as the slider's.
placement.SizeRelativeToAdornerDesiredHeight(1.0, 0);

// Position the adorner within the control it adorns.
placement.PositionRelativeToAdornerHeight(1.0, 0);

AdornerPanel.SetPlacements(skewSlider, placement);

另请参见

参考

IAdornerPlacement 成员

Microsoft.Windows.Design.Interaction 命名空间

AdornerPlacementCollection

AdornerPanel

其他资源

布局空间和呈现空间

演练:在控件内部实现一个轨道

了解 WPF 设计器扩展性