admin管理员组文章数量:1794759
wpf
当前效果:移入textblock范围内时浮窗出现,移出时消失。
前台
<Grid x:Name="mainGrid" ShowGridLines="True"><Grid.RowDefinitions><RowDefinition Height="auto"/><RowDefinition Height="*"/></Grid.RowDefinitions><Grid Grid.Row="0"><TextBlock Text="测试浮窗" MouseMove="TextBlock_MouseMove"MouseLeave="TextBlock_MouseLeave"Margin="10, 20, 10,10"Width="50"/><Popup x:Name="popPath" AllowsTransparency="True"><Border BorderBrush="Transparent" BorderThickness="0" Background="Transparent"><Grid HorizontalAlignment="Center" VerticalAlignment="Center"><Path Stroke="Black" StrokeThickness="1" Fill="White" Data="M 0,0 L 120,0 L 120,30 L 65,30 L 60,35 L 55,30 L 0,30 Z"/><Grid x:Name="grpopPath" Margin="5,5,5,10"><TextBlock x:Name="tbPath" Foreground="Black" FontSize="13" HorizontalAlignment="Center" VerticalAlignment="Center"/></Grid></Grid></Border></Popup></Grid></Grid>
后台
private void TextBlock_MouseMove(object sender, MouseEventArgs e){TextBlock t = (TextBlock)sender;tbPath.Text = t.Text;// 位置Point p = e.GetPosition(mainGrid);popPath.IsOpen = true;popPath.HorizontalOffset = p.X - 60;popPath.VerticalOffset = p.Y -100;}private void TextBlock_MouseLeave(object sender, MouseEventArgs e){popPath.IsOpen = false;}
本文标签: WPF
版权声明:本文标题:wpf 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1692506020a140464.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论