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 支持快捷键文本的设置,可以 ...
随机推荐
- SharepPoint 2013安装体会
SharePoint 2013出来了,一直没有找到合适的机器来安装.前天腾出来一台内存8G的机器,决定在Hyper-V上安装在一台虚机,然后装个Windows 2012,再装SharePoint 20 ...
- 【CF1016B】Segment Occurrences(模拟)
题意:给定两个串s和t,多次询问s的一个区间[l ,r]中有多少个子串与t串相同 len<=1e3,q<=1e5 思路:前缀和 #include<cstdio> #includ ...
- angular关于依赖注入
<html> <head> <title>Angular JS Forms</title> </head> <body> < ...
- postgresql 10 ltree 使用说明
官方文档 https://www.postgresql.org/docs/10/static/ltree.html ltree是俄罗斯Teodor Sigaev和Oleg Bartunov共同开发的P ...
- bzero 字符数组清零
原来bzero()是这个功能,学习啦.下面的文章可以好好参考,出处:http://hi.baidu.com/wg_wang/item/5fa42c15c73b8efa9c778af8 bzero &a ...
- 浅谈HookSSDT和和Resume(恢复)SSDT
最近在学HookSSDT和针对Hook的ResumeSSDT,避免自己理解有所偏差,把它们写出来,希望大家不吝赐教.(虽然已经是过时了的技术,但是最起码了解其中的原理,嘿嘿嘿.) 转载注明出处:ht ...
- pycharm上传代码到码云错误现象用户密码
>>出现此时错误说明在pycharm>git登录用户名或密码是错误的(必须填成是自己注册的码云邮箱和密码 不允许出现中文)并且无法在当前修改用户名或密码 >>接下来打开电 ...
- guake使用
1. 安装:sudo apt-get install guake 2. 在终端输入guake 3. f12:显示/隐藏 4. f11:全屏/正常屏切换 5. f2:重命名终端名 6. 还可以查看修改快 ...
- django使用logging记录日志
django使用logging记录日志,我没有用这方式去记录日志,主要还是项目小的原因吧, 有机会遇见大项目的话可以回头研究. 配置setting.py配置文件 import logging impo ...
- POJ 3660 Cow Contest 传递闭包+Floyd
原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Subm ...