ToolTipService.SetPlacementTarget(DependencyObject, UIElement) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置对象的 PlacementTarget 附加属性的值。
public:
static void SetPlacementTarget(System::Windows::DependencyObject ^ element, System::Windows::UIElement ^ value);
public static void SetPlacementTarget (System.Windows.DependencyObject element, System.Windows.UIElement value);
static member SetPlacementTarget : System.Windows.DependencyObject * System.Windows.UIElement -> unit
Public Shared Sub SetPlacementTarget (element As DependencyObject, value As UIElement)
参数
- element
- DependencyObject
将附加属性写入到的对象。
- value
- UIElement
要设置的值。
示例
以下示例演示如何设置附加属性的值 ToolTipService.PlacementTarget
。
//create the button that displays the tooltip
Button targetButton = new Button();
targetButton.Content = "tooltip Placement Target";
//create a button that owns the tooltip
Button tooltipOwner = new Button();
tooltipOwner.Content = "tooltip owner";
tooltipOwner.ToolTip = "The ToolTip";
ToolTipService.SetPlacement(tooltipOwner,PlacementMode.Top);
ToolTipService.SetPlacementTarget(tooltipOwner,targetButton);
'create the button that displays the tooltip
Dim targetButton As New Button()
targetButton.Content = "tooltip Placement Target"
'create a button that owns the tooltip
Dim tooltipOwner As New Button()
tooltipOwner.Content = "tooltip owner"
tooltipOwner.ToolTip = "The ToolTip"
ToolTipService.SetPlacement(tooltipOwner,PlacementMode.Top)
ToolTipService.SetPlacementTarget(tooltipOwner,targetButton)