首页 > Web开发 > 详细

silverlight中鼠标放在对象的提示事件

时间:2015-09-25 18:25:15      阅读:164      评论:0      收藏:0      [点我收藏+]

技术分享

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

 

 技术分享

技术分享

silverlight中鼠标放在对象的提示事件

原文:http://www.cnblogs.com/lwngreat/p/4838545.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!