WPF Popup弹出框箭头自动定位效果
2021-01-31 01:14
标签:fse binding csharp closed pop reg 代码 win block 在WPF中如何做到,点击按钮,弹出一个带箭头的消息框,箭头对准按钮,效果如图所示。 XAML代码 CS代码 看代码其实很简单,只是没想到办法,突然想到了就写一个简单的例子做演示。 WPF Popup弹出框箭头自动定位效果 标签:fse binding csharp closed pop reg 代码 win block 原文地址:https://www.cnblogs.com/chengNet/p/11632675.html
public MainWindow()
{
InitializeComponent();
Popup1.Opened += Popup1_Opened;
Popup1.Closed += Popup1_Closed;
}
private void Popup1_Closed(object sender, EventArgs e)
{
TextBlock1.SetValue(Canvas.LeftProperty, (double)0);
}
private void Popup1_Opened(object sender, EventArgs e)
{
Point point = button.TranslatePoint(new Point(0, 0), this);
Point point2 = TextBlock1.TranslatePoint(new Point(0, 0), this);
TextBlock1.SetValue(Canvas.LeftProperty, point.X - point2.X);
}
private void button_Click(object sender, RoutedEventArgs e)
{
Popup1.IsOpen = true;
}
下一篇:【APIO2018】新家
文章标题:WPF Popup弹出框箭头自动定位效果
文章链接:http://soscw.com/index.php/essay/49253.html