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 支持快捷键文本的设置,可以 ...
随机推荐
- La 3942 字符串+dp
题目大意:一个字符串,可以分解成若干英语单词的连接(单词可以重复使用),求有多少种方法? #include<iostream> #include<cstdio> #includ ...
- http client transfer
背景 在平时工作中我偶尔会写一些脚本监控HTTP接口的健康状况,基本上都是发送HTTP GET或HTTP POST请求,然后检测响应内容.但一直用的是WebClient和HttpWebRequest, ...
- Spring Boot的web开发&静态资源配置方式
Web开发的自动配置类:org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration 1.1. 自动配置的ViewResolve ...
- HDU 6218 (线段树+set)
HDU 6218 Bridge Problem : 给一个2×n的矩阵,一开始矩阵所有相邻点之间有一条边.有其.个询问,每次给出两个相邻的点的坐标,将其中的边删除或者添加,问如此操作之后整张图的割边数 ...
- Linux 虚拟内存和物理内存的理解【转】
转自:http://www.cnblogs.com/dyllove98/archive/2013/06/12/3132940.html 首先,让我们看下虚拟内存: 第一层理解 1. 每 ...
- LeetCode OJ--Minimum Path Sum **
https://oj.leetcode.com/problems/minimum-path-sum/ 对一个grid从左上角到右下角的路径,求出路径中和最小的. 受之前思路的影响,就寻思递归,并且记录 ...
- js-(19,999,999.00)
function price(n, precision) { let s = String(n), int = parseInt(n).toString(), pre = s.split('.')[1 ...
- linux source filename
简单来说:source filename即把filename文件里的命令(命令集脚本文件)执行一遍,相当于在shell里逐个执行单条命令
- spring mvc 编写处理带参数的Controller
在上一随笔记录的基础上,现记录编写处理带有参数的Controller. @Controller //这个注解会告知<context:component:scan> 将HomeControl ...
- BZOJ1014火星人prefix Splay維護序列 + 字符串哈希
@[Splay, 哈希] Description 火星人最近研究了一种操作:求一个字串两个后缀的公共前缀.比方说,有这样一个字符串:\(madamimadam\), 我们将这个字符串的各个字符予以标号 ...