zoukankan      html  css  js  c++  java
  • silverlight中鼠标放在对象的提示事件

    1、xaml 中实现

     <Rectangle x:Name="toolTip" Grid.Column="0"  Grid.Row="1" Fill="White"  Width="100" Height="100">
                <ToolTipService.ToolTip>
                    <TextBlock>这里是toolTip!</TextBlock>
                </ToolTipService.ToolTip>
    </Rectangle>

    2、c#语言中实现

    string tip = "这里是toolTip!";
    toolTip.SetValue(ToolTipService.ToolTipProperty, tip);
    <!--xaml里面矩形的定义-->
    <Rectangle x:Name="toolTip" Grid.Column="0"  Grid.Row="1" Fill="White"  Width="100" Height="100">       
    </Rectangle>

    3、曲线救国

    添加一个Popu控件,并实现两个Mouse事件即可。

     <Rectangle x:Name="toolTip"  Grid.Column="0"  Grid.Row="1" Fill="White"  Width="100" Height="100" MouseLeave="toolTip_MouseLeave" MouseMove="toolTip_MouseMove">       
    </Rectangle>
    <Popup x:Name="tip">
            <TextBlock Foreground="Red" Text="这里是Popup"/>
            <!--<Rectangle Fill="DeepSkyBlue" Width="60" Height="40" />-->
     </Popup>
     private void toolTip_MouseLeave(object sender, MouseEventArgs e)
            {
                this.tip.IsOpen = false;  
            }
    
    private void toolTip_MouseMove(object sender, MouseEventArgs e)
            {
                this.tip.IsOpen = true; 
                this.tip.HorizontalOffset = e.GetPosition(null).X + 20; 
                this.tip.VerticalOffset = e.GetPosition(null).Y - 20; 
            }

     

  • 相关阅读:
    mysql 更改字符集
    修改pip源
    git命令
    virtualwrapper使用
    Python环境搭建
    IntellIJ IDEA 配置 Maven 以及 修改 默认 Repository
    Spring4:JDBC
    Spring3:AOP
    Spring2:bean的使用
    Spring1:Spring简介、环境搭建、源码下载及导入MyEclipse
  • 原文地址:https://www.cnblogs.com/lwngreat/p/4838545.html
Copyright © 2011-2022 走看看