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 ...
随机推荐
- css过渡
过渡transition是一个复合属性 例子1 .example{ width: 200px; height: 100px; background-color: blanchedalmond; tra ...
- Linux中一个快速查找文件和目录的命令
功能介绍: locate命令其实是find -name的另一种写法,但是要比后者快得多,原因在于它不搜索具体目录,而是搜索一个数据库/var/lib/locatedb,值得注意的是:版本不同,会有所不 ...
- springboot使用fastjson中文乱码解决方法 【转载】
以前使用fastjson替换jackson时,没有直接在页面打印过json,都是js使用没有出现乱码,偶然 打印出来出现了中文乱码 之前使用的配置方式 @Configuration public cl ...
- Java基本类型内存字节数
基本类型 字节数 位(bit) 取值范围 byte 1 1*8 -128~127 short 2 2*8 int 4 4*8 long 8 8*8 float 4 4*8 double ...
- 访问链接出现 ERR_CONTENT_DECODING_FAILED 错误的解决办法
今天跑一个应用,别人的机器上都是好的,但是本地部署就是不行.访问页面调试工具console总是提示 ERR_CONTENT_DECODING_FAILED 错误. 就是数据表格无法显示,经排查,发现是 ...
- VS2017开发.net core 时默认发布路径文件夹多个BPC
新安装的VS2017,编译后进行发布,结果在bin文件夹下多了个BPC文件夹,很是费解,查了资料才知道是VS2017默认设置了环境变量.在此记录下,如果不需要默认路径可修改环境变量,具体操作如下: 我 ...
- nextcloud大文件无法上传
I think that if u got a small /tmp like i had u cant upload big file…My /tmp = 462M so i can upload ...
- 常用adb 指令
adb指令 monkey https://www.cnblogs.com/aland-1415/p/6949964.html
- Kali Linux Vmware虚拟机(新手)安装
准备工作: 1.安装VMware workstation 软件 2.下载好kali linux 的ios系统文件 3.打开电脑的虚拟化支持(Intel VT-x/EPT或AMD-V/RVI(V)) 虚 ...
- 大数据之NBA
2017年NBA季后赛落幕后,网络上仍有大量关于NBA关键词的搜索. 这是近30天来,通过PC端和移动端搜索的趋势,可以看到有些日期的搜索指数是猛增的,因为NBA有大新闻爆出,比如8月23日,骑士与凯 ...