工具提示保持打开状态

时间:2018-11-30 12:30:58

标签: wpf vb.net

我需要在特定控件上显示ToolTip一段时间,使用此代码我可以显示ToolTip,但它不会消失:

Public Sub tooltipControl(ByVal kontrola As Object, ByVal opened As Boolean, ByVal Optional poruka As String = "", ByVal Optional boja As Object = Nothing)
    Dim ellipse1 As New Ellipse
    ellipse1.Height = 25
    ellipse1.Width = 50
    ellipse1.Fill = Brushes.Gray
    ellipse1.HorizontalAlignment = HorizontalAlignment.Left


    Dim bubble As New ToolTip
    bubble.PlacementTarget = kontrola 
    bubble.Placement = PlacementMode.Bottom
    ToolTipService.SetShowDuration(kontrola, 5000)
    Dim bdec As New BulletDecorator
    Dim littleEllipse As New Ellipse

    littleEllipse.Height = 20
    littleEllipse.Width = 20
    littleEllipse.Fill = boja
    bdec.Bullet = littleEllipse

    Dim tipText As New TextBlock
    tipText.Text = poruka
    bdec.Child = tipText
    bubble.Content = bdec

    bubble.IsOpen = True
    kontrola.ToolTip = bubble
End Sub

1 个答案:

答案 0 :(得分:-1)

在工具提示所属的元素上设置持续时间

ToolTipService.SetShowDuration(kontrola, 5000)

并在打开之前添加工具提示

kontrola.ToolTip = bubble
bubble.IsOpen = True