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 ...
随机推荐
- 从零开始,搭建 AI 音箱 Alexa 语音服务
https://blog.csdn.net/gitchat/article/details/78869367
- 日常记Bug
前记:后端写代码应该对数据的交互更加掌握,不要被编码.数据模型细节坑住 Unicode编码.Django数据迁移偶尔产生的不稳定 处理细项工资记录模型: class TeachRoll(models. ...
- 《BUG创造队》第一次作业:团队亮相
项目 内容 这个作业属于哪个课程 2016级软件工程 这个作业的要求在哪里 第五次实验 团队名称 BUG创造队 作业学习目标 通过本次项目了解并熟悉团队开发的过程 关于我们 -我们的队名:BUG创造队 ...
- sqlserver isnull函数
isnull(参数1,参数2),判断参数1是否为NULL,如果是,返回参数2,否则返回参数1. select ISNULL(null,'helloword') 返回helloword字符串select ...
- JQuery的常用选择器 转
JQuery的常用选择器 刚开始学JQuery写的如有错误欢迎批评指正 JQuery拥有的选择器可以让我们更快更方便找到想要的元素,然后对相应的元素进行操作 简单介绍一下一些常用的选择器: 1.基本选 ...
- python pyqt4问题记录
在python中在终端中使用pip无法完成pyqt4的安装. 在官网下载相应的最新文件,在cmd中使用命令也无法实现安装 最终发现python最新的版本(现在已是3.7版本),无法安装. 解决办法为将 ...
- asp.net 跨域访问
摘自 https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests- ...
- Linux内存管理(二)
Linux内存管理之二:Linux在X86上的虚拟内存管理 本文档来自网络,并稍有改动. 前言 Linux支持很多硬件运行平台,常用的有:Intel X86,Alpha,Sparc等.对于不能够通用的 ...
- bind与继承 待研究
class a { f() { console.log('a') } get f2() { console.log('f2') return (this['f'] = this.f.bind(this ...
- JS中的作用域(一)-详谈
本篇文章在于详细解读JavaScript的作用域,从底层原理来解释一些常见的问题,例如变量提升.隐式创建变量等问题,在和大家一起交流进步的同时,也算对自己知识掌握的记录,方便以后复习 首先,直接捡干的 ...