WPF popup控件的使用
<Window x:Class= "WPFPopup.RuntimePopup" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml" Title= "RuntimePopup" Height= "800" Width= "800" Loaded= "Window_Loaded" > <StackPanel> <Button Height= "300" >T</Button> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <CheckBox Name= "PCheckBox" Width= "100" Margin= "60,10,0,0" Content= "Popup Window" /> <CheckBox Name= "PCheckBox2" Grid.Column= "1" Width= "100" Margin= "0,10,0,0" Content= "Popup Window" /> </Grid> <Button HorizontalAlignment= "Left" Width= "169" Margin= "10,10,0,0" > <Button.Triggers> <EventTrigger RoutedEvent= "Button.Click" > <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName= "theTransform" Storyboard.TargetProperty= "(RotateTransform.Angle)" From= "0" To= "360" Duration= "0:0:5" AutoReverse= "True" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> Start Animation </Button> <Popup x:Name= "popusBottom" IsOpen= "{Binding ElementName=PCheckBox,Path=IsChecked}" PlacementTarget= "{Binding ElementName=PCheckBox}" AllowsTransparency= "True" PopupAnimation= "Fade" HorizontalOffset= "5" VerticalOffset= "-120" > <Canvas Margin= "150" Background= "Green" > <Canvas.RenderTransform> <RotateTransform x:Name= "theTransform" /> </Canvas.RenderTransform> <WrapPanel > <WrapPanel.Background> <ImageBrush ImageSource= "BG.png" /> </WrapPanel.Background> <Button Click= "Button_Click" Margin= "15" >Test</Button> <ListBox Height= "90" Margin= "15" > <ListBoxItem>Item1</ListBoxItem> <ListBoxItem>Item2</ListBoxItem> <ListBoxItem>Item3</ListBoxItem> <ListBoxItem>Item1</ListBoxItem> <ListBoxItem>Item2</ListBoxItem> <ListBoxItem>Item3</ListBoxItem> <ListBoxItem>Item1</ListBoxItem> <ListBoxItem>Item2</ListBoxItem> <ListBoxItem>Item3</ListBoxItem> </ListBox> </WrapPanel> </Canvas> </Popup> <Popup x:Name= "popusBottom2" IsOpen= "{Binding ElementName=PCheckBox2,Path=IsChecked}" PlacementTarget= "{Binding ElementName=PCheckBox2}" AllowsTransparency= "True" PopupAnimation= "Fade" HorizontalOffset= "5" VerticalOffset= "-120" > <Canvas Margin= "150" > <WrapPanel > <WrapPanel.Background> <ImageBrush ImageSource= "BG.png" /> </WrapPanel.Background> <Button Click= "Button_Click" Margin= "15" >Test</Button> <ListBox Height= "90" Margin= "15" > <ListBoxItem>Item1</ListBoxItem> <ListBoxItem>Item2</ListBoxItem> <ListBoxItem>Item3</ListBoxItem> <ListBoxItem>Item1</ListBoxItem> <ListBoxItem>Item2</ListBoxItem> <ListBoxItem>Item3</ListBoxItem> <ListBoxItem>Item1</ListBoxItem> <ListBoxItem>Item2</ListBoxItem> <ListBoxItem>Item3</ListBoxItem> </ListBox> </WrapPanel> </Canvas> </Popup> </StackPanel> </Window> |
C# code
public partial class RuntimePopup : Window { public RuntimePopup() { InitializeComponent(); LocationChanged += new EventHandler(RuntimePopup_LocationChanged); } void RuntimePopup_LocationChanged( object sender, EventArgs e) { var mi = typeof (Popup).GetMethod( "UpdatePosition" , System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); mi.Invoke(popusBottom, null );//控制popup随window移动而移动 } private void Button_Click( object sender, RoutedEventArgs e) { MessageBox.Show( "Test" ); } } |
WPF popup控件的使用的更多相关文章
- WPF Popup 控件导致被遮挡内容不刷新的原因
WPF Popup 控件导致被遮挡内容不刷新的原因 周银辉 今天在写一个WPF控件时用到了Popup控件,很郁闷的情况是:当popup关闭时,原来被popup挡住的界面部分不刷新,非要手动刷新一下(比 ...
- 自定义WPF Popup控件
解决问题 1.WPF Popup 不随着 Window 一起移动的问题 2.WPF Popup 总是显示在最前面 引用命名空间 xmlns:ctrl="clr-namespace:Micro ...
- 解决wpf popup控件遮挡其他程序的问题
public class PopupNonTopmost : Popup { public static DependencyProperty TopmostProperty = Window.Top ...
- wpf 客户端【JDAgent桌面助手】开发详解(四) popup控件的win8.0的bug
目录区域: 业余开发的wpf 客户端终于完工了..晒晒截图 wpf 客户端[JDAgent桌面助手]开发详解-开篇 wpf 客户端[JDAgent桌面助手]详解(一)主窗口 圆形菜单... wpf 客 ...
- 关于WPF中Popup控件的小记
在wpf开发中,常需要在鼠标位置处弹出一个“提示框”(在此就以“提示框”代替吧),通过“提示框”进行信息提示或者数据操作,如果仅仅是提示作用,使用ToolTip控件已经足够,但是有些是需要在弹出的框中 ...
- WPF中Popup控件在Win7以及Win10等中的对齐点方式不一样的解决方案 - 简书
原文:WPF中Popup控件在Win7以及Win10等中的对齐点方式不一样的解决方案 - 简书 最近项目中使用弹出控件Popup,发现弹出框的对齐方式在不同的系统中存在不同(Popup在win10上是 ...
- 【WPF】使用Popup控件做浮窗/提示框
需求:当鼠标移入某个区域时,弹出一个浮窗,以便用户进行下一步操作. 效果如下图: 当鼠标移入左上角的[多选显示]框内,出现下面的浮窗(悬浮在原UI之上).当在浮窗外点击鼠标左键时,隐藏该浮窗. 由于该 ...
- WPF中Popup控件的使用
一.Popup控件的主要属性 Popup表示具有内容的弹出窗口,其主要属性为: Child:获取或设置 Popup控件的内容. IsOpen:获取或设置一个值,该值指示Popup 是否可见 Place ...
- 迟到的 WPF 学习 —— 控件
这一章书中内容比较多而杂,但每个对象的内容又相对简短,所以只挑选里边有代表性的内容做记录. 1. Label 控件:一个基础的简单的 ContentControl,Labe 支持快捷键文本的设置,可以 ...
随机推荐
- 超级钢琴 BZOJ 2006
超级钢琴 [问题描述] 小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以弹奏出n个音符,编号为1至n.第i个音符的美妙度 ...
- xml文档绑定某个属性值到treeview算法
原文发布时间为:2008-08-10 -- 来源于本人的百度文章 [由搬家工具导入] using System.Xml; protected void Button2_Click(object sen ...
- 致命错误:ext/standard/php_smart_str.h:没有那个文件或目录
致命错误:ext/standard/php_smart_str.h:没有那个文件或目录 参考文章:https://blog.csdn.net/jartins/article/details/80371 ...
- AC日记——Weird Rounding Codeforces 779b
B. Weird Rounding time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- ScrollView 嵌套WebView 的问题优化
一.布局样式 <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:androi ...
- 1005 Spell It Right
1005 Spell It Right Given a non-negative integer N, your task is to compute the sum of all the dig ...
- IntelliJ IDEA ,springboot 2.0 +mybatis 创建和访问数据库
环境: JDK8+windows10 步骤 New Module —>Spring Initializr—>next 1 2. 3.web勾选web,sql里面可以不勾,后续添加, ...
- IDEA一个窗口打开多个项目
首先IDEA没有Eclipse的Workspace的概念,且IDEA推荐是一个窗口对应着一个Project. 然后经过研究你会发现IDEA其实是由一个主进程来维护这些窗口的,所以即使你开了很多个窗口, ...
- SilverLight-DataBinding:二、Bingding to a Collection Objects(绑定一个集合对象)
ylbtech-SilverLight-DataBinding: Bingding to a Collection Objects(绑定一个集合对象) 1.A, Building a Data Ob ...
- 利用Thinkphp 5缓存漏洞实现前台Getshell
0×00 背景 网站为了实现加速访问,会将用户访问过的页面存入缓存来减小数据库查询的开销.而Thinkphp5框架的缓存漏洞使得在缓存中注入代码成为可能.(漏洞详情见参考资料) 本文将会详细讲解: 1 ...