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)