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; 
            }

     

  • 相关阅读:
    Gym
    Gym 100712H
    CodeForces
    CodeForces
    P1103 书本整理(DP)
    P1435 回文子串(最长公共子序列)
    P1095 守望者的逃离(线性DP)
    P1077 摆花(背包)
    P1832 A+B Problem(再升级)
    P1757 通天之分组背包(分组背包)
  • 原文地址:https://www.cnblogs.com/lwngreat/p/4838545.html
Copyright © 2011-2022 走看看