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属性配置工具提示框显示的延迟时间

  • 相关阅读:
    学习进度14
    计算最长英语单词链
    梦断代码阅读笔记02
    梦断代码阅读笔记01
    学习进度13
    评价输入法
    课堂测试——找水王
    第二阶段冲刺05
    实验2
    实验 1 Linux 系统的安装和常用命令
  • 原文地址:https://www.cnblogs.com/greenteaone/p/1906890.html
Copyright © 2011-2022 走看看