zoukankan      html  css  js  c++  java
  • WPF 工具提示(ToolTip)

    WPF的工具提示实现方法如下

    1:简单的工具提示只需设置元素的ToolTip属性

         example:

    <Button Margin="20" Grid.Row="2" ToolTip="This is a button">
    another button
    </Button>

    2:复杂的工具提示需要使用更复杂的嵌套内容设置ToolTip属性

    example:

    代码
    <Window x:Class="grid_Study.MainWindow"
    xmlns
    ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
    ="http://schemas.microsoft.com/winfx/2006/xaml"
    Title
    ="MainWindow" Height="350" Width="525" >
    <Button Content="my button">
    <Button.ToolTip>
    <StackPanel>
    <TextBlock Margin="3">Image and text</TextBlock>
    <Image Source="C:\Users\Public\Pictures\Sample Pictures\baxianhua.jpg" Width="150" Height="150"/>
    <TextBlock Margin="3">Image and text</TextBlock>
    </StackPanel>
    </Button.ToolTip>
    </Button>
    </Window>

    3.工具提示的显示位置:

    3.1 相对于鼠标的位置

    3.2 相对于元素的侧边

    3.3 相对于元素进行偏移

     

    4.设置ToolTipService属性

    通过ToolTipService属性配置工具提示框显示的延迟时间

  • 相关阅读:
    致橡树——舒婷
    MPU6050
    Android自动折行TextView Group
    基于LRU Cache的简单缓存
    如果不能给心以翅膀,她如何飞翔
    ubuntu手机识别
    Webkit JNI
    scrapy入门
    Webkit二:RenderTree 创建
    Webkit一:Dom转码和解析
  • 原文地址:https://www.cnblogs.com/greenteaone/p/1906890.html
Copyright © 2011-2022 走看看