WPF popup自动关闭
var tileMore = new Tile
{
Height = ,
Width = ,
Background = new SolidColorBrush(Color.FromRgb(, , )),
Title = "更多...",
};
tileMore.SetResourceReference(FrameworkElement.StyleProperty, "KentTile"); Popup popup = new Popup
{
//StaysOpen = false,
PopupAnimation = PopupAnimation.Slide,
PlacementTarget = tileMore,
Placement = PlacementMode.Bottom,
AllowsTransparency = true
};
//pop里面生成的内容,本例是StackPannel中包括一个textbox
WrapPanel stackPanel = new WrapPanel
{
Width = tileMore.Width * ,
Background = Brushes.Transparent
};
stackPanel.Children.Add(/*sth to show*/);
popup.Child = stackPanel; tileMore.MouseEnter += (sender, e) =>
{
popup.IsOpen = true;
}; tileMore.MouseLeave += (s, e) =>
{
if (timerCloseRecentPopup == null)
{
timerCloseRecentPopup = new DispatcherTimer();
timerCloseRecentPopup.Interval = new TimeSpan(, , );
timerCloseRecentPopup.Tag = popup;
timerCloseRecentPopup.Tick += closePopup;
}
timerCloseRecentPopup.Stop();
timerCloseRecentPopup.Start();
}; popup.MouseLeave += (s, e) =>
{
if(timerCloseRecentPopup == null)
{
timerCloseRecentPopup = new DispatcherTimer();
timerCloseRecentPopup.Interval = new TimeSpan(, , );
timerCloseRecentPopup.Tag = popup;
timerCloseRecentPopup.Tick += closePopup;
}
timerCloseRecentPopup.Stop();
timerCloseRecentPopup.Start();
};
/// <summary>
/// 定时关闭 更多 popup窗口
/// </summary>
private DispatcherTimer timerCloseRecentPopup;
private void closePopup(object state,EventArgs e)
{
Popup pop = timerCloseRecentPopup.Tag as Popup;
if(pop == null)
{
//todo timer里面的Assert没有对话框出来
Debug.Assert(true,"pop==null");
return;
} Tile tileMore = pop.PlacementTarget as Tile; if (!pop.IsMouseOver )
{
if(tileMore != null)
{
if(!tileMore.IsMouseOver)
{
pop.IsOpen = false;
timerCloseRecentPopup.Stop();
} }
else
{
pop.IsOpen = false;
timerCloseRecentPopup.Stop();
}
} }
WPF popup自动关闭的更多相关文章
- WPF Popup 控件导致被遮挡内容不刷新的原因
WPF Popup 控件导致被遮挡内容不刷新的原因 周银辉 今天在写一个WPF控件时用到了Popup控件,很郁闷的情况是:当popup关闭时,原来被popup挡住的界面部分不刷新,非要手动刷新一下(比 ...
- WPF Popup 置顶问题
原文 WPF Popup 置顶问题 问题: 使用wpf的popup,当在popup中弹出MessageBox或者打开对话框的时候,popup总是置顶,并遮住MessageBox或对话框. 解决: 写如 ...
- WPF Popup全屏 弹出方法。解决只显示75%的问题。
WPF Popup全屏 弹出方法.解决只显示75%的问题. WPF 中 Popup 有一个特点.当Popup的高度超过屏幕的75%的时候,只显示75%的高度. 如下代码: <Window x ...
- 自定义WPF Popup控件
解决问题 1.WPF Popup 不随着 Window 一起移动的问题 2.WPF Popup 总是显示在最前面 引用命名空间 xmlns:ctrl="clr-namespace:Micro ...
- wpf Popup Win8.0 bug HorizontalOffset 弹出位置偏移
问题描述参考 wpf 客户端[JDAgent桌面助手]开发详解(四) popup控件的win8.0的bug 当开发完程序后,我们在多操作系统测试时候发现:win8.0 系统中 popup 弹出的位置 ...
- WPF popup被截断的原因和修改方法
原因:wpf里 popup不能超过屏幕75%的面积,不知道为什么要这么设置? 修改方法: private void SetPopupScreen() { Rect rtWnd = , , gridMa ...
- WPF Popup 右下角提示框 定时消失 ,以及任意位置定位
------------恢复内容开始------------ 好久没写WPF的博客了,其实有很多心得要总结下,但是懒..... 今天工作需要,需要实现一个 1 右下角的提示窗口,然后过三五秒自动消失这 ...
- WPF popup置顶
在程序写一个popup发现他会在置顶,在网上找了两大神代码http://www.cnblogs.com/Leaco/p/3164394.html http://blog.csdn.net/baijin ...
- WPF popup控件的使用
<Window x:Class="WPFPopup.RuntimePopup" xmlns="http://schemas.microsoft.com/wi ...
随机推荐
- guxh的python笔记十一:异常处理
1,抓错方法 name = [0, 1, 2] try: name[3] except IndexError as exc: # 抓单个错误,打印错误信息e print(exc) except (In ...
- 20165309 《网络对抗技术》实验五:MSF基础应用
20165309 <网络对抗技术>实验五:MSF基础应用 1.基础问题回答 (1)什么是exploit? (2)什么是payload? (3)什么是encode? (4)离实战还缺些什么技 ...
- 【单调队列优化dp】 分组
[单调队列优化dp] 分组 >>>>题目 [题目] 给定一行n个非负整数,现在你可以选择其中若干个数,但不能有连续k个数被选择.你的任务是使得选出的数字的和最大 [输入格式] ...
- div模拟文本框textarea
需求:利用highlight.js对文本框中的内容进行高亮显示 1.highlight.js使用 js中:<script src="js/highlight/highlight.pac ...
- Python3+Requests-HTML+Requests-File解析本地html文件
一.说明 解析html文件我喜欢用xpath不喜欢用BeautifulSoup,Requests的作者出了Requests-HTML后一般都用Requests-HTML. 但是Requests-HTM ...
- No X11 DISPLAY variable was set
在命令行调用图形化界面时报错 “No X11 DISPLAY variable was set” 首先使用xclock命令查看是否能调出时钟,如果不行,使用如下命令: 打开xmanager – pas ...
- scrapy 入门爬取新闻
为文本分类实验爬取数据集,要求一百万,分类>10类. 参考链接:http://litianyi.cc/technology/2015/12/01/text-classification-1/ 文 ...
- linux常用命令 grep命令
linux grep命令 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配行打印出来 grep 全称 Grobal Regular Expression Pr ...
- Oracle查询语句导致CPU使用率过高问题处理
解决此问题的关键在于如何找到造成CPU使用率过高的SQL语句.步骤如下: 1.使用Process Explorer工具查看到Oracle进程,双击Oracle进程,在弹出的属性窗口的Threads选项 ...
- UVa LA 4636 Cubist Artwork 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...